批次线数据完善
parent
8b5e73f664
commit
146a14d04b
|
|
@ -272,6 +272,17 @@ namespace New_College.Api.Controllers.Front
|
|||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task SyncBatchInfo()
|
||||
{
|
||||
|
||||
// await t_EnrollmentPlanedescServices.SyncBatchInfo();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
///获取批次(院校详情中调用)
|
||||
|
|
|
|||
|
|
@ -1075,6 +1075,12 @@
|
|||
<param name="query"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.Front.VolunteerController.SyncBatchInfo">
|
||||
<summary>
|
||||
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:New_College.Api.Controllers.Front.VolunteerController.GetUniversityPlanBatch(New_College.Model.ViewModels.YearAreaQuery)">
|
||||
<summary>
|
||||
获取批次(院校详情中调用)
|
||||
|
|
|
|||
|
|
@ -140,6 +140,8 @@ namespace New_College.IServices
|
|||
/// <returns></returns>
|
||||
Task<MessageModel<List<IdNameResult>>> GetUniversityPlanBatch(YearAreaQuery query);
|
||||
|
||||
Task SyncBatchInfo();
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -40,16 +40,18 @@ public class Batchobject
|
|||
public BatchData data { get; set; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class BatchData
|
||||
{
|
||||
public Configlist configList { get; set; }
|
||||
public List<ListItem> list { get; set; }
|
||||
public List[] list { get; set; }
|
||||
}
|
||||
|
||||
public class Configlist
|
||||
{
|
||||
public string proDefault { get; set; }
|
||||
public int yearDefault { get; set; }
|
||||
public string yearDefault { get; set; }
|
||||
public int subjectDefault { get; set; }
|
||||
public Prolist[] proList { get; set; }
|
||||
public Yearlist[] yearList { get; set; }
|
||||
|
|
@ -88,7 +90,7 @@ public class Batchlist
|
|||
public string batch_name { get; set; }
|
||||
}
|
||||
|
||||
public class ListItem
|
||||
public class List
|
||||
{
|
||||
public int year { get; set; }
|
||||
public int province_code { get; set; }
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ namespace New_College.Model.ViewModels
|
|||
public string AreaName { get; set; }
|
||||
|
||||
|
||||
public string ProvinceCode { get; set; }
|
||||
public int ProvinceCode { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using New_College.IRepository.Base;
|
||||
using New_College.Model.Models;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.IRepository
|
||||
{
|
||||
|
|
@ -8,5 +10,6 @@ namespace New_College.IRepository
|
|||
/// </summary>
|
||||
public interface IT_EnrollmentBatchRepository : IBaseRepository<T_EnrollmentBatch>
|
||||
{
|
||||
Task<int> BatchAdd(List<T_EnrollmentBatch> t_EnrollmentBatches);
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,8 @@
|
|||
using New_College.IRepository.UnitOfWork;
|
||||
using New_College.Model.Models;
|
||||
using New_College.Repository.Base;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace New_College.Repository
|
||||
{
|
||||
|
|
@ -13,5 +15,12 @@ namespace New_College.Repository
|
|||
public T_EnrollmentBatchRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
||||
{
|
||||
}
|
||||
|
||||
public async Task<int> BatchAdd(List<T_EnrollmentBatch> t_EnrollmentBatches)
|
||||
{
|
||||
return await this.Db.Fastest<T_EnrollmentBatch>().BulkCopyAsync(t_EnrollmentBatches);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ namespace New_College.Services
|
|||
private readonly ID_ScoreLineRepository _ScoreLineRepository;
|
||||
private readonly IT_BatchlineRepository t_BatchlineRepository;
|
||||
private readonly IT_TbSNeedDataInfoRepository t_TbSNeedDataInfoRepository;
|
||||
private readonly ISysRegionRepository t_SysRegionRepository;
|
||||
public T_EnrollmentPlanedescServices(IBaseRepository<T_EnrollmentPlanedesc> dal
|
||||
, ID_UniversityRepository ID_UniversityRepository
|
||||
, IT_EnrollmentBatchRepository IT_EnrollmentBatchRepository
|
||||
|
|
@ -64,7 +65,7 @@ namespace New_College.Services
|
|||
, IT_GearInfoRepository IT_GearInfoRepository, IT_EnrollmentPlanedescRepository t_EnrollmentPlanedescServices,
|
||||
IV_CustomerInfoRepository v_CustomerInfoRepository, ID_PlanMajorDescRepository planMajorDescRepository,
|
||||
ID_PlanMajorScoreLineRepository planMajorScoreLineRepository, ID_QualificationLineRepository qualificationLineRepository, ID_ScoreLineRepository scoreLineRepository,
|
||||
IT_BatchlineRepository batchlineRepository, IT_TbSNeedDataInfoRepository tbSNeedDataInfoRepository)
|
||||
IT_BatchlineRepository batchlineRepository, IT_TbSNeedDataInfoRepository tbSNeedDataInfoRepository, ISysRegionRepository sysRegionRepository)
|
||||
{
|
||||
this._dal = dal;
|
||||
d_UniversityRepository = ID_UniversityRepository;
|
||||
|
|
@ -89,6 +90,7 @@ namespace New_College.Services
|
|||
_ScoreLineRepository = scoreLineRepository;
|
||||
t_BatchlineRepository = batchlineRepository;
|
||||
t_TbSNeedDataInfoRepository = tbSNeedDataInfoRepository;
|
||||
t_SysRegionRepository = sysRegionRepository;
|
||||
}
|
||||
|
||||
public List<string> permut = new List<string>();
|
||||
|
|
@ -105,6 +107,61 @@ namespace New_College.Services
|
|||
|
||||
}
|
||||
|
||||
|
||||
public async Task SyncBatchInfo()
|
||||
{
|
||||
var provineInfo = await this.t_SysRegionRepository.Query(e => e.Level == 1 && !e.RegionCode.Contains("-"));
|
||||
string baseUrl = "https://static-data.ycymedu.com/batchitems/";
|
||||
using var httpClient = new System.Net.Http.HttpClient();
|
||||
var list = new List<T_EnrollmentBatch>();
|
||||
provineInfo.ForEach(p =>
|
||||
{
|
||||
var years = new List<string>() { "2024", "2023", "2022" };
|
||||
years.ForEach(y =>
|
||||
{
|
||||
string url = $"{baseUrl}{p.RegionCode}_{y}.json";
|
||||
|
||||
var response = httpClient.GetAsync(url).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var jsons = response.Content.ReadAsStringAsync().Result;
|
||||
var jsonData = System.Text.Json.JsonSerializer.Deserialize<Batchobject>(response.Content.ReadAsStringAsync().Result);
|
||||
if (jsonData?.code == 1)
|
||||
{
|
||||
var items = jsonData.data.list.Select(s => new T_EnrollmentBatch()
|
||||
{
|
||||
Id = s.subject_id,
|
||||
Batch_name = s.batch_name,
|
||||
Year = s.year,
|
||||
Type = s.subject_name,
|
||||
ScoreLine = s.score,
|
||||
AreaId = int.Parse(p.RegionCode),
|
||||
AreaName = p.RegionName,
|
||||
CreateTime = DateTime.Now,
|
||||
IsDelete = false,
|
||||
OrderSort = 0,
|
||||
Subjectlevel = 0,
|
||||
ModifyTime = DateTime.Now,
|
||||
}).ToList();
|
||||
list.AddRange(items);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
list.ForEach(async c =>
|
||||
{
|
||||
|
||||
await this.t_EnrollmentBatchRepository.Add(c);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 霍兰德推荐学校专业
|
||||
/// </summary>
|
||||
|
|
@ -1609,63 +1666,63 @@ namespace New_College.Services
|
|||
/// <returns></returns>
|
||||
public async Task<MessageModel<List<IdNameResult>>> GetBatchByYearArea(YearAreaQuery query)
|
||||
{
|
||||
//query.Year = query.Year.HasValue && query.Year >= 2024 ? 2024 : query.Year;//获取批次信息新数据出来2023后需更新成2024
|
||||
//Expression<Func<T_EnrollmentBatch, bool>> expression = Expressionable.Create<T_EnrollmentBatch>()
|
||||
// .And(c => c.IsDelete == false)
|
||||
// .And(c => !c.Batch_name.Contains("提前"))
|
||||
// .And(c => !c.Batch_name.Contains("零志愿"))
|
||||
// .And(c => c.AreaName == query.AreaName)
|
||||
// .AndIF(query.Year.HasValue, c => c.Year == query.Year)
|
||||
// .ToExpression();
|
||||
//var info = await t_EnrollmentBatchRepository.Query(expression);
|
||||
//if (info.Count <= 0)
|
||||
// return new MessageModel<List<IdNameResult>>() { success = false, msg = "数据为空" };
|
||||
//List<IdNameResult> list = new List<IdNameResult>() { };
|
||||
//foreach (var item in info.OrderByDescending(c => c.Year).ToList())
|
||||
//{
|
||||
// if (item.Type != "不分文理")
|
||||
// {
|
||||
// list.Add(new IdNameResult()
|
||||
// {
|
||||
// Id = item.Id,
|
||||
// Name = item.Batch_name,
|
||||
// TypeName = item.Type,
|
||||
// Year = item.Year,
|
||||
// Score = item.ScoreLine
|
||||
// });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// list.Add(new IdNameResult()
|
||||
// {
|
||||
// Id = item.Id,
|
||||
// Name = item.Batch_name,
|
||||
// Year = item.Year,
|
||||
// Score = item.ScoreLine
|
||||
// });
|
||||
// }
|
||||
//}
|
||||
query.Year = query.Year.HasValue && query.Year >= 2024 ? 2024 : query.Year;//获取批次信息新数据出来2023后需更新成2024
|
||||
Expression<Func<T_EnrollmentBatch, bool>> expression = Expressionable.Create<T_EnrollmentBatch>()
|
||||
.And(c => c.IsDelete == false)
|
||||
.And(c => !c.Batch_name.Contains("提前"))
|
||||
.And(c => !c.Batch_name.Contains("零志愿"))
|
||||
.And(c => c.AreaId == query.ProvinceCode)
|
||||
.AndIF(query.Year.HasValue, c => c.Year == query.Year)
|
||||
.ToExpression();
|
||||
var info = await t_EnrollmentBatchRepository.Query(expression);
|
||||
if (info.Count <= 0)
|
||||
return new MessageModel<List<IdNameResult>>() { success = false, msg = "数据为空" };
|
||||
List<IdNameResult> list = new List<IdNameResult>() { };
|
||||
foreach (var item in info.OrderByDescending(c => c.Year).ToList())
|
||||
{
|
||||
if (item.Type != "不分文理")
|
||||
{
|
||||
list.Add(new IdNameResult()
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Batch_name,
|
||||
TypeName = item.Type,
|
||||
Year = item.Year,
|
||||
Score = item.ScoreLine
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
list.Add(new IdNameResult()
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Batch_name,
|
||||
Year = item.Year,
|
||||
Score = item.ScoreLine
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
var baseurl = "https://static-data.ycymedu.com/batchitems/";
|
||||
var list = new List<IdNameResult>();
|
||||
using var httpClient = new System.Net.Http.HttpClient();
|
||||
string url = $"{baseurl}{query.ProvinceCode}.json";
|
||||
var response = httpClient.GetAsync(url).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var jsonData = System.Text.Json.JsonSerializer.Deserialize<Batchobject>(response.Content.ReadAsStringAsync().Result);
|
||||
if (jsonData?.code == 1)
|
||||
{
|
||||
list = jsonData.data.list.Select(s => new IdNameResult()
|
||||
{
|
||||
Id = s.subject_id,
|
||||
Name = s.batch_name,
|
||||
Year = s.year,
|
||||
TypeName = s.subject_name,
|
||||
Score = s.score
|
||||
}).ToList();
|
||||
}
|
||||
}
|
||||
//var baseurl = "https://static-data.ycymedu.com/batchitems/";
|
||||
//var list = new List<IdNameResult>();
|
||||
//using var httpClient = new System.Net.Http.HttpClient();
|
||||
//string url = $"{baseurl}{query.ProvinceCode}.json";
|
||||
//var response = httpClient.GetAsync(url).Result;
|
||||
//if (response.IsSuccessStatusCode)
|
||||
//{
|
||||
// var jsonData = System.Text.Json.JsonSerializer.Deserialize<Batchobject>(response.Content.ReadAsStringAsync().Result);
|
||||
// if (jsonData?.code == 1)
|
||||
// {
|
||||
// list = jsonData.data.list.Select(s => new IdNameResult()
|
||||
// {
|
||||
// Id = s.subject_id,
|
||||
// Name = s.batch_name,
|
||||
// Year = s.year,
|
||||
// TypeName = s.subject_name,
|
||||
// Score = s.score
|
||||
// }).ToList();
|
||||
// }
|
||||
//}
|
||||
return new MessageModel<List<IdNameResult>>()
|
||||
{
|
||||
success = true,
|
||||
|
|
|
|||
|
|
@ -41,7 +41,11 @@ namespace New_College.Tasks
|
|||
var provineInfo = await this.sysRegionServices.Query(e => e.Level == 1 && !e.RegionCode.Contains("-"));
|
||||
provineInfo.ForEach(p =>
|
||||
{
|
||||
// batchListAgHelper.HtmlCreatePageData(p.RegionCode);
|
||||
//var years = new List<string>() { "2024", "2023", "2022" };
|
||||
//years.ForEach(y =>
|
||||
//{
|
||||
// batchListAgHelper.HtmlCreatePageData(p.RegionCode, y);
|
||||
//});
|
||||
try
|
||||
{
|
||||
var list = anghelper.HtmlCreatePageData(p.RegionCode);
|
||||
|
|
|
|||
|
|
@ -21,19 +21,19 @@ namespace New_College.Tasks
|
|||
// 初始化 OSS 客户端
|
||||
private OssClient ossClient = new OssClient("https://oss-cn-shanghai.aliyuncs.com", "LTAI5tKs3TXSbt7E4WMDcxwR", "EvC8MjRaQC1kHubgU4MtecZnofOb0v");
|
||||
public string baseUrl = "http://api.xuexingaokao.com/api/tool/batch/index?pro=";
|
||||
public void HtmlCreatePageData(string provinceCode)
|
||||
public void HtmlCreatePageData(string provinceCode,string year)
|
||||
{
|
||||
using var httpClient = new HttpClient();
|
||||
Thread.Sleep(100);
|
||||
// 动态构建 API URL
|
||||
var gourl = $"{baseUrl}{provinceCode}&year=&subject=&batch=×tamp={DateTimeOffset.Now.ToUnixTimeSeconds()}";
|
||||
var gourl = $"{baseUrl}{provinceCode}&year={year}&subject=&batch=×tamp={DateTimeOffset.Now.ToUnixTimeSeconds()}";
|
||||
Console.WriteLine($"gourl {gourl}...");
|
||||
var response = httpClient.GetAsync(gourl).Result;
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var jsonData = response.Content.ReadAsStringAsync().Result;
|
||||
// 构建文件名和路径
|
||||
string objectName = $"{filePrefix}{provinceCode}.json";
|
||||
string objectName = $"{filePrefix}{provinceCode}_{year}.json";
|
||||
// 上传到 OSS(同步上传)
|
||||
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonData));
|
||||
ossClient.PutObject(bucketName, objectName, stream);
|
||||
|
|
|
|||
Loading…
Reference in New Issue