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