fix
This commit is contained in:
parent
79237c4a7f
commit
a53f2b6a99
1 changed files with 56 additions and 38 deletions
|
|
@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using MySqlConnector;
|
using MySqlConnector;
|
||||||
|
using MySqlX.XDevAPI.Common;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using OfficeOpenXml;
|
using OfficeOpenXml;
|
||||||
|
|
@ -2235,6 +2236,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var year_ = int.Parse(year) - 543;
|
||||||
List<ExamInfo> header = new List<ExamInfo>();
|
List<ExamInfo> header = new List<ExamInfo>();
|
||||||
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
||||||
{
|
{
|
||||||
|
|
@ -2247,7 +2249,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
sb.Append(" Where score_year = @year");
|
sb.Append(" Where score_year = @year");
|
||||||
sb.Append(" ORDER BY Position_name ASC");
|
sb.Append(" ORDER BY Position_name ASC");
|
||||||
cmd.CommandText = sb.ToString();
|
cmd.CommandText = sb.ToString();
|
||||||
cmd.Parameters.Add(new MySqlParameter("@year", MySqlDbType.Int32) { Value = year });
|
cmd.Parameters.Add(new MySqlParameter("@year", MySqlDbType.Int32) { Value = year_ });
|
||||||
_context.Database.OpenConnection();
|
_context.Database.OpenConnection();
|
||||||
using (var reader = cmd.ExecuteReader())
|
using (var reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
|
@ -2268,24 +2270,32 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
var groupedResult = header
|
var groupedResult = header
|
||||||
.GroupBy(x => new
|
.GroupBy(x => new
|
||||||
{
|
{
|
||||||
x.PositionName,
|
x.PositionName,
|
||||||
x.Gender,
|
x.Gender,
|
||||||
x.Age,
|
x.Age,
|
||||||
x.Degree
|
x.Degree
|
||||||
})
|
})
|
||||||
.Select(group => new
|
.Select(group => new
|
||||||
{
|
{
|
||||||
Group = group.Key,
|
positionName = group.Key.PositionName,
|
||||||
Amount = group.Count()
|
gender = group.Key.Gender,
|
||||||
})
|
age = group.Key.Age,
|
||||||
.ToList();
|
degree = group.Key.Degree,
|
||||||
var resultMap = groupedResult.ToDictionary(
|
amount = group.Count()
|
||||||
x => string.Join("_", x.Group.PositionName, x.Group.Gender, x.Group.Age, x.Group.Degree),
|
})
|
||||||
x => x);
|
.ToList();
|
||||||
|
|
||||||
return Success(resultMap);
|
var result = new
|
||||||
|
{
|
||||||
|
template = "recruit-officer-pre",
|
||||||
|
reportName = "xlsx-report",
|
||||||
|
data = new { list = groupedResult }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
return Success(result);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
@ -2310,6 +2320,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
var year_ = int.Parse(year) - 543;
|
||||||
List<ExamInfo> header = new List<ExamInfo>();
|
List<ExamInfo> header = new List<ExamInfo>();
|
||||||
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
using (var cmd = _context.Database.GetDbConnection().CreateCommand())
|
||||||
{
|
{
|
||||||
|
|
@ -2323,7 +2334,7 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
sb.Append(" AND result = 'ผ่าน'");
|
sb.Append(" AND result = 'ผ่าน'");
|
||||||
sb.Append(" ORDER BY Position_name ASC");
|
sb.Append(" ORDER BY Position_name ASC");
|
||||||
cmd.CommandText = sb.ToString();
|
cmd.CommandText = sb.ToString();
|
||||||
cmd.Parameters.Add(new MySqlParameter("@year", MySqlDbType.Int32) { Value = year });
|
cmd.Parameters.Add(new MySqlParameter("@year", MySqlDbType.Int32) { Value = year_ });
|
||||||
_context.Database.OpenConnection();
|
_context.Database.OpenConnection();
|
||||||
using (var reader = cmd.ExecuteReader())
|
using (var reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
|
|
@ -2342,28 +2353,35 @@ namespace BMA.EHR.Recruit.Service.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
var groupedResult = header
|
var groupedResult = header
|
||||||
.GroupBy(x => new
|
.GroupBy(x => new
|
||||||
{
|
{
|
||||||
x.PositionName,
|
x.PositionName,
|
||||||
x.Gender,
|
x.Gender,
|
||||||
x.Age,
|
x.Age,
|
||||||
x.Degree,
|
x.Degree,
|
||||||
x.Result
|
x.Result
|
||||||
})
|
})
|
||||||
.Select(group => new
|
.Select(group => new
|
||||||
{
|
{
|
||||||
Group = group.Key,
|
positionName = group.Key.PositionName,
|
||||||
Amount = group.Count()
|
gender = group.Key.Gender,
|
||||||
})
|
age = group.Key.Age,
|
||||||
.ToList();
|
degree = group.Key.Degree,
|
||||||
var resultMap = groupedResult.ToDictionary(
|
result = group.Key.Result,
|
||||||
x => string.Join("_", x.Group.PositionName, x.Group.Gender, x.Group.Age, x.Group.Degree, x.Group.Result),
|
amount = group.Count()
|
||||||
x => x);
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var result = new
|
||||||
|
{
|
||||||
|
template = "recruit-officer-pass",
|
||||||
|
reportName = "xlsx-report",
|
||||||
|
data = new { list = groupedResult }
|
||||||
|
};
|
||||||
|
return Success(result);
|
||||||
|
|
||||||
return Success(resultMap);
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue