diff --git a/New_College.Api/appsettings.json b/New_College.Api/appsettings.json index 1171ef7..bbbbe77 100644 --- a/New_College.Api/appsettings.json +++ b/New_College.Api/appsettings.json @@ -97,14 +97,14 @@ "DBType": 0, "Enabled": true, "HitRate": 20, - "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=volunteerapp; Uid=ycymedu; Pwd=Vs..127134;CharSet=utf8mb4" + "Connection": "Server=192.168.104.108; Port=3306;SslMode=None;Database=volunteerapp; Uid=root; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" }, { "ConnId": "MYSQL_CasDoor", "DBType": 0, "Enabled": true, "HitRate": 20, - "Connection": "Server=192.168.103.102; Port=3306;SslMode=None;Database=casdoor; Uid=ycymedu; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" + "Connection": "Server=192.168.104.108; Port=3306;SslMode=None;Database=casdoor; Uid=root; Pwd=Vs..127134;CharSet=utf8mb4;AllowLoadLocalInfile=true" }, { "ConnId": "WMBLOG_ORACLE", diff --git a/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs b/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs index 97603b0..64af931 100644 --- a/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs +++ b/New_College.Repository/BASE/T_EnrollmentPlanedescRepository.cs @@ -16,6 +16,7 @@ using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Numerics; +using System.Text; using System.Threading.Tasks; namespace New_College.Repository @@ -201,19 +202,64 @@ namespace New_College.Repository return new MessageModel>() { success = false, msg = "所选专业大类数据完善中..." }; majornames = majoraslist.Select(x => x.MajorName).ToList(); } - var recommendInfo = await this.Db.Queryable() - .WhereIF(regionlist.Any(), p => SqlFunc.ContainsArray(regionlist, p.Province)) - //.WhereIF(query.Year > 0, p => p.Years == query.Year) - .WhereIF(!string.IsNullOrEmpty(query.Location), p => p.Location == query.Location) - .Where(p => p.SubjectType == subjecttype) - //.WhereIF(!string.IsNullOrEmpty(query.BatchName), p => p.BatchName == query.BatchName) - .WhereIF(string.IsNullOrWhiteSpace(query.Type), p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score - 60, query.Score + 15)) - .WhereIF(query.Type == "冲", p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score, query.Score + 15)) - .WhereIF(query.Type == "稳", p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score - 26, query.Score - 1)) - .WhereIF(query.Type == "保", p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score - 60, query.Score - 26)) - .WhereIF(!string.IsNullOrWhiteSpace(query.SubjectClaim), c => SqlFunc.Contains(c._23subject, claim01) || SqlFunc.Contains(c._23subject, claim02) || SqlFunc.Contains(c._23subject, claim03) || c._23subject == "不限") - .WhereIF(majornames.Any() && majornames.Count() > 0, p => SqlFunc.ContainsArray(majornames, p.MajorName)) - .ToListAsync(); + StringBuilder sqlstr = new StringBuilder(); + sqlstr.AppendFormat("SELECT * from T_TbSNeedDataInfo where SubjectType='{0}' ", subjecttype); + + if (regionlist.Any()) + { + sqlstr.AppendFormat(" and Province in ('{0}')", string.Join("','", regionlist)); + } + //if (query.Year > 0) + //{ + // sqlstr.AppendFormat("and Years={0}", query.Year); + //} + if (!string.IsNullOrEmpty(query.Location)) + { + sqlstr.AppendFormat(" and Location='{0}'", query.Location); + } + if (string.IsNullOrEmpty(query.Type)) + { + sqlstr.AppendFormat(" and (_23Score BETWEEN {0} and {1})", query.Score - 60, query.Score + 15); + } + + if (query.Type == "冲") + { + sqlstr.AppendFormat(" and (_23Score BETWEEN {0} and {1})", query.Score, query.Score + 15); + } + if (query.Type == "稳") + { + sqlstr.AppendFormat(" and (_23Score BETWEEN {0} and {1})", query.Score - 26, query.Score - 1); + } + if (query.Type == "保") + { + sqlstr.AppendFormat(" and (_23Score BETWEEN {0} and {1})", query.Score - 60, query.Score - 26); + } + if (majornames.Any() && majornames.Count() > 0) + { + + sqlstr.AppendFormat(" and MajorName in ('{0}')", string.Join("','", majornames)); + } + if (!string.IsNullOrWhiteSpace(query.SubjectClaim)) + { + sqlstr.AppendFormat(" and (_23subject like'%{0}%' or _23subject like'%{1}%' or _23subject like'%{2}%' )", claim01, claim02, claim03); + } + sqlstr.Append(" order by _23Score"); + //string sql = string.Format("SELECT * from T_TbSNeedDataInfo where location='{0}' and _23Score BETWEEN {1} and {2} and (_23subject like'%{3}%' or _23subject like'%{4}%' or _23subject like'%{5}%' )" + // , query.Location, query.Score, query.Score + 15, claim01, claim02, claim03); + var recommendInfo = await this.Db.SqlQueryable(sqlstr.ToString()).ToListAsync(); + // var recommendInfo = await this.Db.Queryable() + // .WhereIF(regionlist.Any(), p => SqlFunc.ContainsArray(regionlist, p.Province)) + // //.WhereIF(query.Year > 0, p => p.Years == query.Year) + // .WhereIF(!string.IsNullOrEmpty(query.Location), p => p.Location == query.Location) + // .Where(p => p.SubjectType == subjecttype) + // //.WhereIF(!string.IsNullOrEmpty(query.BatchName), p => p.BatchName == query.BatchName) + // .WhereIF(string.IsNullOrWhiteSpace(query.Type), p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score - 60, query.Score + 15)) + // .WhereIF(query.Type == "冲", p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score, query.Score + 15)) + // .WhereIF(query.Type == "稳", p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score - 26, query.Score - 1)) + // .WhereIF(query.Type == "保", p => int.Parse(p._23Score) > 0 && SqlFunc.Between(int.Parse(p._23Score), query.Score - 60, query.Score - 26)) + // .WhereIF(!string.IsNullOrWhiteSpace(query.SubjectClaim), c => SqlFunc.Contains(c._23subject, claim01) || SqlFunc.Contains(c._23subject, claim02) || SqlFunc.Contains(c._23subject, claim03) || c._23subject == "不限") + // .WhereIF(majornames.Any() && majornames.Count() > 0, p => SqlFunc.ContainsArray(majornames, p.MajorName)) + //.ToListAsync(); var universitylist = recommendInfo.GroupBy(g => g.UniversityName).Select(c => new UniversityEnrollmentPlanResult() { UniversityName = c.Key }).ToList(); var universitytemps = (await d_University.Query(c => SqlFunc.ContainsArray(recommendInfo.Select(c => c.UniversityName).ToList(), c.Name))).Select(c => new @@ -289,7 +335,7 @@ namespace New_College.Repository .WhereIF(maxscore > 10, (plans, universitys) => plans.LowScore <= maxscore) .WhereIF(minscore > 0, (plans, universitys) => plans.LowScore > minscore) .WhereIF(query.Ranking > 0, (plans, universitys) => plans.LowScoreRank >= query.Ranking - 6) - // .Where(!string.IsNullOrWhiteSpace(query.SubjectClaim), (plans, universitys) => (plans.SubjectType.Contains(sbuOne) || plans.SelectSubject.Contains(sbuTwo) || plans.SelectSubject.Contains(sbuTree))) + // .Where(!string.IsNullOrWhiteSpace(query.SubjectClaim), (plans, universitys) => (plans.SubjectType.Contains(sbuOne) || plans.SelectSubject.Contains(sbuTwo) || plans.SelectSubject.Contains(sbuTree))) .OrderBy((plans, universitys) => plans.LowScoreRank, OrderByType.Asc) .Select((plans, universitys) => new UniversityResult() {