培训需求统计

master
xiaochanghai 9 months ago
parent fb882bb71a
commit b82e3039b6
  1. 578
      Model/Tiobon.Web.pdm
  2. 12
      Tiobon.Core.Api/Controllers/Ghre/Ghre_RequestController.cs
  3. 5
      Tiobon.Core.IServices/Ghre/IGhre_RequestServices.cs
  4. 3
      Tiobon.Core.Model/View/Ghre/Ghre_Request.Dto.View.cs
  5. 136
      Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs
  6. 3
      Tiobon.Core.Services/Ghre/Ghre_StudyRecordServices.cs

File diff suppressed because it is too large Load Diff

@ -1,4 +1,6 @@
namespace Tiobon.Core.Api.Controllers; using Consul.Filtering;
namespace Tiobon.Core.Api.Controllers;
/// <summary> /// <summary>
/// 培训需求(Controller) /// 培训需求(Controller)
@ -44,4 +46,12 @@ public class Ghre_RequestController : BaseController<IGhre_RequestServices, Ghre
return await _service.InsertByStatus(insertModel, status); return await _service.InsertByStatus(insertModel, status);
} }
#endregion #endregion
#region 新增
[HttpPost("QueryGroup/{type}")]
public async Task<ServicePageResult<Ghre_RequestDto>> QueryGroup([FromBody] QueryBody filter, string type)
{
return await _service.QueryGroup(filter, type);
}
#endregion
} }

@ -1,4 +1,5 @@
using Tiobon.Core.IServices.BASE; using Tiobon.Core.Common;
using Tiobon.Core.IServices.BASE;
using Tiobon.Core.Model; using Tiobon.Core.Model;
using Tiobon.Core.Model.Models; using Tiobon.Core.Model.Models;
@ -12,4 +13,6 @@ public interface IGhre_RequestServices : IBaseServices<Ghre_Request, Ghre_Reques
Task<ServiceResult> UpdateStatus(InsertGhre_RequestInput input, string status); Task<ServiceResult> UpdateStatus(InsertGhre_RequestInput input, string status);
Task<ServiceResult<long>> InsertByStatus(InsertGhre_RequestInput insertModel, string status); Task<ServiceResult<long>> InsertByStatus(InsertGhre_RequestInput insertModel, string status);
Task<ServicePageResult<Ghre_RequestDto>> QueryGroup(QueryBody filter, string type);
} }

@ -52,7 +52,10 @@ public class Ghre_RequestDto : Ghre_Request
public string AgreeUserName { get; set; } public string AgreeUserName { get; set; }
public string RefuseUserName { get; set; } public string RefuseUserName { get; set; }
public string WorkStateLabel { get; set; } public string WorkStateLabel { get; set; }
public string YearMonthLabel { get; set; }
public string MonthLabel { get; set; }
} }

@ -10,6 +10,8 @@ using Tiobon.Core.Model;
using Tiobon.Core.Common.Helper; using Tiobon.Core.Common.Helper;
using Tiobon.Core.Common; using Tiobon.Core.Common;
using static Tiobon.Core.Model.Consts; using static Tiobon.Core.Model.Consts;
using Newtonsoft.Json.Linq;
using NPOI.Util.Collections;
namespace Tiobon.Core.Services; namespace Tiobon.Core.Services;
@ -190,4 +192,138 @@ public class Ghre_RequestServices : BaseServices<Ghre_Request, Ghre_RequestDto,
// return ServiceResult.OprateSuccess("停用成功!"); // 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);
}
} }

@ -1166,7 +1166,8 @@ WHERE A.Id = '{id}'";
TeacherEName = course.TeacherEName, TeacherEName = course.TeacherEName,
TeacherPhotoUrl = course.TeacherPhotoUrl, TeacherPhotoUrl = course.TeacherPhotoUrl,
DeptOrSchoolName = course.DeptOrSchoolName, DeptOrSchoolName = course.DeptOrSchoolName,
TeacherRemarkSz = course.TeacherRemarkSz TeacherRemarkSz = course.TeacherRemarkSz,
CourseName = course.CourseName
} }
]; ];

Loading…
Cancel
Save