You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.7 KiB
84 lines
3.7 KiB
namespace Tiobon.Core.Services;
|
|
|
|
/// <summary>
|
|
/// 培训计划 (服务)
|
|
/// </summary>
|
|
public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhre_PlanInput, EditGhre_PlanInput>, IGhre_PlanServices
|
|
{
|
|
private readonly IBaseRepository<Ghre_Plan> _dal;
|
|
public Ghre_PlanServices(ICaching caching, IBaseRepository<Ghre_Plan> dal)
|
|
{
|
|
this._dal = dal;
|
|
base.BaseDal = dal;
|
|
base._caching = caching;
|
|
}
|
|
public override async Task<ServicePageResult<Ghre_PlanDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true)
|
|
{
|
|
|
|
var result = await base.QueryFilterPage(filter, condition, IsEnable);
|
|
var DT_TableDataT1 = result.result.DT_TableDataT1;
|
|
|
|
var deptIds = DT_TableDataT1.Select(x => x.DeptId).Distinct().ToList();
|
|
var courseIds = DT_TableDataT1.Select(x => x.CourseId).Distinct().ToList();
|
|
var schoolIds = DT_TableDataT1.Select(x => x.SchoolId).Distinct().ToList();
|
|
var staffIds = new List<int>();
|
|
for (int i = 0; i < DT_TableDataT1.Count; i++)
|
|
{
|
|
if (DT_TableDataT1[i].StaffIds.IsNotEmptyOrNull())
|
|
staffIds.AddRange(JsonHelper.JsonToObj<List<int>>(DT_TableDataT1[i].StaffIds));
|
|
DT_TableDataT1[i].PlanType = await GetParaLabel("TrainingCategory", DT_TableDataT1[i].PlanType);
|
|
DT_TableDataT1[i].Month = await GetParaLabel("MonthSelect", DT_TableDataT1[i].Month);
|
|
}
|
|
staffIds = staffIds.Distinct().ToList();
|
|
var staffs = await Db.Queryable<Ghra_Staff>().Where(x => staffIds.Contains(x.StaffID)).ToListAsync();
|
|
var depts = await Db.Queryable<Ghro_Dept>().Where(x => deptIds.Contains(x.DeptID)).ToListAsync();
|
|
var courses = await Db.Queryable<Ghre_Course>().Where(x => courseIds.Contains(x.Id)).ToListAsync();
|
|
var schools = await Db.Queryable<Ghre_School>().Where(x => schoolIds.Contains(x.Id)).ToListAsync();
|
|
|
|
|
|
for (int i = 0; i < DT_TableDataT1.Count; i++)
|
|
{
|
|
if (DT_TableDataT1[i].StaffIds.IsNotEmptyOrNull())
|
|
{
|
|
var staffIds1 = JsonHelper.JsonToObj<List<int>>(DT_TableDataT1[i].StaffIds);
|
|
if (staffIds1.Any())
|
|
DT_TableDataT1[i].StaffNames = string.Join("、", staffs.Where(x => staffIds1.Contains(x.StaffID)).Select(x => x.StaffName));
|
|
}
|
|
|
|
DT_TableDataT1[i].CourseName = courses.Where(x => x.Id == DT_TableDataT1[i].CourseId).Select(x => x.CourseName).FirstOrDefault();
|
|
DT_TableDataT1[i].DeptName = depts.Where(x => x.DeptID == DT_TableDataT1[i].DeptId).Select(x => x.DeptName).FirstOrDefault();
|
|
DT_TableDataT1[i].SchoolName = schools.Where(x => x.Id == DT_TableDataT1[i].SchoolId).Select(x => x.SchoolName).FirstOrDefault();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
public override async Task<long> Add(InsertGhre_PlanInput entity)
|
|
{
|
|
if (entity.StaffIdList != null)
|
|
entity.StaffIds = JsonHelper.ObjToJson(entity.StaffIdList);
|
|
var result = await base.Add(entity);
|
|
|
|
return result;
|
|
}
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_PlanInput editModel)
|
|
{
|
|
if (editModel.StaffIdList != null)
|
|
editModel.StaffIds = JsonHelper.ObjToJson(editModel.StaffIdList);
|
|
|
|
var result = await base.Update(Id, editModel);
|
|
return result;
|
|
}
|
|
|
|
public override async Task<ServiceFormResult<Ghre_PlanDto>> QueryForm(QueryForm body)
|
|
{
|
|
var result = await base.QueryForm(body);
|
|
string StaffIds = result.result.DT_TableDataT1[0].StaffIds;
|
|
if (!string.IsNullOrWhiteSpace(StaffIds))
|
|
result.result.DT_TableDataT1[0].StaffIdList = JsonConvert.DeserializeObject<List<int>>(StaffIds);
|
|
return result;
|
|
|
|
}
|
|
} |