no message
This commit is contained in:
parent
9ce6c503c3
commit
c8cc885546
2 changed files with 37 additions and 46 deletions
|
|
@ -30,6 +30,7 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using OfficeOpenXml.Style;
|
using OfficeOpenXml.Style;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace BMA.EHR.Recruit.Service.Controllers
|
namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -1962,7 +1963,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
var p_Id = new MySqlParameter("@id", id);
|
var p_Id = new MySqlParameter("@id", id);
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// 1️⃣ ดึงรายละเอียดสอบ (exam_info)
|
// 1️. ดึงรายละเอียดสอบ (exam_info)
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
||||||
{
|
{
|
||||||
|
|
@ -2007,7 +2008,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
_context.Database.OpenConnection();
|
_context.Database.OpenConnection();
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// 2️⃣ ใช้ DbDataReader แทน DataTable → ประหยัด memory และเร็วขึ้น
|
// 2️. ใช้ DbDataReader แทน DataTable → ประหยัด memory และเร็วขึ้น
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
using (var reader = cmd.ExecuteReader())
|
using (var reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
|
@ -2047,12 +2048,40 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// 3️⃣ ดึงสรุปคะแนน (sum_exam_info)
|
// 3️. ดึงสรุปคะแนน
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
dynamic header = null;
|
dynamic header = null;
|
||||||
if (data.Count == 0)
|
if (data.Count > 0)
|
||||||
{
|
{
|
||||||
header = new
|
int _count = await _context.Recruits.Where(x => x.Id == id).CountAsync();
|
||||||
|
header = await _context.RecruitScores
|
||||||
|
.Include(x => x.ScoreImport)
|
||||||
|
.Where(x => x.ScoreImport.RecruitImportId == id)
|
||||||
|
.GroupBy(x => 1)
|
||||||
|
.Select(g => new
|
||||||
|
{
|
||||||
|
count = _count,
|
||||||
|
pass = g.Count(x => x.ExamStatus == "ผ่าน"),
|
||||||
|
notpass = g.Count(x => x.ExamStatus == "ไม่ผ่าน"),
|
||||||
|
missed_exam = g.Count(x => x.ExamStatus == "ขส."),
|
||||||
|
other = g.Count(x =>
|
||||||
|
string.IsNullOrEmpty(x.ExamStatus) ||
|
||||||
|
!new[] { "ผ่าน", "ไม่ผ่าน", "ขส." }.Contains(x.ExamStatus)
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.FirstOrDefaultAsync()
|
||||||
|
?? new // ใช้ null-coalescing กันกรณีไม่มีข้อมูล (แทน else เดิม)
|
||||||
|
{
|
||||||
|
count = 0,
|
||||||
|
pass = 0,
|
||||||
|
notpass = 0,
|
||||||
|
missed_exam = 0,
|
||||||
|
other = 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
header = new
|
||||||
{
|
{
|
||||||
count = 0,
|
count = 0,
|
||||||
pass = 0,
|
pass = 0,
|
||||||
|
|
@ -2061,50 +2090,10 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
other = 0
|
other = 0
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
|
||||||
{
|
|
||||||
cmd.CommandTimeout = 0;
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
cmd.Parameters.Clear();
|
|
||||||
sb.Append(" SELECT count, pass, notpass, missed_exam, other FROM sum_exam_info WHERE recruit_import_id = @id ");
|
|
||||||
cmd.Parameters.Add(p_Id);
|
|
||||||
cmd.CommandText = sb.ToString();
|
|
||||||
_context.Database.OpenConnection();
|
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader())
|
|
||||||
{
|
|
||||||
if (!reader.HasRows)
|
|
||||||
{
|
|
||||||
header = new
|
|
||||||
{
|
|
||||||
count = 0,
|
|
||||||
pass = 0,
|
|
||||||
notpass = 0,
|
|
||||||
missed_exam = 0,
|
|
||||||
other = 0
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
reader.Read();
|
|
||||||
header = new
|
|
||||||
{
|
|
||||||
count = reader["count"].ToString().ToInteger(),
|
|
||||||
pass = reader["pass"].ToString().ToInteger(),
|
|
||||||
notpass = reader["notpass"].ToString().ToInteger(),
|
|
||||||
missed_exam = reader["missed_exam"].ToString().ToInteger(),
|
|
||||||
other = reader["other"].ToString().ToInteger()
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
// 4️⃣ ดึง period
|
// 4️. ดึง period
|
||||||
// ---------------------------
|
// ---------------------------
|
||||||
var period = await _context.RecruitImports.AsQueryable()
|
var period = await _context.RecruitImports.AsQueryable()
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string ExamResult { get; set; }
|
public string ExamResult { get; set; }
|
||||||
|
|
||||||
|
public string? keyword { get; set; }
|
||||||
|
|
||||||
public int Page { get; set; } = 1;
|
public int Page { get; set; } = 1;
|
||||||
public int PageSize { get; set; } = 10;
|
public int PageSize { get; set; } = 10;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue