From ed646d5cadae0024e02e42f85d353298da48c6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Tue, 9 Apr 2024 13:55:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AEbug=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/HealthCheckController.cs | 6 +- New_College.Api/start.sh | 1 + .../Helper/UniqueIdGenerator.cs | 39 ++++++ New_College.IServices/ID_LongIdMapServices.cs | 5 + .../Models/D_PlanMajorScoreLine.cs | 2 +- .../BASE/D_PlanMajorScoreLineRepository.cs | 14 ++- .../BASE/ID_PlanMajorScoreLineRepository.cs | 3 + New_College.Services/D_LongIdMapServices.cs | 117 +++++++++++++----- 8 files changed, 146 insertions(+), 41 deletions(-) create mode 100644 New_College.Common/Helper/UniqueIdGenerator.cs diff --git a/New_College.Api/Controllers/HealthCheckController.cs b/New_College.Api/Controllers/HealthCheckController.cs index 04f5ed9..dce7996 100644 --- a/New_College.Api/Controllers/HealthCheckController.cs +++ b/New_College.Api/Controllers/HealthCheckController.cs @@ -67,10 +67,10 @@ namespace New_College.Controllers // return t_EnrollmentPlane.categoryupdate(); - // return d_LongIdMapServices.UpdateUniveristyInf(); - // return d_LongIdMapServices.Import(); + //return d_LongIdMapServices.UpdateUniveristyInf(); + // await d_LongIdMapServices.UpdatePlanScoreLine(); - await v_CustomerInfoServices.CustomeBillExport(); + // await v_CustomerInfoServices.CustomeBillExport(); return true; } diff --git a/New_College.Api/start.sh b/New_College.Api/start.sh index c8a99a1..6429346 100644 --- a/New_College.Api/start.sh +++ b/New_College.Api/start.sh @@ -19,5 +19,6 @@ sleep 3 docker run \ -p 8082:8082 \ + --restart unless-stopped \ --name pcnewcollage-api \ -d pcnewcollage-api diff --git a/New_College.Common/Helper/UniqueIdGenerator.cs b/New_College.Common/Helper/UniqueIdGenerator.cs new file mode 100644 index 0000000..324581f --- /dev/null +++ b/New_College.Common/Helper/UniqueIdGenerator.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace New_College.Common +{ + public static class UniqueIdGenerator + { + + public static int GenerateUniqueIntId() + { + // 生成一个唯一的Guid + Guid guid = Guid.NewGuid(); + + // 将Guid转换为字节数组 + byte[] bytes = guid.ToByteArray(); + + // 确保最后的四字节是正数 + int timeHi = BitConverter.ToInt32(bytes, 4); + if (timeHi < 0) + { + timeHi += int.MaxValue; + } + + // 将字节数组的前八个字节转换为整数 + long id = BitConverter.ToInt64(bytes, 0); + + // 确保整数是正数 + if (id < 0) + { + id += long.MaxValue; + } + + return Math.Abs((int)id); + } + } +} diff --git a/New_College.IServices/ID_LongIdMapServices.cs b/New_College.IServices/ID_LongIdMapServices.cs index 6e34439..38670f0 100644 --- a/New_College.IServices/ID_LongIdMapServices.cs +++ b/New_College.IServices/ID_LongIdMapServices.cs @@ -13,6 +13,11 @@ namespace New_College.IServices /// public interface ID_LongIdMapServices : IBaseServices { + /// + /// 更显专业分数线 + /// + /// + Task UpdatePlanScoreLine(); Task UpdatePlanProInf(); Task Import(); diff --git a/New_College.Model/Models/D_PlanMajorScoreLine.cs b/New_College.Model/Models/D_PlanMajorScoreLine.cs index a1c3a53..9b16c2d 100644 --- a/New_College.Model/Models/D_PlanMajorScoreLine.cs +++ b/New_College.Model/Models/D_PlanMajorScoreLine.cs @@ -62,7 +62,7 @@ namespace New_College.Model.Models /// 专业 /// - [SugarColumn(IsNullable = true, Length = 500)] + [SugarColumn(IsNullable = true, Length = 600)] public string Major { get; set; } /// diff --git a/New_College.Repository/BASE/D_PlanMajorScoreLineRepository.cs b/New_College.Repository/BASE/D_PlanMajorScoreLineRepository.cs index 61b5aaa..619a12d 100644 --- a/New_College.Repository/BASE/D_PlanMajorScoreLineRepository.cs +++ b/New_College.Repository/BASE/D_PlanMajorScoreLineRepository.cs @@ -2,16 +2,24 @@ 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 { - /// - /// D_PlanMajorScoreLineRepository - /// + /// + /// D_PlanMajorScoreLineRepository + /// public class D_PlanMajorScoreLineRepository : BaseRepository, ID_PlanMajorScoreLineRepository { public D_PlanMajorScoreLineRepository(IUnitOfWork unitOfWork) : base(unitOfWork) { } + + public async Task BatchAdd(List majorScoreLines) + { + var kk = await this.Db.Fastest().PageSize(50000).BulkCopyAsync(majorScoreLines); + return kk > 0; + } } } \ No newline at end of file diff --git a/New_College.Repository/BASE/ID_PlanMajorScoreLineRepository.cs b/New_College.Repository/BASE/ID_PlanMajorScoreLineRepository.cs index 9777ccd..c02ccef 100644 --- a/New_College.Repository/BASE/ID_PlanMajorScoreLineRepository.cs +++ b/New_College.Repository/BASE/ID_PlanMajorScoreLineRepository.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 ID_PlanMajorScoreLineRepository : IBaseRepository { + Task BatchAdd(List majorScoreLines); } } \ No newline at end of file diff --git a/New_College.Services/D_LongIdMapServices.cs b/New_College.Services/D_LongIdMapServices.cs index b399cd6..6a67fb9 100644 --- a/New_College.Services/D_LongIdMapServices.cs +++ b/New_College.Services/D_LongIdMapServices.cs @@ -1847,44 +1847,44 @@ namespace New_College.Services //}); #region *******************院校信息更新****************** - for (var i = 1; i <= 147; i++) - { - var body = new HttpHelperPostRequest() { pageIndex = i }; - var info = HttpHelper.PostApi("http://192.168.104.104:3000/youzy.dms.basiclib.api.college.query", body); + //for (var i = 1; i <= 147; i++) + //{ + // var body = new HttpHelperPostRequest() { pageIndex = i }; + // var info = HttpHelper.PostApi("http://192.168.104.104:3000/youzy.dms.basiclib.api.college.query", body); - info.result.items.ToList().ForEach(async a => - { + // info.result.items.ToList().ForEach(async a => + // { - //http://192.168.104.104:3000/youzy.dms.basiclib.api.college.bycode.get?code=10017 //详情 - // var bodydetail = new httphelperdetailrequest() { code = a.code }; - var undetail = HttpHelper.GetApi("http://192.168.104.104:3000/", "youzy.dms.basiclib.api.college.bycode.get?code=" + a.code + "", ""); - Thread.Sleep(1000); - var universitymodel = await d_UniversityRepository.Query(c => c.Name == a.cnName); - if (universitymodel.Any() && undetail != null && undetail.result != null) - { - var updatemodel = universitymodel.FirstOrDefault(); - var category = undetail.result.categories.ToList(); - //if (category.Contains("医药")) - //{ - // updatemodel.Type = UniversityTypeRelsove.GetTypeName("医药"); + // //http://192.168.104.104:3000/youzy.dms.basiclib.api.college.bycode.get?code=10017 //详情 + // // var bodydetail = new httphelperdetailrequest() { code = a.code }; + // var undetail = HttpHelper.GetApi("http://192.168.104.104:3000/", "youzy.dms.basiclib.api.college.bycode.get?code=" + a.code + "", ""); + // Thread.Sleep(1000); + // var universitymodel = await d_UniversityRepository.Query(c => c.Name == a.cnName); + // if (universitymodel.Any() && undetail != null && undetail.result != null) + // { + // var updatemodel = universitymodel.FirstOrDefault(); + // var category = undetail.result.categories.ToList(); + // //if (category.Contains("医药")) + // //{ + // // updatemodel.Type = UniversityTypeRelsove.GetTypeName("医药"); - //updatemodel.Web = undetail.result.webSite; - //updatemodel.Address = undetail.result.address[0].address; - //updatemodel.Phone = string.Join(",",undetail.result.zhaoBanDH); - // updatemodel.AscriptionName = undetail.result.belong; - //updatemodel.UniversityCode = a.code; - //updatemodel.Rank = a.ranking; - //updatemodel.Build_Date = undetail.result.createdYear; - //updatemodel.Description = undetail.result.introduction; - updatemodel.Master_Count = undetail.result.pointsOfShuo.Any() ? undetail.result.pointsOfShuo[0].number : 0; - updatemodel.Doctorate_Count = undetail.result.pointsOfBo.Any() ? undetail.result.pointsOfBo[0].number : 0; - //updatemodel.Type = UniversityTypeRelsove.GetTypeName((undetail.result.categories.Any() ? undetail.result.categories[0] : "")); - await d_UniversityRepository.Update(updatemodel); - // } - } + // //updatemodel.Web = undetail.result.webSite; + // //updatemodel.Address = undetail.result.address[0].address; + // //updatemodel.Phone = string.Join(",",undetail.result.zhaoBanDH); + // // updatemodel.AscriptionName = undetail.result.belong; + // //updatemodel.UniversityCode = a.code; + // //updatemodel.Rank = a.ranking; + // //updatemodel.Build_Date = undetail.result.createdYear; + // //updatemodel.Description = undetail.result.introduction; + // updatemodel.Master_Count = undetail.result.pointsOfShuo.Any() ? undetail.result.pointsOfShuo[0].number : 0; + // updatemodel.Doctorate_Count = undetail.result.pointsOfBo.Any() ? undetail.result.pointsOfBo[0].number : 0; + // //updatemodel.Type = UniversityTypeRelsove.GetTypeName((undetail.result.categories.Any() ? undetail.result.categories[0] : "")); + // await d_UniversityRepository.Update(updatemodel); + // // } + // } - }); - } + // }); + //} @@ -1918,6 +1918,55 @@ namespace New_College.Services } + /// + /// 更新专业分数线 + /// + /// + public async Task UpdatePlanScoreLine() + { + var tbinfo = await t_TbSNeedDataInfoRepository.Query(e => e.Location == "山东省"); + var plist = await this.d_PlanMajorDescProRepository.Query(c => c.Location == "山东省" && c.Years == 2023 && c.IsDelete == false); + var list = new List(); + int i = 232818; + tbinfo.ForEach(a => + { + if (plist.Where(e => e.UniversityName == a.UniversityName && e.MajorCode == a.MajorCode).Any()) + { + i++; + var pdefault = plist.Where(e => e.UniversityName == a.UniversityName && e.MajorCode == a.MajorCode).FirstOrDefault(); + list.Add(new D_PlanMajorScoreLine() + { + Id = i, + AvgScore = a._23SchoolAvgScore, + BatchName = pdefault.BatchName, + CreateTime = DateTime.Now, + FirstType = a.FirstType, + IsDelete = true, + Location = a.Location, + LowScore = Convert.ToInt32(a._23Score), + LowScoreRank = Convert.ToInt32(a._23ScoreLine), + Major = a.MajorName, + MajorCode = a.MajorCode, + ModifyTime = DateTime.Now, + //HighScore = "0", + //MajorGroup = "", + PlanCount = pdefault.PlanCount, + RootType = pdefault.RootType, + SelectSubject = pdefault.SelectSubject, + SubjectType = "综合", + UId = pdefault.UId, + UniversityName = a.UniversityName, + Years = pdefault.Years, + Remark = pdefault.Remark + }); + } + }); + + //var count = list; + await d_PlanMajorScoreLineRepository.BatchAdd(list); + return true; + } + /// /// 更新学校基础信息