|
|
@ -5,11 +5,12 @@ using Tiobon.Core.Services.BASE; |
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
using Tiobon.Core.IRepository.Base; |
|
|
|
using Tiobon.Core.Common.Caches; |
|
|
|
using Tiobon.Core.Common.Caches; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using Microsoft.AspNetCore.Http; |
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
using Tiobon.Core.Common.UserManager; |
|
|
|
using Tiobon.Core.Common.UserManager; |
|
|
|
using Tiobon.Core.Model; |
|
|
|
using Tiobon.Core.Model; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Common.Helper; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
using Tiobon.Core.Common; |
|
|
|
|
|
|
|
using Newtonsoft.Json.Linq; |
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
|
@ -26,23 +27,79 @@ public class Ghre_RequestServices : BaseServices<Ghre_Request, Ghre_RequestDto, |
|
|
|
base._caching = caching; |
|
|
|
base._caching = caching; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_RequestDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var result = await base.QueryFilterPage(filter, condition, IsEnable); |
|
|
|
|
|
|
|
var courseIds = result.result.DT_TableDataT1.Where(x => x.CourseId != null).Select(x => x.CourseId).Distinct().ToList(); |
|
|
|
|
|
|
|
var courses = await Db.Queryable<Ghre_Course>().Where(x => courseIds.Contains(x.Id)).ToListAsync(); |
|
|
|
|
|
|
|
var deptIds = result.result.DT_TableDataT1.Where(x => x.DeptId != null).Select(x => x.DeptId).Distinct().ToList(); |
|
|
|
|
|
|
|
var depts = await Db.Queryable<Ghro_Dept>().Where(x => deptIds.Contains(x.DeptID)).ToListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var sponsorIds = result.result.DT_TableDataT1.Where(x => x.SponsorId != null).Select(x => x.SponsorId).Distinct().ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.result.DT_TableDataT1.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
string trainStaffId = x.TrainStaffId; |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(trainStaffId)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.TrainStaffIds = JsonHelper.JsonToObj<List<int>>(trainStaffId); |
|
|
|
|
|
|
|
var TrainStaffIds = JsonHelper.JsonToObj<List<long?>>(trainStaffId); |
|
|
|
|
|
|
|
sponsorIds.AddRange(TrainStaffIds); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
sponsorIds = sponsorIds.Distinct().ToList(); |
|
|
|
|
|
|
|
var staffs = await Db.Queryable<Ghra_Staff>().Where(x => sponsorIds.Contains(x.StaffID)).ToListAsync(); |
|
|
|
|
|
|
|
result.result.DT_TableDataT1.ForEach(async x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
x.CourseSourceLabel = await GetParaLabel("TrainingRequestCourseSource", x.CourseSource); |
|
|
|
|
|
|
|
x.RequestSourceLabel = await GetParaLabel("TrainingRequestRequestSource", x.RequestSource); |
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x.CourseId != null) |
|
|
|
|
|
|
|
x.CourseName = courses.Where(o => x.CourseId == o.Id).FirstOrDefault()?.CourseName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x.DeptId != null) |
|
|
|
|
|
|
|
x.DeptName = depts.Where(o => x.DeptId == o.DeptID).FirstOrDefault()?.DeptName; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (x.SponsorId != null) |
|
|
|
|
|
|
|
x.SponsorName = staffs.Where(o => x.SponsorId == o.StaffID).FirstOrDefault()?.StaffName; |
|
|
|
|
|
|
|
if (x.TrainStaffIds.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
x.TrainStaffNames = string.Join("、", staffs.Where(o => x.TrainStaffIds.Contains(o.StaffID)).Select(o => o.StaffName)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override async Task<long> Add(InsertGhre_RequestInput entity) |
|
|
|
public override async Task<long> Add(InsertGhre_RequestInput entity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
entity.SponsorId = GetStaffId(); |
|
|
|
entity.SponsorId = GetStaffId(); |
|
|
|
|
|
|
|
if (entity.TrainStaffIds.IsNotEmptyOrNull()) |
|
|
|
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); |
|
|
|
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); |
|
|
|
|
|
|
|
entity.RequestNo = await GenerateContinuousSequence("Ghre_Request", "RequestNo", "R"); |
|
|
|
return await base.Add(entity); |
|
|
|
return await base.Add(entity); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_RequestInput entity) |
|
|
|
public override async Task<bool> Update(long Id, EditGhre_RequestInput entity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (entity.TrainStaffIds.IsNotEmptyOrNull()) |
|
|
|
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); |
|
|
|
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds); |
|
|
|
|
|
|
|
else entity.TrainStaffId = null; |
|
|
|
return await base.Update(Id, entity, null, ["Status"]); |
|
|
|
return await base.Update(Id, entity, null, ["Status"]); |
|
|
|
} |
|
|
|
} |
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_RequestInput insertModel, string status) |
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_RequestInput insertModel, string status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var data = ServiceResult<long>.OprateSuccess("新增成功", 0); |
|
|
|
var data = ServiceResult<long>.OprateSuccess("新增成功", 0); |
|
|
|
insertModel.Status = status; |
|
|
|
insertModel.Status = status; |
|
|
|
var id = await base.Add(insertModel); |
|
|
|
var id = await Add(insertModel); |
|
|
|
|
|
|
|
|
|
|
|
data.Success = id > 0; |
|
|
|
data.Success = id > 0; |
|
|
|
if (data.Success) |
|
|
|
if (data.Success) |
|
|
@ -56,9 +113,9 @@ public class Ghre_RequestServices : BaseServices<Ghre_Request, Ghre_RequestDto, |
|
|
|
public override async Task<ServiceFormResult<Ghre_RequestDto>> QueryForm(QueryForm body) |
|
|
|
public override async Task<ServiceFormResult<Ghre_RequestDto>> QueryForm(QueryForm body) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
string examPaperId = result.result.DT_TableDataT1[0].TrainStaffId; |
|
|
|
string trainStaffId = result.result.DT_TableDataT1[0].TrainStaffId; |
|
|
|
if (!string.IsNullOrWhiteSpace(examPaperId)) |
|
|
|
if (!string.IsNullOrWhiteSpace(trainStaffId)) |
|
|
|
result.result.DT_TableDataT1[0].TrainStaffIds = JsonHelper.JsonToObj<List<int>>(examPaperId); |
|
|
|
result.result.DT_TableDataT1[0].TrainStaffIds = JsonHelper.JsonToObj<List<int>>(trainStaffId); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|