diff --git a/New_College.Api/Controllers/Front/VolunteerController.cs b/New_College.Api/Controllers/Front/VolunteerController.cs
index 5e830c4..3113045 100644
--- a/New_College.Api/Controllers/Front/VolunteerController.cs
+++ b/New_College.Api/Controllers/Front/VolunteerController.cs
@@ -17,7 +17,7 @@ namespace New_College.Api.Controllers.Front
{
private readonly IT_EnrollmentPlanedescServices t_EnrollmentPlanedescServices;
private readonly ID_MajorClassServices d_MajorClassServices;
-
+
public VolunteerController(IT_EnrollmentPlanedescServices IT_EnrollmentPlanedescServices, ID_MajorClassServices ID_MajorClassServices)
{
t_EnrollmentPlanedescServices = IT_EnrollmentPlanedescServices;
@@ -272,6 +272,17 @@ namespace New_College.Api.Controllers.Front
}
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ public async Task SyncBatchInfo()
+ {
+
+ // await t_EnrollmentPlanedescServices.SyncBatchInfo();
+ }
+
///
///获取批次(院校详情中调用)
@@ -286,7 +297,7 @@ namespace New_College.Api.Controllers.Front
-
+
}
}
diff --git a/New_College.Api/New_College.xml b/New_College.Api/New_College.xml
index f2fa607..6e9f6b2 100644
--- a/New_College.Api/New_College.xml
+++ b/New_College.Api/New_College.xml
@@ -1075,6 +1075,12 @@
+
+
+
+
+
+
获取批次(院校详情中调用)
diff --git a/New_College.IServices/IT_EnrollmentPlanedescServices.cs b/New_College.IServices/IT_EnrollmentPlanedescServices.cs
index 9a0de75..6ac0e64 100644
--- a/New_College.IServices/IT_EnrollmentPlanedescServices.cs
+++ b/New_College.IServices/IT_EnrollmentPlanedescServices.cs
@@ -140,6 +140,8 @@ namespace New_College.IServices
///
Task>> GetUniversityPlanBatch(YearAreaQuery query);
+ Task SyncBatchInfo();
+
diff --git a/New_College.Model/ViewModels/BaseResult.cs b/New_College.Model/ViewModels/BaseResult.cs
index 6f09768..bc53b49 100644
--- a/New_College.Model/ViewModels/BaseResult.cs
+++ b/New_College.Model/ViewModels/BaseResult.cs
@@ -40,16 +40,18 @@ public class Batchobject
public BatchData data { get; set; }
}
+
+
public class BatchData
{
public Configlist configList { get; set; }
- public List 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; }
diff --git a/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs b/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs
index 4de3edd..d2e1e3e 100644
--- a/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs
+++ b/New_College.Model/ViewModels/Query/SubjectSelectQuery.cs
@@ -100,7 +100,7 @@ namespace New_College.Model.ViewModels
public string AreaName { get; set; }
- public string ProvinceCode { get; set; }
+ public int ProvinceCode { get; set; }
}
}
diff --git a/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs b/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs
index defc301..be2fcb5 100644
--- a/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs
+++ b/New_College.Repository/BASE/IT_EnrollmentBatchRepository.cs
@@ -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
///
public interface IT_EnrollmentBatchRepository : IBaseRepository
{
+ Task BatchAdd(List t_EnrollmentBatches);
}
}
\ No newline at end of file
diff --git a/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs b/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs
index 305d1b2..1de7610 100644
--- a/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs
+++ b/New_College.Repository/BASE/T_EnrollmentBatchRepository.cs
@@ -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 BatchAdd(List t_EnrollmentBatches)
+ {
+ return await this.Db.Fastest().BulkCopyAsync(t_EnrollmentBatches);
+ }
+
+
}
}
\ No newline at end of file
diff --git a/New_College.Services/T_EnrollmentPlanedescServices.cs b/New_College.Services/T_EnrollmentPlanedescServices.cs
index b2fc6a3..5385433 100644
--- a/New_College.Services/T_EnrollmentPlanedescServices.cs
+++ b/New_College.Services/T_EnrollmentPlanedescServices.cs
@@ -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 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 permut = new List();
@@ -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();
+ provineInfo.ForEach(p =>
+ {
+ var years = new List() { "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(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);
+ });
+
+ }
+
+
+
///
/// 霍兰德推荐学校专业
///
@@ -1609,63 +1666,63 @@ namespace New_College.Services
///
public async Task>> GetBatchByYearArea(YearAreaQuery query)
{
- //query.Year = query.Year.HasValue && query.Year >= 2024 ? 2024 : query.Year;//获取批次信息新数据出来2023后需更新成2024
- //Expression> expression = Expressionable.Create()
- // .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>() { success = false, msg = "数据为空" };
- //List list = new List() { };
- //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();
- using var httpClient = new System.Net.Http.HttpClient();
- string url = $"{baseurl}{query.ProvinceCode}.json";
- var response = httpClient.GetAsync(url).Result;
- if (response.IsSuccessStatusCode)
+ query.Year = query.Year.HasValue && query.Year >= 2024 ? 2024 : query.Year;//获取批次信息新数据出来2023后需更新成2024
+ Expression> expression = Expressionable.Create()
+ .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>() { success = false, msg = "数据为空" };
+ List list = new List() { };
+ foreach (var item in info.OrderByDescending(c => c.Year).ToList())
{
- var jsonData = System.Text.Json.JsonSerializer.Deserialize(response.Content.ReadAsStringAsync().Result);
- if (jsonData?.code == 1)
+ if (item.Type != "不分文理")
{
- list = jsonData.data.list.Select(s => new IdNameResult()
+ list.Add(new IdNameResult()
{
- Id = s.subject_id,
- Name = s.batch_name,
- Year = s.year,
- TypeName = s.subject_name,
- Score = s.score
- }).ToList();
+ 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();
+ //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(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>()
{
success = true,
diff --git a/New_College.Tasks/HostedService/JobTimedSpiderService.cs b/New_College.Tasks/HostedService/JobTimedSpiderService.cs
index d2602eb..e835ec9 100644
--- a/New_College.Tasks/HostedService/JobTimedSpiderService.cs
+++ b/New_College.Tasks/HostedService/JobTimedSpiderService.cs
@@ -36,12 +36,16 @@ namespace New_College.Tasks
private async void DoWork(object state)
{
- // BatchListAgHelper batchListAgHelper = new BatchListAgHelper();
+ // BatchListAgHelper batchListAgHelper = new BatchListAgHelper();
NationWideNewsAgHelper anghelper = new NationWideNewsAgHelper();
var provineInfo = await this.sysRegionServices.Query(e => e.Level == 1 && !e.RegionCode.Contains("-"));
provineInfo.ForEach(p =>
{
- // batchListAgHelper.HtmlCreatePageData(p.RegionCode);
+ //var years = new List() { "2024", "2023", "2022" };
+ //years.ForEach(y =>
+ //{
+ // batchListAgHelper.HtmlCreatePageData(p.RegionCode, y);
+ //});
try
{
var list = anghelper.HtmlCreatePageData(p.RegionCode);
diff --git a/New_College.Tasks/HtmlAgSpider/BatchListAgHelper.cs b/New_College.Tasks/HtmlAgSpider/BatchListAgHelper.cs
index 7cde34c..6e2d1e0 100644
--- a/New_College.Tasks/HtmlAgSpider/BatchListAgHelper.cs
+++ b/New_College.Tasks/HtmlAgSpider/BatchListAgHelper.cs
@@ -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);