|
|
|
@ -1,4 +1,7 @@ |
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
using Tiobon.Core.Common.DB.Dapper.Extensions; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 【牛尾】培训计划 (服务) |
|
|
|
@ -12,4 +15,114 @@ public class Ghre_UshioPlanServices : BaseServices<Ghre_UshioPlan, Ghre_UshioPla |
|
|
|
|
base.BaseDal = dal; |
|
|
|
|
base._caching = caching; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<ServicePageResult<Ghre_UshioPlanDto>> 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 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].TrainCategory = await GetParaLabel("TrainingCategory", DT_TableDataT1[i].TrainCategory); |
|
|
|
|
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(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<long> Add(InsertGhre_UshioPlanInput entity) |
|
|
|
|
{ |
|
|
|
|
if (entity.StaffId != null) |
|
|
|
|
entity.StaffIds = JsonHelper.ObjToJson(entity.StaffId); |
|
|
|
|
var result = await base.Add(entity); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_UshioPlanInput editModel) |
|
|
|
|
{ |
|
|
|
|
if (editModel.StaffId != null) |
|
|
|
|
editModel.StaffIds = JsonHelper.ObjToJson(editModel.StaffId); |
|
|
|
|
|
|
|
|
|
var result = await base.Update(Id, editModel, null, ["Status"]); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<ServiceFormResult<Ghre_UshioPlanDto>> 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].StaffId = JsonConvert.DeserializeObject<List<int>>(StaffIds); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_UshioPlanInput insertModel, string status) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if (insertModel.StaffId != null) |
|
|
|
|
insertModel.StaffIds = JsonHelper.ObjToJson(insertModel.StaffId); |
|
|
|
|
var data = ServiceResult<long>.OprateSuccess("新增成功", 0); |
|
|
|
|
insertModel.Status = status; |
|
|
|
|
var id = await Add(insertModel); |
|
|
|
|
|
|
|
|
|
data.Success = id > 0; |
|
|
|
|
if (data.Success) |
|
|
|
|
data.Data = id; |
|
|
|
|
else |
|
|
|
|
return ServiceResult<long>.OprateFailed("失败!"); |
|
|
|
|
|
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> UpdateStatus(InsertGhre_UshioPlanInput input, string status) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
|
|
var api = request.Path.ObjToString().TrimEnd('/').ToLower(); |
|
|
|
|
var ip = GetUserIp(UserContext.Context); |
|
|
|
|
|
|
|
|
|
var entities = new List<Ghre_UshioPlan>(); |
|
|
|
|
foreach (var id in input.Ids) |
|
|
|
|
{ |
|
|
|
|
if (!BaseDal.Any(id)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
var entity = await BaseDal.QueryById(id); |
|
|
|
|
|
|
|
|
|
entity.UpdateIP = ip; |
|
|
|
|
entity.UpdateProg = api; |
|
|
|
|
entity.Status = status; |
|
|
|
|
entities.Add(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = await BaseDal.Update(entities); |
|
|
|
|
return ServiceResult.OprateSuccess("执行成功!"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |