diff --git a/Tiobon.Core.Api/Controllers/Ghre/Ghre_PlanController.cs b/Tiobon.Core.Api/Controllers/Ghre/Ghre_PlanController.cs index fbb50196..4896d363 100644 --- a/Tiobon.Core.Api/Controllers/Ghre/Ghre_PlanController.cs +++ b/Tiobon.Core.Api/Controllers/Ghre/Ghre_PlanController.cs @@ -1,4 +1,6 @@ -namespace Tiobon.Core.Api.Controllers; +using Tiobon.Core.Model.ViewModels.Extend; + +namespace Tiobon.Core.Api.Controllers; /// /// 培训计划(Controller) @@ -46,4 +48,14 @@ public class Ghre_PlanController : BaseController + /// 根据条件查询数据 + /// + /// 条件 + /// + [HttpPost, Route("QueryUshioPlanReport")] + public async Task> QueryUshioPlan([FromBody] QueryBody body) => await _service.QueryUshioPlan(body); + #endregion } \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index 0f44f739..ad991fe6 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -1202,6 +1202,13 @@ status + + + 根据条件查询数据 + + 条件 + + 题目答案(Controller) diff --git a/Tiobon.Core.IServices/Ghre/IGhre_PlanServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_PlanServices.cs index 4bbf81ec..046e402c 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_PlanServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_PlanServices.cs @@ -1,4 +1,6 @@ -using Tiobon.Core.Model; +using Tiobon.Core.Common; +using Tiobon.Core.Model; +using Tiobon.Core.Model.ViewModels.Extend; namespace Tiobon.Core.IServices; @@ -10,4 +12,6 @@ public interface IGhre_PlanServices : IBaseServices> InsertByStatus(InsertGhre_PlanInput insertModel, string status); Task UpdateStatus(InsertGhre_PlanInput input, string status); + + Task> QueryUshioPlan(QueryBody filter); } \ No newline at end of file diff --git a/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs b/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs index 15b2d8a6..850e6f6a 100644 --- a/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs +++ b/Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs @@ -166,5 +166,10 @@ public class Ghre_StudyRecordDto : Ghre_StudyRecord /// 培训计划 /// public string PlanName { get; set; } + public bool? IsRequireStudy { get; set; } + public DateTime? ExamDate1 { get; set; } + + + } diff --git a/Tiobon.Core.Model/ViewModels/Extend/UshioPlanReport.cs b/Tiobon.Core.Model/ViewModels/Extend/UshioPlanReport.cs new file mode 100644 index 00000000..a94a5015 --- /dev/null +++ b/Tiobon.Core.Model/ViewModels/Extend/UshioPlanReport.cs @@ -0,0 +1,34 @@ +using Tiobon.Core.Model.Models; + +namespace Tiobon.Core.Model.ViewModels.Extend; + +public class UshioPlanReport : Ghre_PlanDto +{ + + public int? M1_Count { get; set; } = 0; + public decimal? M1_CompletionRate { get; set; } = 0; + public int? M2_Count { get; set; } = 0; + public decimal? M2_CompletionRate { get; set; } = 0; + public int? M3_Count { get; set; } = 0; + public decimal? M3_CompletionRate { get; set; } = 0; + public int? M4_Count { get; set; } = 0; + public decimal? M4_CompletionRate { get; set; } = 0; + public int? M5_Count { get; set; } = 0; + public decimal? M5_CompletionRate { get; set; } = 0; + public int? M6_Count { get; set; } = 0; + public decimal? M6_CompletionRate { get; set; } = 0; + public int? M7_Count { get; set; } = 0; + public decimal? M7_CompletionRate { get; set; } = 0; + public int? M8_Count { get; set; } = 0; + public decimal? M8_CompletionRate { get; set; } = 0; + public int? M9_Count { get; set; } = 0; + public decimal? M9_CompletionRate { get; set; } = 0; + public int? M10_Count { get; set; } = 0; + public decimal? M10_CompletionRate { get; set; } = 0; + public int? M11_Count { get; set; } = 0; + public decimal? M11_CompletionRate { get; set; } = 0; + public int? M12_Count { get; set; } + public decimal? M12_CompletionRate { get; set; } = 0; +} + + diff --git a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs index c080c494..4ea1b1cb 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs @@ -1,4 +1,8 @@ -using static Tiobon.Core.Model.Consts; +using NPOI.SS.Formula.Functions; +using NPOI.SS.Util; +using System.Linq; +using Tiobon.Core.Common.HttpContextUser; +using static Tiobon.Core.Model.Consts; namespace Tiobon.Core.Services; @@ -118,8 +122,6 @@ public class Ghre_PlanServices : BaseServices Add(InsertGhre_PlanInput entity) { if (entity.StaffId != null) @@ -219,4 +221,57 @@ public class Ghre_PlanServices : BaseServices> QueryUshioPlan(QueryBody filter) + { + var result = await QueryFilterPage(filter, "", true); + + var inPlanIds = result.result.DT_TableDataT1.Where(x => x.InOrOut == "In").Select(x => x.Id).ToList(); + var outPlanIds = result.result.DT_TableDataT1.Where(x => x.InOrOut == "Out").Select(x => x.Id).ToList(); + + int? year = null; + if (filter.jsonParam != null) + foreach (JProperty jProperty in filter.jsonParam.Properties()) + { + var name = jProperty.Name; + var value = jProperty.Value.ToString(); + if (name == "Year") + { + + var jsonParam = JsonHelper.JsonToObj(value); + year = jsonParam.columnValue.ObjToInt(); + + } + } + + + var studyRecordGroup1 = await Db.SqlQueryable("select * from Ghre_StudyRecord_V") + .Where(m => + inPlanIds.Contains(m.PlanId.Value) && m.PlanId != null && ( + m.CourseType == "ManualInsert" || + (m.BeginTime != null && m.EndTime != null && m.ExamId == null) || + (m.BeginTime != null && m.EndTime != null && m.ExamId != null && m.IsRequireStudy == true && m.IsPass == true) + )) + .Select(q => new { q.Id, q.PlanId, ExamDate = q.ExamDate1 ?? q.EndTime }) + .GroupBy(q => new { q.Id, q.PlanId, q.ExamDate }) + .Select(m => new { m.PlanId, ExamDate = m.ExamDate.Value, Count = SqlFunc.AggregateCount(m.Id) }) + .ToListAsync(); + + var data = Mapper.Map(result.result.DT_TableDataT1).ToANew>(); + + + data.ForEach(d => + { + d.M1_Count = studyRecordGroup1.Where(x => x.PlanId == d.Id && x.ExamDate.Year == year && x.ExamDate.Month == 1).Sum(x => x.Count); + if (d.M1_Count > 0 && d.TrainNum > 0) + d.M1_CompletionRate = d.M1_Count / d.TrainNum; + + + }); + + return new ServicePageResult(filter.pageNum, result.result.DT_TablePageInfoT1.TotalCount, filter.pageSize, data); + + + } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs index 7001a259..f5d2828f 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs @@ -740,7 +740,7 @@ INSERT INTO [120.26.205.42].[GhrUshio].[dbo].Ghre_GHR50Plan (PlanID, INNER JOIN Ghra_Staff S ON JsonData.TrainStaffId = S.StaffID FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') AS StaffNames, A.TrainNum - FROM Ghre_UshioPlan A + FROM Ghre_Plan A LEFT JOIN [120.26.205.42].[GhrUshio].[dbo].Ghre_GHR50Plan B ON B.PlanID = A.Id LEFT JOIN Ghro_Dept C ON a.DeptId = c.DeptID @@ -756,7 +756,7 @@ WHERE B.IsEnable ! = A.IsEnable UPDATE A SET A.IsEnable = B.IsEnable,A.LastUpdateDate=isnull (B.UpdateTime, B.CreateTime) FROM [120.26.205.42].[GhrUshio].[dbo].Ghre_GHR50Plan A - JOIN Ghre_UshioPlan B ON a.PlanID = B.Id + JOIN Ghre_Plan B ON a.PlanID = B.Id WHERE B.IsEnable ! = A.IsEnable OR isnull (B.UpdateTime, B.CreateTime) ! = A.LastUpdateDate"; await Db.Ado.ExecuteCommandAsync(sql);