牛尾培训计划报表开发

master
xiaochanghai 3 months ago
parent 384cf65486
commit c1d6647f0b
  1. 14
      Tiobon.Core.Api/Controllers/Ghre/Ghre_PlanController.cs
  2. 7
      Tiobon.Core.Api/Tiobon.Core.xml
  3. 6
      Tiobon.Core.IServices/Ghre/IGhre_PlanServices.cs
  4. 5
      Tiobon.Core.Model/View/Ghre/Ghre_StudyRecord.Dto.View.cs
  5. 34
      Tiobon.Core.Model/ViewModels/Extend/UshioPlanReport.cs
  6. 61
      Tiobon.Core.Services/Ghre/Ghre_PlanServices.cs
  7. 4
      Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs

@ -1,4 +1,6 @@
namespace Tiobon.Core.Api.Controllers;
using Tiobon.Core.Model.ViewModels.Extend;
namespace Tiobon.Core.Api.Controllers;
/// <summary>
/// 培训计划(Controller)
@ -46,4 +48,14 @@ public class Ghre_PlanController : BaseController<IGhre_PlanServices, Ghre_Plan,
return await _service.InsertByStatus(insertModel, status);
}
#endregion
#region 牛尾报表查询
/// <summary>
/// 根据条件查询数据
/// </summary>
/// <param name="body">条件</param>
/// <returns></returns>
[HttpPost, Route("QueryUshioPlanReport")]
public async Task<ServicePageResult<UshioPlanReport>> QueryUshioPlan([FromBody] QueryBody body) => await _service.QueryUshioPlan(body);
#endregion
}

@ -1202,6 +1202,13 @@
<param name="status">status</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Api.Controllers.Ghre_PlanController.QueryUshioPlan(Tiobon.Core.Common.QueryBody)">
<summary>
根据条件查询数据
</summary>
<param name="body">条件</param>
<returns></returns>
</member>
<member name="T:Tiobon.Core.Api.Controllers.Ghre_QuestionAnswerController">
<summary>
题目答案(Controller)

@ -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<Ghre_Plan, Ghre_PlanDto, Ins
Task<ServiceResult<long>> InsertByStatus(InsertGhre_PlanInput insertModel, string status);
Task<ServiceResult> UpdateStatus(InsertGhre_PlanInput input, string status);
Task<ServicePageResult<UshioPlanReport>> QueryUshioPlan(QueryBody filter);
}

@ -166,5 +166,10 @@ public class Ghre_StudyRecordDto : Ghre_StudyRecord
/// 培训计划
/// </summary>
public string PlanName { get; set; }
public bool? IsRequireStudy { get; set; }
public DateTime? ExamDate1 { get; set; }
}

@ -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;
}

@ -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<Ghre_Plan, Ghre_PlanDto, InsertGhr
return result;
}
public override async Task<long> Add(InsertGhre_PlanInput entity)
{
if (entity.StaffId != null)
@ -219,4 +221,57 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr
return ServiceResult.OprateSuccess("执行成功!");
}
public async Task<ServicePageResult<UshioPlanReport>> 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<JsonParam>(value);
year = jsonParam.columnValue.ObjToInt();
}
}
var studyRecordGroup1 = await Db.SqlQueryable<Ghre_StudyRecordDto>("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<List<UshioPlanReport>>();
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<UshioPlanReport>(filter.pageNum, result.result.DT_TablePageInfoT1.TotalCount, filter.pageSize, data);
}
}

@ -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);

Loading…
Cancel
Save