|
|
@ -8,16 +8,32 @@ namespace Tiobon.Core.Services; |
|
|
|
public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhre_PlanInput, EditGhre_PlanInput>, IGhre_PlanServices |
|
|
|
public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhre_PlanInput, EditGhre_PlanInput>, IGhre_PlanServices |
|
|
|
{ |
|
|
|
{ |
|
|
|
private readonly IBaseRepository<Ghre_Plan> _dal; |
|
|
|
private readonly IBaseRepository<Ghre_Plan> _dal; |
|
|
|
public Ghre_PlanServices(ICaching caching, IBaseRepository<Ghre_Plan> dal) |
|
|
|
private readonly ICommonServices _commonServices; |
|
|
|
|
|
|
|
public Ghre_PlanServices(ICaching caching, IBaseRepository<Ghre_Plan> dal, ICommonServices commonServices) |
|
|
|
{ |
|
|
|
{ |
|
|
|
this._dal = dal; |
|
|
|
this._dal = dal; |
|
|
|
base.BaseDal = dal; |
|
|
|
base.BaseDal = dal; |
|
|
|
base._caching = caching; |
|
|
|
base._caching = caching; |
|
|
|
|
|
|
|
_commonServices = commonServices; |
|
|
|
} |
|
|
|
} |
|
|
|
public override async Task<ServicePageResult<Ghre_PlanDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
public override async Task<ServicePageResult<Ghre_PlanDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var result = await base.QueryFilterPage(filter, condition, IsEnable); |
|
|
|
var result = await base.QueryFilterPage(filter, condition, IsEnable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 DT_TableDataT1 = result.result.DT_TableDataT1; |
|
|
|
var DT_TableDataT1 = result.result.DT_TableDataT1; |
|
|
|
|
|
|
|
|
|
|
|
var deptIds = DT_TableDataT1.Select(x => x.DeptId).Distinct().ToList(); |
|
|
|
var deptIds = DT_TableDataT1.Select(x => x.DeptId).Distinct().ToList(); |
|
|
@ -29,7 +45,26 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr |
|
|
|
if (DT_TableDataT1[i].StaffIds.IsNotEmptyOrNull()) |
|
|
|
if (DT_TableDataT1[i].StaffIds.IsNotEmptyOrNull()) |
|
|
|
staffIds.AddRange(JsonHelper.JsonToObj<List<int>>(DT_TableDataT1[i].StaffIds)); |
|
|
|
staffIds.AddRange(JsonHelper.JsonToObj<List<int>>(DT_TableDataT1[i].StaffIds)); |
|
|
|
DT_TableDataT1[i].TrainCategory = await GetParaLabel("TrainingCategory", DT_TableDataT1[i].TrainCategory); |
|
|
|
DT_TableDataT1[i].TrainCategory = await GetParaLabel("TrainingCategory", DT_TableDataT1[i].TrainCategory); |
|
|
|
DT_TableDataT1[i].Month = await GetParaLabel("MonthSelect", DT_TableDataT1[i].Month); |
|
|
|
if (DT_TableDataT1[i].Month.IsNotEmptyOrNull()) |
|
|
|
|
|
|
|
DT_TableDataT1[i].Months = JsonHelper.JsonToObj<List<string>>(DT_TableDataT1[i].Month); |
|
|
|
|
|
|
|
//DT_TableDataT1[i].Month = await GetParaLabel("MonthSelect", DT_TableDataT1[i].Month); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DT_TableDataT1[i].Months.Any()) |
|
|
|
|
|
|
|
DT_TableDataT1[i].Months.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (x.ObjToInt() == 1) DT_TableDataT1[i].M1 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 2) DT_TableDataT1[i].M2 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 3) DT_TableDataT1[i].M3 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 4) DT_TableDataT1[i].M4 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 5) DT_TableDataT1[i].M5 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 6) DT_TableDataT1[i].M6 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 7) DT_TableDataT1[i].M7 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 8) DT_TableDataT1[i].M8 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 9) DT_TableDataT1[i].M9 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 10) DT_TableDataT1[i].M10 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 11) DT_TableDataT1[i].M11 = "✔"; |
|
|
|
|
|
|
|
else if (x.ObjToInt() == 12) DT_TableDataT1[i].M12 = "✔"; |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
staffIds = staffIds.Distinct().ToList(); |
|
|
|
staffIds = staffIds.Distinct().ToList(); |
|
|
|
var staffs = await Db.Queryable<Ghra_Staff>().Where(x => staffIds.Contains(x.StaffID)).ToListAsync(); |
|
|
|
var staffs = await Db.Queryable<Ghra_Staff>().Where(x => staffIds.Contains(x.StaffID)).ToListAsync(); |
|
|
@ -47,10 +82,39 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr |
|
|
|
DT_TableDataT1[i].StaffNames = string.Join("、", staffs.Where(x => staffIds1.Contains(x.StaffID)).Select(x => x.StaffName)); |
|
|
|
DT_TableDataT1[i].StaffNames = string.Join("、", staffs.Where(x => staffIds1.Contains(x.StaffID)).Select(x => x.StaffName)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (DT_TableDataT1[i].CourseId.IsNotEmptyOrNull() && DT_TableDataT1[i].CourseName.IsNullOrEmpty()) |
|
|
|
DT_TableDataT1[i].CourseName = courses.Where(x => x.Id == DT_TableDataT1[i].CourseId).Select(x => x.CourseName).FirstOrDefault(); |
|
|
|
DT_TableDataT1[i].CourseName = courses.Where(x => x.Id == DT_TableDataT1[i].CourseId).Select(x => x.CourseName).FirstOrDefault(); |
|
|
|
|
|
|
|
if (DT_TableDataT1[i].DeptId.IsNotEmptyOrNull()) |
|
|
|
DT_TableDataT1[i].DeptName = depts.Where(x => x.DeptID == DT_TableDataT1[i].DeptId).Select(x => x.DeptName).FirstOrDefault(); |
|
|
|
DT_TableDataT1[i].DeptName = depts.Where(x => x.DeptID == DT_TableDataT1[i].DeptId).Select(x => x.DeptName).FirstOrDefault(); |
|
|
|
|
|
|
|
if (DT_TableDataT1[i].SchoolId.IsNotEmptyOrNull()) |
|
|
|
DT_TableDataT1[i].SchoolName = schools.Where(x => x.Id == DT_TableDataT1[i].SchoolId).Select(x => x.SchoolName).FirstOrDefault(); |
|
|
|
DT_TableDataT1[i].SchoolName = schools.Where(x => x.Id == DT_TableDataT1[i].SchoolId).Select(x => x.SchoolName).FirstOrDefault(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ModuleParam param = new ModuleParam() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
langId = filter.langId, |
|
|
|
|
|
|
|
menuName = filter.menuName |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
var module = await _commonServices.GetModuleInfoAsync(param); |
|
|
|
|
|
|
|
result.result.JM_TableColumnT1 = module.Data.JM_TableColumnT1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var yearField = module.Data.JM_TableColumnT1.TableColumn.Where(x => x.field == "Year").SingleOrDefault(); |
|
|
|
|
|
|
|
if (year != yearField?.searchColumnDefaultValue.ObjToInt()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.result.JM_TableColumnT1.TableColumn?.ForEach(x => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (x.GroupName == "计划年月") |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int month = x.field.Replace("M", null).Replace("_F", null).ObjToInt(); |
|
|
|
|
|
|
|
x.label = year + "-" + (month < 10 ? "0" + month : month); |
|
|
|
|
|
|
|
if (month == 12) |
|
|
|
|
|
|
|
year++; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -58,8 +122,12 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr |
|
|
|
|
|
|
|
|
|
|
|
public override async Task<long> Add(InsertGhre_PlanInput entity) |
|
|
|
public override async Task<long> Add(InsertGhre_PlanInput entity) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (entity.StaffIdList != null) |
|
|
|
if (entity.StaffId != null) |
|
|
|
entity.StaffIds = JsonHelper.ObjToJson(entity.StaffIdList); |
|
|
|
entity.StaffIds = JsonHelper.ObjToJson(entity.StaffId.OrderBy(n => n).ToList()); |
|
|
|
|
|
|
|
if (entity.StaffId.IsNotEmptyOrNull() && entity.StaffId.Count > 0) |
|
|
|
|
|
|
|
entity.TrainNum = entity.StaffId.Count; |
|
|
|
|
|
|
|
if (entity.Months != null) |
|
|
|
|
|
|
|
entity.Month = JsonHelper.ObjToJson(entity.Months.OrderBy(n => n).ToList()); |
|
|
|
var result = await base.Add(entity); |
|
|
|
var result = await base.Add(entity); |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -67,8 +135,13 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr |
|
|
|
|
|
|
|
|
|
|
|
public override async Task<bool> Update(long Id, EditGhre_PlanInput editModel) |
|
|
|
public override async Task<bool> Update(long Id, EditGhre_PlanInput editModel) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (editModel.StaffIdList != null) |
|
|
|
if (editModel.StaffId != null) |
|
|
|
editModel.StaffIds = JsonHelper.ObjToJson(editModel.StaffIdList); |
|
|
|
editModel.StaffIds = JsonHelper.ObjToJson(editModel.StaffId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (editModel.StaffId.IsNotEmptyOrNull() && editModel.StaffId.Count > 0) |
|
|
|
|
|
|
|
editModel.TrainNum = editModel.StaffId.Count; |
|
|
|
|
|
|
|
if (editModel.Months != null) |
|
|
|
|
|
|
|
editModel.Month = JsonHelper.ObjToJson(editModel.Months.OrderBy(n => n).ToList()); |
|
|
|
|
|
|
|
|
|
|
|
var result = await base.Update(Id, editModel, null, ["Status"]); |
|
|
|
var result = await base.Update(Id, editModel, null, ["Status"]); |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -77,19 +150,22 @@ public class Ghre_PlanServices : BaseServices<Ghre_Plan, Ghre_PlanDto, InsertGhr |
|
|
|
public override async Task<ServiceFormResult<Ghre_PlanDto>> QueryForm(QueryForm body) |
|
|
|
public override async Task<ServiceFormResult<Ghre_PlanDto>> QueryForm(QueryForm body) |
|
|
|
{ |
|
|
|
{ |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
var result = await base.QueryForm(body); |
|
|
|
|
|
|
|
|
|
|
|
string StaffIds = result.result.DT_TableDataT1[0].StaffIds; |
|
|
|
string StaffIds = result.result.DT_TableDataT1[0].StaffIds; |
|
|
|
|
|
|
|
string Month = result.result.DT_TableDataT1[0].Month; |
|
|
|
if (!string.IsNullOrWhiteSpace(StaffIds)) |
|
|
|
if (!string.IsNullOrWhiteSpace(StaffIds)) |
|
|
|
result.result.DT_TableDataT1[0].StaffIdList = JsonConvert.DeserializeObject<List<int>>(StaffIds); |
|
|
|
result.result.DT_TableDataT1[0].StaffId = JsonConvert.DeserializeObject<List<int>>(StaffIds); |
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(Month)) |
|
|
|
|
|
|
|
result.result.DT_TableDataT1[0].Months = JsonConvert.DeserializeObject<List<string>>(Month); |
|
|
|
|
|
|
|
if (result.result.DT_TableDataT1[0].TrainNum != null && result.result.DT_TableDataT1[0].TrainDays != null) |
|
|
|
|
|
|
|
result.result.DT_TableDataT1[0].TotalDays = result.result.DT_TableDataT1[0].TrainNum * result.result.DT_TableDataT1[0].TrainDays; |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_PlanInput insertModel, string status) |
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhre_PlanInput insertModel, string status) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (insertModel.StaffId != null) |
|
|
|
if (insertModel.StaffIdList != null) |
|
|
|
insertModel.StaffIds = JsonHelper.ObjToJson(insertModel.StaffId); |
|
|
|
insertModel.StaffIds = JsonHelper.ObjToJson(insertModel.StaffIdList); |
|
|
|
|
|
|
|
var data = ServiceResult<long>.OprateSuccess("新增成功", 0); |
|
|
|
var data = ServiceResult<long>.OprateSuccess("新增成功", 0); |
|
|
|
insertModel.Status = status; |
|
|
|
insertModel.Status = status; |
|
|
|
var id = await Add(insertModel); |
|
|
|
var id = await Add(insertModel); |
|
|
|