feat:优化查询功能
parent
176bd353ef
commit
4ba9aebe0e
|
|
@ -97,14 +97,14 @@
|
||||||
"DBType": 0,
|
"DBType": 0,
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"HitRate": 20,
|
"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",
|
"ConnId": "MYSQL_CasDoor",
|
||||||
"DBType": 0,
|
"DBType": 0,
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"HitRate": 20,
|
"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",
|
"ConnId": "WMBLOG_ORACLE",
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace New_College.Repository
|
namespace New_College.Repository
|
||||||
|
|
@ -201,19 +202,64 @@ namespace New_College.Repository
|
||||||
return new MessageModel<PageModel<UniversityEnrollmentPlanResult>>() { success = false, msg = "所选专业大类数据完善中..." };
|
return new MessageModel<PageModel<UniversityEnrollmentPlanResult>>() { success = false, msg = "所选专业大类数据完善中..." };
|
||||||
majornames = majoraslist.Select(x => x.MajorName).ToList();
|
majornames = majoraslist.Select(x => x.MajorName).ToList();
|
||||||
}
|
}
|
||||||
var recommendInfo = await this.Db.Queryable<TbSNeedDataInfoViewDto>()
|
StringBuilder sqlstr = new StringBuilder();
|
||||||
.WhereIF(regionlist.Any(), p => SqlFunc.ContainsArray(regionlist, p.Province))
|
sqlstr.AppendFormat("SELECT * from T_TbSNeedDataInfo where SubjectType='{0}' ", subjecttype);
|
||||||
//.WhereIF(query.Year > 0, p => p.Years == query.Year)
|
|
||||||
.WhereIF(!string.IsNullOrEmpty(query.Location), p => p.Location == query.Location)
|
if (regionlist.Any())
|
||||||
.Where(p => p.SubjectType == subjecttype)
|
{
|
||||||
//.WhereIF(!string.IsNullOrEmpty(query.BatchName), p => p.BatchName == query.BatchName)
|
sqlstr.AppendFormat(" and Province in ('{0}')", string.Join("','", regionlist));
|
||||||
.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))
|
//if (query.Year > 0)
|
||||||
.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))
|
// sqlstr.AppendFormat("and Years={0}", query.Year);
|
||||||
.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))
|
if (!string.IsNullOrEmpty(query.Location))
|
||||||
.ToListAsync();
|
{
|
||||||
|
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<TbSNeedDataInfoViewDto>(sqlstr.ToString()).ToListAsync();
|
||||||
|
// var recommendInfo = await this.Db.Queryable<TbSNeedDataInfoViewDto>()
|
||||||
|
// .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 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
|
var universitytemps = (await d_University.Query(c => SqlFunc.ContainsArray(recommendInfo.Select(c => c.UniversityName).ToList(), c.Name))).Select(c => new
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue