|
|
@@ -9,9 +9,6 @@ namespace YBEE.EQM.Application;
|
|
|
/// </summary>
|
|
|
public class NceeScoreService(IRepository<NceeScore> rep) : INceeScoreService, ITransient
|
|
|
{
|
|
|
- private readonly IRepository<NceeScore> _rep = rep;
|
|
|
- private readonly List<short> _chooseCourses = [5, 6, 7, 9];
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 上传成绩(仅原始分,适用于五区联考或本区独立赋分)
|
|
|
/// </summary>
|
|
|
@@ -92,10 +89,10 @@ public class NceeScoreService(IRepository<NceeScore> rep) : INceeScoreService, I
|
|
|
#endregion
|
|
|
|
|
|
#region 2.读取数据
|
|
|
- var plan = await _rep.Change<NceePlan>().DetachedEntities.FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001, "计划");
|
|
|
- var courseDict = (await _rep.Change<Course>().DetachedEntities.ToListAsync()).ToDictionary(t => t.Name);
|
|
|
+ var plan = await rep.Change<NceePlan>().DetachedEntities.FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001, "计划");
|
|
|
+ var courseDict = (await rep.Change<Course>().DetachedEntities.ToListAsync()).ToDictionary(t => t.Name);
|
|
|
//var orgs = await _rep.Change<SysOrg>().DetachedEntities.Where(t => t.EducationStage == EducationStage.SENIOR_HIGH_SCHOOL_STAGE).ToListAsync();
|
|
|
- var courseCombs = await _rep.Change<NceeCourseComb>().DetachedEntities.ToListAsync();
|
|
|
+ var courseCombs = await rep.Change<NceeCourseComb>().DetachedEntities.ToListAsync();
|
|
|
var courseCombDict = courseCombs.ToDictionary(t => t.Id, t => t);
|
|
|
|
|
|
// 获取需要导入的科目列表
|
|
|
@@ -205,7 +202,7 @@ public class NceeScoreService(IRepository<NceeScore> rep) : INceeScoreService, I
|
|
|
|
|
|
if (item.Score > 0)
|
|
|
{
|
|
|
- if (!_chooseCourses.Any(t => t == course.Id))
|
|
|
+ if (!NceeUtil.ChooseCourses.Any(t => t == course.Id))
|
|
|
{
|
|
|
item.ScoreX = item.Score;
|
|
|
}
|
|
|
@@ -225,7 +222,7 @@ public class NceeScoreService(IRepository<NceeScore> rep) : INceeScoreService, I
|
|
|
#region 3.处理学生
|
|
|
// 清理学生
|
|
|
string deleteStudentSql = $"DELETE FROM ncee_student WHERE ncee_plan_id = {nceePlanId};";
|
|
|
- await _rep.SqlNonQueryAsync(deleteStudentSql);
|
|
|
+ await rep.SqlNonQueryAsync(deleteStudentSql);
|
|
|
|
|
|
var uid = CurrentSysUserInfo.SysUserId;
|
|
|
if (uid == 0)
|
|
|
@@ -257,7 +254,7 @@ public class NceeScoreService(IRepository<NceeScore> rep) : INceeScoreService, I
|
|
|
INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, exam_number, `name`, direction_course_id, ncee_course_comb_id, score, score_x) VALUES
|
|
|
{string.Join(",", insertValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(insertSql);
|
|
|
+ await rep.SqlNonQueryAsync(insertSql);
|
|
|
insertValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
@@ -266,7 +263,7 @@ INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, e
|
|
|
#region 4.批量导入
|
|
|
// 清理成绩
|
|
|
string deleteScoreSql = $"DELETE FROM ncee_score WHERE ncee_plan_id = {nceePlanId};";
|
|
|
- await _rep.SqlNonQueryAsync(deleteScoreSql);
|
|
|
+ await rep.SqlNonQueryAsync(deleteScoreSql);
|
|
|
|
|
|
insertValues.Clear();
|
|
|
scount = scores.Count;
|
|
|
@@ -281,7 +278,7 @@ INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, e
|
|
|
INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, score, score_x) VALUES
|
|
|
{string.Join(",", insertValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(insertSql);
|
|
|
+ await rep.SqlNonQueryAsync(insertSql);
|
|
|
insertValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
@@ -377,12 +374,12 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, score, scor
|
|
|
#endregion
|
|
|
|
|
|
#region 2.读取数据
|
|
|
- var plan = await _rep.Change<NceePlan>().DetachedEntities.FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001, "计划");
|
|
|
- var courseDict = (await _rep.Change<Course>().DetachedEntities.ToListAsync()).ToDictionary(t => t.Name);
|
|
|
+ var plan = await rep.Change<NceePlan>().DetachedEntities.FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001, "计划");
|
|
|
+ var courseDict = (await rep.Change<Course>().DetachedEntities.ToListAsync()).ToDictionary(t => t.Name);
|
|
|
//var orgs = await _rep.Change<SysOrg>().DetachedEntities.Where(t => t.EducationStage == EducationStage.SENIOR_HIGH_SCHOOL_STAGE).ToListAsync();
|
|
|
- var courseCombs = await _rep.Change<NceeCourseComb>().DetachedEntities.ToListAsync();
|
|
|
+ var courseCombs = await rep.Change<NceeCourseComb>().DetachedEntities.ToListAsync();
|
|
|
var courseCombDict = courseCombs.ToDictionary(t => t.Id, t => t);
|
|
|
- var convertGrades = await _rep.Change<NceeConvertGrade>().DetachedEntities.ToListAsync();
|
|
|
+ var convertGrades = await rep.Change<NceeConvertGrade>().DetachedEntities.ToListAsync();
|
|
|
var convertGradeDict = convertGrades.ToDictionary(t => t.Name);
|
|
|
|
|
|
// 获取需要导入的科目列表
|
|
|
@@ -519,7 +516,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, score, scor
|
|
|
if (course.IsRawScore == true)
|
|
|
{
|
|
|
item.Score = score;
|
|
|
- if (!_chooseCourses.Any(t => t == course.Course.Id))
|
|
|
+ if (!NceeUtil.ChooseCourses.Any(t => t == course.Course.Id))
|
|
|
{
|
|
|
item.ScoreX = score;
|
|
|
}
|
|
|
@@ -555,7 +552,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, score, scor
|
|
|
#region 3.处理学生
|
|
|
// 清理学生
|
|
|
string deleteStudentSql = $"DELETE FROM ncee_student WHERE ncee_plan_id = {nceePlanId};";
|
|
|
- await _rep.SqlNonQueryAsync(deleteStudentSql);
|
|
|
+ await rep.SqlNonQueryAsync(deleteStudentSql);
|
|
|
|
|
|
var uid = CurrentSysUserInfo.SysUserId;
|
|
|
if (uid == 0)
|
|
|
@@ -587,7 +584,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, score, scor
|
|
|
INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, exam_number, `name`, direction_course_id, ncee_course_comb_id, score, score_x) VALUES
|
|
|
{string.Join(",", insertValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(insertSql);
|
|
|
+ await rep.SqlNonQueryAsync(insertSql);
|
|
|
insertValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
@@ -596,7 +593,7 @@ INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, e
|
|
|
#region 4.批量导入
|
|
|
// 清理成绩
|
|
|
string deleteScoreSql = $"DELETE FROM ncee_score WHERE ncee_plan_id = {nceePlanId};";
|
|
|
- await _rep.SqlNonQueryAsync(deleteScoreSql);
|
|
|
+ await rep.SqlNonQueryAsync(deleteScoreSql);
|
|
|
|
|
|
insertValues.Clear();
|
|
|
scount = scores.Count;
|
|
|
@@ -617,7 +614,7 @@ INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, e
|
|
|
INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_convert_grade_id, ncee_convert_grade_name, score, score_x) VALUES
|
|
|
{string.Join(",", insertValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(insertSql);
|
|
|
+ await rep.SqlNonQueryAsync(insertSql);
|
|
|
insertValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
@@ -705,8 +702,8 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_conver
|
|
|
#endregion
|
|
|
|
|
|
#region 2.读取数据
|
|
|
- var plan = await _rep.Change<NceePlan>().DetachedEntities.FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001, "计划");
|
|
|
- var courseDict = (await _rep.Change<Course>().DetachedEntities.ToListAsync()).ToDictionary(t => t.Name);
|
|
|
+ var plan = await rep.Change<NceePlan>().DetachedEntities.FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001, "计划");
|
|
|
+ var courseDict = (await rep.Change<Course>().DetachedEntities.ToListAsync()).ToDictionary(t => t.Name);
|
|
|
|
|
|
// 获取需要导入的科目列表
|
|
|
Dictionary<int, Course> courses = [];
|
|
|
@@ -819,7 +816,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_conver
|
|
|
#region 3.处理学生
|
|
|
// 清理学生
|
|
|
string deleteStudentSql = $"DELETE FROM ncee_student WHERE ncee_plan_id = {nceePlanId};";
|
|
|
- await _rep.SqlNonQueryAsync(deleteStudentSql);
|
|
|
+ await rep.SqlNonQueryAsync(deleteStudentSql);
|
|
|
|
|
|
var uid = CurrentSysUserInfo.SysUserId;
|
|
|
if (uid == 0)
|
|
|
@@ -840,7 +837,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_conver
|
|
|
INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, exam_number, `name`, direction_course_id, ncee_course_comb_id, score, score_x) VALUES
|
|
|
{string.Join(",", insertValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(insertSql);
|
|
|
+ await rep.SqlNonQueryAsync(insertSql);
|
|
|
insertValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
@@ -849,7 +846,7 @@ INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, e
|
|
|
#region 4.批量导入
|
|
|
// 清理成绩
|
|
|
string deleteScoreSql = $"DELETE FROM ncee_score WHERE ncee_plan_id = {nceePlanId};";
|
|
|
- await _rep.SqlNonQueryAsync(deleteScoreSql);
|
|
|
+ await rep.SqlNonQueryAsync(deleteScoreSql);
|
|
|
|
|
|
insertValues.Clear();
|
|
|
scount = scores.Count;
|
|
|
@@ -864,7 +861,7 @@ INSERT INTO ncee_student(id, ncee_plan_id, sys_org_id, grade_id, class_number, e
|
|
|
INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_convert_grade_id, ncee_convert_grade_name, score, score_x) VALUES
|
|
|
{string.Join(",", insertValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(insertSql);
|
|
|
+ await rep.SqlNonQueryAsync(insertSql);
|
|
|
insertValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
@@ -886,7 +883,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_conver
|
|
|
/// <returns></returns>
|
|
|
public async Task Execute(int nceePlanId)
|
|
|
{
|
|
|
- var nceePlan = await _rep.Change<NceePlan>().FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001);
|
|
|
+ var nceePlan = await rep.Change<NceePlan>().FirstOrDefaultAsync(t => t.Id == nceePlanId) ?? throw Oops.Oh(ErrorCode.E2001);
|
|
|
var nceePlanConfig = JSON.Deserialize<NceePlanConfig>(nceePlan.Config);
|
|
|
|
|
|
// 执行分数转换
|
|
|
@@ -909,7 +906,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_conver
|
|
|
/// <returns></returns>
|
|
|
private async Task ExecuteLine(int nceePlanId, NceePlanConfig config)
|
|
|
{
|
|
|
- var baseLines = await _rep.Change<NceeBaseLine>().Where(t => t.NceePlanId == nceePlanId).OrderBy(t => t.NceeLineLevel).ToListAsync();
|
|
|
+ var baseLines = await rep.Change<NceeBaseLine>().Where(t => t.NceePlanId == nceePlanId).OrderBy(t => t.NceeLineLevel).ToListAsync();
|
|
|
// 单科有效分
|
|
|
List<NceeCourseLineScore> courseLineScores = [];
|
|
|
|
|
|
@@ -920,7 +917,7 @@ INSERT INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, ncee_conver
|
|
|
foreach (var line in baseLines)
|
|
|
{
|
|
|
// 计算总有效分
|
|
|
- var lineScoreX = await _rep.SqlScalarAsync<decimal>(@$"
|
|
|
+ var lineScoreX = await rep.SqlScalarAsync<decimal>(@$"
|
|
|
SELECT MIN(score_x) AS score_x
|
|
|
FROM
|
|
|
(
|
|
|
@@ -932,7 +929,7 @@ WHERE T1.rn <= (SELECT COUNT(1) FROM ncee_student WHERE ncee_plan_id = @nceePlan
|
|
|
", new { NceePlanId = nceePlanId, line.DirectionCourseId, line.LineRate });
|
|
|
line.LineScoreX = lineScoreX;
|
|
|
}
|
|
|
- await _rep.Change<NceeBaseLine>().UpdateNowAsync(baseLines);
|
|
|
+ await rep.Change<NceeBaseLine>().UpdateNowAsync(baseLines);
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
@@ -945,8 +942,10 @@ WHERE T1.rn <= (SELECT COUNT(1) FROM ncee_student WHERE ncee_plan_id = @nceePlan
|
|
|
|
|
|
foreach (var line in baseLines)
|
|
|
{
|
|
|
- // 计算单科有效分
|
|
|
- var courseLineScoreX = await _rep.SqlQueryAsync<NceeCourseLineScoreCalcDto>($@"
|
|
|
+ if (!config.DirectionUnseleted)
|
|
|
+ {
|
|
|
+ // 计算单科有效分
|
|
|
+ var courseLineScoreX = await rep.SqlQueryAsync<NceeCourseLineScoreCalcDto>($@"
|
|
|
SELECT
|
|
|
MIN(T1.yuwen_score_x) AS yuwen_score_x, -- 语文
|
|
|
MIN(T1.shuxue_score_x) AS shuxue_score_x, -- 数学
|
|
|
@@ -1012,40 +1011,93 @@ FROM
|
|
|
WHERE T1.score_x >= @totalLineScoreX
|
|
|
", new { NceePlanId = nceePlanId, line.DirectionCourseId, TotalLineScoreX = line.LineScoreX });
|
|
|
|
|
|
- var cline = courseLineScoreX.FirstOrDefault();
|
|
|
- if (cline != null)
|
|
|
+ var cline = courseLineScoreX.FirstOrDefault();
|
|
|
+ if (cline != null)
|
|
|
+ {
|
|
|
+ courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = CourseConst.YU_WEN, LineScoreX = cline.YuwenScoreX });
|
|
|
+ courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = CourseConst.SHU_XUE, LineScoreX = cline.ShuxueScoreX });
|
|
|
+ courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = CourseConst.YING_YU, LineScoreX = cline.YingyuScoreX });
|
|
|
+ courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = line.DirectionCourseId, LineScoreX = cline.FangxiangScoreX });
|
|
|
+ courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = CourseConst.ZONG_HE, LineScoreX = cline.ZongheScoreX });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = 1, LineScoreX = cline.YuwenScoreX });
|
|
|
- courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = 2, LineScoreX = cline.ShuxueScoreX });
|
|
|
- courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = 3, LineScoreX = cline.YingyuScoreX });
|
|
|
- courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = line.DirectionCourseId, LineScoreX = cline.FangxiangScoreX });
|
|
|
- courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = 101, LineScoreX = cline.ZongheScoreX });
|
|
|
+ List<string> minFields = [];
|
|
|
+ List<string> scoreFields = [];
|
|
|
+ List<string> totalScore = [];
|
|
|
+ List<string> courseSelects = [];
|
|
|
+ for (short c = 1; c < 10; c++)
|
|
|
+ {
|
|
|
+ minFields.Add($"MIN(T1.score_{c}) AS score_{c}");
|
|
|
+ scoreFields.Add($"T{c}.score AS score_{c}");
|
|
|
+ totalScore.Add($"IFNULL(T{c}.score, 0)");
|
|
|
+ courseSelects.Add(@$"
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT ROW_NUMBER() OVER(ORDER BY T2.score DESC) AS rn, T2.score
|
|
|
+ FROM ncee_student AS T1
|
|
|
+ JOIN ncee_score AS T2 ON T1.id = T2.ncee_student_id
|
|
|
+ WHERE T1.ncee_plan_id = @nceePlanId AND T1.direction_course_id = @directionCourseId AND T2.course_id = {c}
|
|
|
+ ) AS T{c} ON T0.rn = T{c}.rn
|
|
|
+");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 计算单科有效分
|
|
|
+ var courseLineScoreX = await rep.SqlQueryAsync($@"
|
|
|
+SELECT
|
|
|
+ {string.Join(", ", minFields)}
|
|
|
+FROM
|
|
|
+(
|
|
|
+ SELECT
|
|
|
+ T0.rn,
|
|
|
+ {string.Join(", ", scoreFields)},
|
|
|
+ {string.Join(" + ", totalScore)} AS score
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT ROW_NUMBER() OVER(ORDER BY score DESC) AS rn
|
|
|
+ FROM ncee_student AS T1
|
|
|
+ WHERE T1.ncee_plan_id = @nceePlanId AND T1.direction_course_id = @directionCourseId
|
|
|
+ ) AS T0
|
|
|
+{string.Join("", courseSelects)}
|
|
|
+) AS T1
|
|
|
+WHERE T1.score >= @totalLineScoreX
|
|
|
+", new { NceePlanId = nceePlanId, line.DirectionCourseId, TotalLineScoreX = line.LineScoreX });
|
|
|
+
|
|
|
+ if (courseLineScoreX.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ var dr = courseLineScoreX.Rows[0];
|
|
|
+ for (short c = 1; c < 10; c++)
|
|
|
+ {
|
|
|
+ courseLineScores.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = c, LineScoreX = (decimal)dr[$"score_{c}"] });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- await _rep.Change<NceeCourseLineScore>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
+ await rep.Change<NceeCourseLineScore>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
List<NceeCourseLineScore> totalLines = [];
|
|
|
foreach (var line in baseLines)
|
|
|
{
|
|
|
totalLines.Add(new() { NceePlanId = nceePlanId, DirectionCourseId = line.DirectionCourseId, NceeLineLevel = line.NceeLineLevel, CourseId = 100, LineScoreX = line.LineScoreX });
|
|
|
}
|
|
|
- await _rep.Change<NceeCourseLineScore>().InsertNowAsync(totalLines);
|
|
|
- await _rep.Change<NceeCourseLineScore>().InsertNowAsync(courseLineScores);
|
|
|
+ await rep.Change<NceeCourseLineScore>().InsertNowAsync(totalLines);
|
|
|
+ await rep.Change<NceeCourseLineScore>().InsertNowAsync(courseLineScores);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- courseLineScores = await _rep.Change<NceeCourseLineScore>().Where(t => t.NceePlanId == nceePlanId).ToListAsync();
|
|
|
+ courseLineScores = await rep.Change<NceeCourseLineScore>().Where(t => t.NceePlanId == nceePlanId).ToListAsync();
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
#region 计算总分上线
|
|
|
// 清除数据
|
|
|
- await _rep.Change<NceeLineTotal>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
+ await rep.Change<NceeLineTotal>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
// 总分划线
|
|
|
foreach (var line in baseLines)
|
|
|
{
|
|
|
// 整体 - 方向
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_total(type, ncee_plan_id, ncee_line_level, direction_course_id, grade_id, line_count, total_count, line_rate)
|
|
|
SELECT {(short)NceeDataScopeType.TOTAL}, @nceePlanId, @nceeLineLevel, T1.*, T1.line_count / T1.total_count AS line_rate
|
|
|
FROM
|
|
|
@@ -1066,7 +1118,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX });
|
|
|
|
|
|
// 机构 - 方向
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_total(type, ncee_plan_id, ncee_line_level, direction_course_id, sys_org_id, grade_id, line_count, total_count, line_rate)
|
|
|
SELECT {(short)NceeDataScopeType.ORG}, @nceePlanId, @nceeLineLevel, T1.*, T1.line_count / T1.total_count AS line_rate
|
|
|
FROM
|
|
|
@@ -1091,7 +1143,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX });
|
|
|
|
|
|
// 机构 - 方向 - 组合
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_total(type, ncee_plan_id, ncee_line_level, direction_course_id, ncee_course_comb_id, sys_org_id, grade_id, line_count, total_count, line_rate)
|
|
|
SELECT {(short)NceeDataScopeType.COMB}, @nceePlanId, @nceeLineLevel, T1.*, T1.line_count / T1.total_count AS line_rate
|
|
|
FROM
|
|
|
@@ -1117,7 +1169,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX });
|
|
|
|
|
|
// 机构 - 班级 - 方向 - 组合
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_total(type, ncee_plan_id, ncee_line_level, direction_course_id, ncee_course_comb_id, sys_org_id, grade_id, class_number, line_count, total_count, line_rate)
|
|
|
SELECT {(short)NceeDataScopeType.CLASS}, @nceePlanId, @nceeLineLevel, T1.*, T1.line_count / T1.total_count AS line_rate
|
|
|
FROM
|
|
|
@@ -1149,7 +1201,7 @@ FROM
|
|
|
|
|
|
#region 计算科目有效分上线
|
|
|
// 清除数据
|
|
|
- await _rep.Change<NceeLineCourse>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
+ await rep.Change<NceeLineCourse>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
// 总分划线
|
|
|
foreach (var line in baseLines)
|
|
|
{
|
|
|
@@ -1157,13 +1209,13 @@ FROM
|
|
|
foreach (var courseLine in courseLines)
|
|
|
{
|
|
|
string inCourses = courseLine.CourseId.ToString();
|
|
|
- if (courseLine.CourseId == 101)
|
|
|
+ if (courseLine.CourseId == CourseConst.ZONG_HE)
|
|
|
{
|
|
|
inCourses = "5, 6, 7, 9";
|
|
|
}
|
|
|
|
|
|
// 单上线:整体 - 方向
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, grade_id, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.TOTAL}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 0
|
|
|
FROM
|
|
|
@@ -1196,7 +1248,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
// 双上线:整体 - 方向
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, grade_id, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.TOTAL}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 1
|
|
|
FROM
|
|
|
@@ -1228,9 +1280,8 @@ FROM
|
|
|
) AS T1
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
-
|
|
|
// 单上线:机构 - 方向
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, sys_org_id, grade_id, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.ORG}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 0
|
|
|
FROM
|
|
|
@@ -1267,7 +1318,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
// 双上线:机构 - 方向
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, sys_org_id, grade_id, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.ORG}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 1
|
|
|
FROM
|
|
|
@@ -1303,9 +1354,8 @@ FROM
|
|
|
) AS T1
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
-
|
|
|
// 单上线:机构 - 方向 - 组合
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, ncee_course_comb_id, sys_org_id, grade_id, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.COMB}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 0
|
|
|
FROM
|
|
|
@@ -1343,7 +1393,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
// 双上线:机构 - 方向 - 组合
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, ncee_course_comb_id, sys_org_id, grade_id, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.COMB}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 1
|
|
|
FROM
|
|
|
@@ -1380,9 +1430,8 @@ FROM
|
|
|
) AS T1
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
-
|
|
|
// 机构 - 班级 - 方向 - 组合
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, ncee_course_comb_id, sys_org_id, grade_id, class_number, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.CLASS}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 0
|
|
|
FROM
|
|
|
@@ -1421,7 +1470,7 @@ FROM
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
|
|
|
// 机构 - 班级 - 方向 - 组合
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
INSERT INTO ncee_line_course(type, ncee_plan_id, ncee_line_level, direction_course_id, course_id, ncee_course_comb_id, sys_org_id, grade_id, class_number, line_count, total_count, line_rate, is_double_line)
|
|
|
SELECT {(short)NceeDataScopeType.CLASS}, @nceePlanId, @nceeLineLevel, @directionCourseId, @courseId, T1.*, T1.line_count / T1.total_count AS line_rate, 1
|
|
|
FROM
|
|
|
@@ -1458,7 +1507,6 @@ FROM
|
|
|
GROUP BY T1.ncee_course_comb_id, T1.sys_org_id, T1.grade_id, T1.class_number
|
|
|
) AS T1
|
|
|
", new { NceePlanId = nceePlanId, line.NceeLineLevel, line.DirectionCourseId, line.LineScoreX, courseLine.CourseId, CourseLineScoreX = courseLine.LineScoreX });
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
@@ -1470,15 +1518,15 @@ FROM
|
|
|
/// <returns></returns>
|
|
|
private async Task ExecuteScoreConvert(int nceePlanId)
|
|
|
{
|
|
|
- await _rep.Change<NceeConvertRange>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
+ await rep.Change<NceeConvertRange>().Where(t => t.NceePlanId == nceePlanId).ExecuteDeleteAsync();
|
|
|
|
|
|
- var convertGrades = await _rep.Change<NceeConvertGrade>().DetachedEntities.OrderBy(t => t.Sequence).ToListAsync();
|
|
|
+ var convertGrades = await rep.Change<NceeConvertGrade>().DetachedEntities.OrderBy(t => t.Sequence).ToListAsync();
|
|
|
var convertGradeDict = convertGrades.ToDictionary(t => t.Id, t => t);
|
|
|
|
|
|
// 分科转换
|
|
|
- foreach (var courseId in _chooseCourses)
|
|
|
+ foreach (var courseId in NceeUtil.ChooseCourses)
|
|
|
{
|
|
|
- var scores = await _rep.DetachedEntities.Where(t => t.NceeStudent.NceePlanId == nceePlanId && t.CourseId == courseId && t.Score > 0).OrderByDescending(t => t.Score).ToListAsync();
|
|
|
+ var scores = await rep.DetachedEntities.Where(t => t.NceeStudent.NceePlanId == nceePlanId && t.CourseId == courseId && t.Score > 0).OrderByDescending(t => t.Score).ToListAsync();
|
|
|
if (scores.Count == 0)
|
|
|
{
|
|
|
continue;
|
|
|
@@ -1486,8 +1534,8 @@ FROM
|
|
|
var convertRanges = GetConvertRange(nceePlanId, courseId, convertGrades, scores);
|
|
|
|
|
|
// 更新转换区间
|
|
|
- await _rep.Change<NceeConvertRange>().Where(t => t.NceePlanId == nceePlanId && t.CourseId == courseId).ExecuteDeleteAsync();
|
|
|
- await _rep.Change<NceeConvertRange>().InsertNowAsync(convertRanges);
|
|
|
+ await rep.Change<NceeConvertRange>().Where(t => t.NceePlanId == nceePlanId && t.CourseId == courseId).ExecuteDeleteAsync();
|
|
|
+ await rep.Change<NceeConvertRange>().InsertNowAsync(convertRanges);
|
|
|
|
|
|
// 更新转换分
|
|
|
List<string> replaceValues = [];
|
|
|
@@ -1506,14 +1554,14 @@ FROM
|
|
|
REPLACE INTO ncee_score(id, ncee_plan_id, ncee_student_id, course_id, score, score_x, ncee_convert_grade_id, ncee_convert_grade_name) VALUES
|
|
|
{string.Join(",", replaceValues)}
|
|
|
";
|
|
|
- await _rep.SqlNonQueryAsync(replaceSql);
|
|
|
+ await rep.SqlNonQueryAsync(replaceSql);
|
|
|
replaceValues.Clear();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 更新总分
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
-- 更新总分
|
|
|
UPDATE ncee_student AS T1
|
|
|
JOIN
|
|
|
@@ -1534,7 +1582,7 @@ WHERE T1.ncee_plan_id = @nceePlanId
|
|
|
/// <returns></returns>
|
|
|
private async Task ExecuteUpdateOrder(int nceePlanId)
|
|
|
{
|
|
|
- await _rep.SqlNonQueryAsync($@"
|
|
|
+ await rep.SqlNonQueryAsync($@"
|
|
|
UPDATE ncee_student AS T1
|
|
|
JOIN
|
|
|
(
|
|
|
@@ -1620,6 +1668,14 @@ SET T1.order_in_total = T2.order_in_total,
|
|
|
// Y为原始分
|
|
|
// X为转换分
|
|
|
|
|
|
+ //// X = ((Y - Y1) * X2 + (Y2 - Y) * X1) / (Y2 - Y1)
|
|
|
+ //var y = score;
|
|
|
+ //var y1 = convertRange.MinScore;
|
|
|
+ //var y2 = convertRange.MaxScore;
|
|
|
+ //var x1 = convertGrade.MinScore;
|
|
|
+ //var x2 = convertGrade.MaxScore;
|
|
|
+ //var x = ((y - y1) * x2 + (y2 - y) * x1) / (y2 - y1);
|
|
|
+ //return x;
|
|
|
|
|
|
// a = Y2 - Y
|
|
|
var a = (convertRange.MaxScore - score);
|