|
|
|
@ -10,6 +10,8 @@ using Tiobon.Core.Model; |
|
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
using NPOI.Util.Collections; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
@ -190,4 +192,138 @@ public class Ghre_RequestServices : BaseServices<Ghre_Request, Ghre_RequestDto, |
|
|
|
|
// return ServiceResult.OprateSuccess("停用成功!"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServicePageResult<Ghre_RequestDto>> QueryGroup(QueryBody filter, string type) |
|
|
|
|
{ |
|
|
|
|
if (string.IsNullOrWhiteSpace(filter.orderBy)) |
|
|
|
|
filter.orderBy = "DeptName ASC"; |
|
|
|
|
|
|
|
|
|
if (filter.pageSize == 0) |
|
|
|
|
filter.pageSize = 10000; |
|
|
|
|
string conditions = "WHERE 1=1 "; |
|
|
|
|
|
|
|
|
|
foreach (JProperty jProperty in filter.jsonParam.Properties()) |
|
|
|
|
{ |
|
|
|
|
var name = jProperty.Name; |
|
|
|
|
var value = jProperty.Value.ToString(); |
|
|
|
|
if (name == "page" || name == "pageSize") |
|
|
|
|
continue; |
|
|
|
|
if (name == "YearMonth") |
|
|
|
|
{ |
|
|
|
|
if (value != null) |
|
|
|
|
{ |
|
|
|
|
var jsonParam = JsonHelper.JsonToObj<JsonParam>(value); |
|
|
|
|
var ids1 = JsonHelper.JsonToObj<List<string>>(jsonParam.columnValue.ToString()); |
|
|
|
|
|
|
|
|
|
conditions += $" AND {name}>= '{ids1[0]}-01'"; |
|
|
|
|
conditions += $" AND {name}<= '{ids1[1]}-01'"; |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (name == "Year") |
|
|
|
|
{ |
|
|
|
|
if (value != null) |
|
|
|
|
{ |
|
|
|
|
var jsonParam = JsonHelper.JsonToObj<JsonParam>(value); |
|
|
|
|
var ids1 = JsonHelper.JsonToObj<List<string>>(jsonParam.columnValue.ToString()); |
|
|
|
|
|
|
|
|
|
conditions += $" AND {name}>= '{ids1[0]}'"; |
|
|
|
|
conditions += $" AND {name}<= '{ids1[1]}'"; |
|
|
|
|
} |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
if (!string.IsNullOrWhiteSpace(value)) |
|
|
|
|
conditions = DealConditions(conditions, name, value); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
string sql = @$"SELECT *
|
|
|
|
|
FROM (SELECT sum (RequestNum) RequestNum, |
|
|
|
|
sum (TotalBudget) TotalBudget, |
|
|
|
|
CourseName, |
|
|
|
|
YearMonth1 YearMonthLabel, |
|
|
|
|
DeptName, |
|
|
|
|
TrainClass, |
|
|
|
|
TrainLevel, |
|
|
|
|
InOrOut |
|
|
|
|
FROM (SELECT A.Id, |
|
|
|
|
A.CourseName, |
|
|
|
|
SUBSTRING (A.YearMonth, 1, 4) + '年' YearMonth1, |
|
|
|
|
-- CAST (A.YearMonth + '-01' AS DATE) YearMonthDate, |
|
|
|
|
CONVERT (INT, SUBSTRING (A.YearMonth, 1, 4)) Year, |
|
|
|
|
ISNULL (B.DeptName, D.DeptName) DeptName, |
|
|
|
|
ISNULL (B.DeptId, D.DeptId) DeptId, |
|
|
|
|
ISNULL (A.RequestNum, 1) RequestNum, |
|
|
|
|
A.TrainClass, |
|
|
|
|
A.CourseSource, |
|
|
|
|
A.RequestSource, |
|
|
|
|
TrainLevel, |
|
|
|
|
A.InOrOut, |
|
|
|
|
ISNULL (A.TotalBudget, 0) TotalBudget |
|
|
|
|
FROM Ghre_Request A |
|
|
|
|
LEFT JOIN Ghro_Dept B ON A.DeptId = B.DeptID |
|
|
|
|
LEFT JOIN Ghra_Staff C ON A.ApplicantId = C.StaffID |
|
|
|
|
LEFT JOIN Ghro_Dept D ON C.DeptID = D.DeptID |
|
|
|
|
WHERE A.IsEnable = 1) A {conditions} |
|
|
|
|
GROUP BY CourseName, |
|
|
|
|
YearMonth1, |
|
|
|
|
DeptName, |
|
|
|
|
TrainClass, |
|
|
|
|
TrainLevel, |
|
|
|
|
InOrOut) A |
|
|
|
|
ORDER BY {filter.orderBy}";
|
|
|
|
|
|
|
|
|
|
if (type == "Month") |
|
|
|
|
sql = @$"SELECT *
|
|
|
|
|
FROM (SELECT sum (RequestNum) RequestNum, |
|
|
|
|
sum (TotalBudget) TotalBudget, |
|
|
|
|
CourseName, |
|
|
|
|
YearMonth1 YearMonthLabel, |
|
|
|
|
DeptName, |
|
|
|
|
TrainClass, |
|
|
|
|
TrainLevel, |
|
|
|
|
InOrOut |
|
|
|
|
FROM (SELECT A.Id, |
|
|
|
|
A.CourseName, |
|
|
|
|
SUBSTRING (A.YearMonth, 1, 4) |
|
|
|
|
+ '年' |
|
|
|
|
+ SUBSTRING (A.YearMonth, 6, 2) |
|
|
|
|
+ '月' YearMonth1, |
|
|
|
|
CAST (A.YearMonth + '-01' AS DATE) YearMonth, |
|
|
|
|
ISNULL (B.DeptName, D.DeptName) DeptName, |
|
|
|
|
ISNULL (B.DeptId, D.DeptId) DeptId, |
|
|
|
|
ISNULL (A.RequestNum, 1) RequestNum, |
|
|
|
|
A.TrainClass, A.CourseSource, |
|
|
|
|
|
|
|
|
|
TrainLevel, |
|
|
|
|
A.RequestSource, |
|
|
|
|
A.InOrOut, |
|
|
|
|
ISNULL (A.TotalBudget, 0) TotalBudget |
|
|
|
|
FROM Ghre_Request A |
|
|
|
|
LEFT JOIN Ghro_Dept B ON A.DeptId = B.DeptID |
|
|
|
|
LEFT JOIN Ghra_Staff C ON A.ApplicantId = C.StaffID |
|
|
|
|
LEFT JOIN Ghro_Dept D ON C.DeptID = D.DeptID |
|
|
|
|
WHERE A.IsEnable = 1) A {conditions} |
|
|
|
|
GROUP BY CourseName, |
|
|
|
|
YearMonth1, |
|
|
|
|
DeptName, |
|
|
|
|
TrainClass, |
|
|
|
|
TrainLevel, |
|
|
|
|
InOrOut) A |
|
|
|
|
ORDER BY {filter.orderBy}";
|
|
|
|
|
var result = await Db.Ado.SqlQueryAsync<Ghre_RequestDto>(sql); |
|
|
|
|
|
|
|
|
|
result.ForEach(async x => |
|
|
|
|
{ |
|
|
|
|
x.TrainClassLabel = await GetParaLabel("TrainingRequestTrainClass", x.TrainClass); |
|
|
|
|
x.TrainLevelLabel = await GetParaLabel("TrainingRequestTrainLevel", x.TrainLevel); |
|
|
|
|
x.InOrOutLabel = await GetParaLabel("CourseInOrOut", x.InOrOut); |
|
|
|
|
x.TeacherClassLabel = await GetParaLabel("TrainingTeacherType", x.InOrOut); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
//return ServiceResult<List<>>.OprateSuccess("查询成功", result); |
|
|
|
|
return new ServicePageResult<Ghre_RequestDto>(filter.pageNum, result.Count, filter.pageSize, result); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |