培训需求

master
xiaochanghai 10 months ago
parent 375122254a
commit bc9bcb7bc3
  1. 18
      Tiobon.Core.Model/View/Ghre/Ghre_Request.Dto.View.cs
  2. 4
      Tiobon.Core.Services/BASE/BaseServices.cs
  3. 71
      Tiobon.Core.Services/Ghre/Ghre_RequestServices.cs

@ -32,4 +32,22 @@ public class Ghre_RequestDto : Ghre_Request
/// </summary>
public string UpdateDataInfo { get; set; }
public List<int> TrainStaffIds { get; set; }
public string CourseSourceLabel { get; set; }
public string RequestSourceLabel { get; set; }
public string DeptName { get; set; }
public string TrainClassLabel { get; set; }
public string TrainLevelLabel { get; set; }
public string InOrOutLabel { get; set; }
public string TeacherClassLabel { get; set; }
public string SponsorName { get; set; }
public string TrainStaffNames { get; set; }
}

@ -1237,13 +1237,11 @@ public class BaseServices<TEntity, TEntityDto, TInsertDto, TEditDto> : IBaseServ
/// <param name="columnCode">栏位名</param>
/// <param name="prefixTemp">前缀</param>
/// <returns></returns>
public async Task<string> GenerateContinuousSequence(string tableCode, string columnCode, string prefixTemp)
public async Task<string> GenerateContinuousSequence(string tableCode, string columnCode, string prefixTemp, int length = 7, int tempLength = 6)
{
try
{
string result = string.Empty;
int length = 7;
int tempLength = 6;
int sequence;
#region 查询

@ -5,11 +5,12 @@ using Tiobon.Core.Services.BASE;
using Tiobon.Core.IRepository.Base;
using Tiobon.Core.Common.Caches;
using Microsoft.AspNetCore.Http;
using static Tiobon.Core.Model.Consts;
using Tiobon.Core.Common.UserManager;
using Tiobon.Core.Model;
using Tiobon.Core.Common.Helper;
using Tiobon.Core.Common;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace Tiobon.Core.Services;
@ -26,23 +27,79 @@ public class Ghre_RequestServices : BaseServices<Ghre_Request, Ghre_RequestDto,
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)
{
entity.SponsorId = GetStaffId();
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds);
if (entity.TrainStaffIds.IsNotEmptyOrNull())
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds);
entity.RequestNo = await GenerateContinuousSequence("Ghre_Request", "RequestNo", "R");
return await base.Add(entity);
}
public override async Task<bool> Update(long Id, EditGhre_RequestInput entity)
{
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds);
if (entity.TrainStaffIds.IsNotEmptyOrNull())
entity.TrainStaffId = JsonHelper.ObjToJson(entity.TrainStaffIds);
else entity.TrainStaffId = null;
return await base.Update(Id, entity, null, ["Status"]);
}
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_RequestInput insertModel, string status)
{
var data = ServiceResult<long>.OprateSuccess("新增成功", 0);
insertModel.Status = status;
var id = await base.Add(insertModel);
var id = await Add(insertModel);
data.Success = id > 0;
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)
{
var result = await base.QueryForm(body);
string examPaperId = result.result.DT_TableDataT1[0].TrainStaffId;
if (!string.IsNullOrWhiteSpace(examPaperId))
result.result.DT_TableDataT1[0].TrainStaffIds = JsonHelper.JsonToObj<List<int>>(examPaperId);
string trainStaffId = result.result.DT_TableDataT1[0].TrainStaffId;
if (!string.IsNullOrWhiteSpace(trainStaffId))
result.result.DT_TableDataT1[0].TrainStaffIds = JsonHelper.JsonToObj<List<int>>(trainStaffId);
return result;
}

Loading…
Cancel
Save