diff --git a/New_College.Api/Controllers/Back/D_PlanMajorDescController.cs b/New_College.Api/Controllers/Back/D_PlanMajorDescController.cs index 3b94117..bb2fe4f 100644 --- a/New_College.Api/Controllers/Back/D_PlanMajorDescController.cs +++ b/New_College.Api/Controllers/Back/D_PlanMajorDescController.cs @@ -9,6 +9,9 @@ using System.Threading.Tasks; using New_College.Model.ViewModels; using System.Linq; using Org.BouncyCastle.Asn1.Ocsp; +using New_College.IRepository.UnitOfWork; +using System.Collections.Generic; +using Newtonsoft.Json; namespace New_College.Api.Controllers { @@ -22,10 +25,18 @@ namespace New_College.Api.Controllers /// private readonly ID_PlanMajorDescServices _d_PlanMajorDescServices; private readonly ID_PlanMajorDescProServices _d_PlanMajorDescProServices; - public D_PlanMajorDescController(ID_PlanMajorDescServices D_PlanMajorDescServices, ID_PlanMajorDescProServices d_PlanMajorDescProServices) + private readonly IU_VolunteerTableServices _VolunteerTableServices; + private readonly IU_VolunteerTableDetailServices _VolunteerTableDetailServices; + private readonly IUnitOfWork _unitOfWork; + public D_PlanMajorDescController(ID_PlanMajorDescServices D_PlanMajorDescServices, ID_PlanMajorDescProServices d_PlanMajorDescProServices, + IU_VolunteerTableServices volunteerTableServices, IU_VolunteerTableDetailServices volunteerTableDetailServices, IUnitOfWork unitOfWork) { _d_PlanMajorDescServices = D_PlanMajorDescServices; _d_PlanMajorDescProServices = d_PlanMajorDescProServices; + _VolunteerTableServices = volunteerTableServices; + _VolunteerTableDetailServices = volunteerTableDetailServices; + _unitOfWork = unitOfWork; + } @@ -66,7 +77,7 @@ namespace New_College.Api.Controllers return new MessageModel() { response = query, - success = query != null&&query.itemViews!=null ? true : false, + success = query != null && query.itemViews != null ? true : false, msg = query != null && query.itemViews != null ? "获取成功" : "获取失败" }; } @@ -171,8 +182,122 @@ namespace New_College.Api.Controllers } + /// + /// 移动端 + /// + /// + /// + [HttpGet] + public async Task> MAIGo([FromQuery] OneSubmitGoRequest request) + { + request.Scoure = "m"; + var query = await OneSubmitGo(request); + if (!query.success) + { + return new MessageModel() + { + success = false, + response = -1, + msg = query.msg + }; + } + var vollunterrrequest = new VolunteerTableDtoView(); + vollunterrrequest.Type = "一键填报"; + vollunterrrequest.CustomerId = request.CustomerId; + vollunterrrequest.BatchName = request.BatchName; + vollunterrrequest.CreateTime = DateTime.Now; + vollunterrrequest.Score = request.Score; + vollunterrrequest.SubjectClaim = request.SubjectClaim; + var vollitem = new List(); + int sort = 0; + query.response.data.ForEach(c => + { + sort++; + vollitem.Add(new VolunteerTableDetailView() + { + UniversityCode = c.UniversityCode, + UniversityId = c.UniversityId, + UniversityName = c.UniversityName, + Sort = sort, + PlanMajorIds = c.PlanId.ToString(), + VolunteerRemark = JsonConvert.SerializeObject(new VolteerItem() + { + planId = c.PlanId, + tage = c.Percentage, + type = c.Type, + }) + }); + }); + vollunterrrequest.volunteerTableDetailViews = vollitem; + int ordersort = 0; + var vol = (await _VolunteerTableServices.Query(c => c.CustomerId == request.CustomerId)); + if (vol.Any()) + { + vollunterrrequest.VolunteerTableName = "我的志愿表" + (vol.OrderByDescending(c => c.CreateTime).FirstOrDefault().OrderSort + 1); + ordersort = (vol.OrderByDescending(c => c.CreateTime).FirstOrDefault().OrderSort + 1); + } + else + { + vollunterrrequest.VolunteerTableName = "我的志愿表01"; + ordersort = 1; + } + if (vollunterrrequest.volunteerTableDetailViews != null && vollunterrrequest.volunteerTableDetailViews.Any() && vollunterrrequest.volunteerTableDetailViews.Count() > 0) + { + _unitOfWork.BeginTran(); + var id = await _VolunteerTableServices.Add(new U_VolunteerTable() + { + CreateTime = DateTime.Now, + CustomerId = request.CustomerId, + ModifyTime = DateTime.Now, + OrderSort = ordersort, + IsDelete = false, + SubjectClaim = request.SubjectClaim, + Type = vollunterrrequest.Type, + Score = request.Score, + BatchName = request.BatchName, + VolunteerTableName = vollunterrrequest.VolunteerTableName, + }); - + int itemIds = 0; + if (id > 0) + { + var itemlist = vollunterrrequest.volunteerTableDetailViews.Select(c => new U_VolunteerTableDetail() + { + CreateTime = DateTime.Now, + IsDelete = false, + ModifyTime = DateTime.Now, + OrderSort = c.Sort, + PlanMajorIds = c.PlanMajorIds, + UniversityCode = c.UniversityCode, + UniversityId = c.UniversityId, + UniversityName = c.UniversityName, + VolunteerTableId = id, + VolunteerRemark = c.VolunteerRemark + }).ToList(); + itemIds = await _VolunteerTableDetailServices.Add(itemlist); + } + if (id > 0 && itemIds == vollunterrrequest.volunteerTableDetailViews.Count() && itemIds > 0) + { + _unitOfWork.BeginTran(); + } + else + { + _unitOfWork.RollbackTran(); + } + return new MessageModel() + { + success = id > 0, + response = id, + msg = "ok" + }; + } + return new MessageModel() + { + success = false, + response = -1, + msg = "无数据" + }; + } /// /// AI智能填报 /// diff --git a/New_College.Api/Controllers/Front/PcVolunteerController.cs b/New_College.Api/Controllers/Front/PcVolunteerController.cs index ae42f81..05b9c2a 100644 --- a/New_College.Api/Controllers/Front/PcVolunteerController.cs +++ b/New_College.Api/Controllers/Front/PcVolunteerController.cs @@ -95,7 +95,7 @@ namespace New_College.Api.Controllers.Front /// 志愿表Id /// [HttpGet("Get")] - public async Task> Get(int id = 0) + public async Task> Get([FromQuery] int id = 0) { if (id <= 0) @@ -117,7 +117,7 @@ namespace New_College.Api.Controllers.Front var planmajordesc = await _planMajorDescServices.Query(c => SqlFunc.ContainsArray(PlanMajorIds, c.Id));// var location = planmajordesc.FirstOrDefault().Location; var majorlist = planmajordesc.Select(c => c.Major).ToList(); - var universityname = planmajordesc.Select(c => c.UniversityName).ToList(); + var universityname = planmajordesc.Select(c => c.UniversityName).Distinct().ToList(); var planmajorcomplist = await _planMajorDescServices.Query(c => c.Location == location && SqlFunc.ContainsArray(majorlist, c.Major) && SqlFunc.ContainsArray(universityname, c.UniversityName));// view.VolunteerTableName = query.VolunteerTableName; @@ -133,7 +133,11 @@ namespace New_College.Api.Controllers.Front items.ForEach(s => { var planids = s.PlanMajorIds.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(ss => int.Parse(ss)).ToList(); - var typeinfo = s.VolunteerRemark.FromJson>(); + var typeinfo = new List(); + if (!string.IsNullOrWhiteSpace(s.VolunteerRemark)) + { + typeinfo = s.VolunteerRemark.FromJson>(); + } var uitem = new VolunteerTableDetailItemsView() { // Sort = s.Sort, @@ -148,8 +152,8 @@ namespace New_College.Api.Controllers.Front PlanId = c.Id, Sort = s.OrderSort, SubjectClam = c.SelectSubject, - Percentage = typeinfo.Any() ? typeinfo.FirstOrDefault(d => d.planId == c.Id).tage : 0, - Type = typeinfo.Any() ? typeinfo.FirstOrDefault(d => d.planId == c.Id).type : 0, + Percentage = typeinfo.Any()&&typeinfo.Count()>0 ? typeinfo.FirstOrDefault(d => d.planId == c.Id).tage : 0, + Type = typeinfo.Any() && typeinfo.Count() > 0 ? typeinfo.FirstOrDefault(d => d.planId == c.Id).type : 0, PlanItems = planmajorcomplist.Where(ee => ee.UId == s.UniversityId && ee.Major == c.Major).Select(tt => new PlanItem() { Count = (tt.PlanCount == 0 ? "--" : tt.PlanCount.ToString()), diff --git a/New_College.Api/New_College.Model.xml b/New_College.Api/New_College.Model.xml index f0e0941..23337a6 100644 --- a/New_College.Api/New_College.Model.xml +++ b/New_College.Api/New_College.Model.xml @@ -4175,6 +4175,16 @@ 学校归属:教育部,上海市-湖北省 + + + 请求来源 + + + + + Web端不传 + + 冲稳保 类型:冲2,稳1,保0 diff --git a/New_College.Api/New_College.xml b/New_College.Api/New_College.xml index 70b9b04..dbbf8a1 100644 --- a/New_College.Api/New_College.xml +++ b/New_College.Api/New_College.xml @@ -134,6 +134,13 @@ + + + 移动端 + + + + AI智能填报 diff --git a/New_College.Api/appsettings.json b/New_College.Api/appsettings.json index 36395fc..d2f0672 100644 --- a/New_College.Api/appsettings.json +++ b/New_College.Api/appsettings.json @@ -97,7 +97,7 @@ "DBType": 0, "Enabled": true, "HitRate": 20, - "Connection": "Server=192.168.104.130; Port=3306;SslMode=None;Database=volunteerapp; Uid=app; Pwd=vaW-F7E_1eDRLVLgI8ri;CharSet=utf8mb4" + "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=volunteerapp; Uid=ycymedu; Pwd=Vs..127134;CharSet=utf8mb4" }, { "ConnId": "WMBLOG_ORACLE", diff --git a/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs b/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs index 84e8144..d5badd8 100644 --- a/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs +++ b/New_College.Model/ViewModels/Query/OneSubmitGoRequest.cs @@ -99,6 +99,16 @@ namespace New_College.Model.ViewModels public string Major { get; set; } + /// + /// 请求来源 + /// + public string Scoure { get; set; } + + /// + /// Web端不传 + /// + public int CustomerId { get; set; } + }