|
|
|
@ -1,4 +1,6 @@ |
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
|
namespace Tiobon.Core.Services; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// 人力需求维护 (服务) |
|
|
|
@ -6,11 +8,13 @@ |
|
|
|
|
public class Ghrh_HumanRequestServices : BaseServices<Ghrh_HumanRequest, Ghrh_HumanRequestDto, InsertGhrh_HumanRequestInput, EditGhrh_HumanRequestInput>, IGhrh_HumanRequestServices |
|
|
|
|
{ |
|
|
|
|
private readonly IBaseRepository<Ghrh_HumanRequest> _dal; |
|
|
|
|
public Ghrh_HumanRequestServices(ICaching caching, IBaseRepository<Ghrh_HumanRequest> dal) |
|
|
|
|
private readonly IGhrh_HumanRequestDetailServices _ghrh_HumanRequestDetailServices; |
|
|
|
|
public Ghrh_HumanRequestServices(ICaching caching, IBaseRepository<Ghrh_HumanRequest> dal, IGhrh_HumanRequestDetailServices ghrh_HumanRequestDetailServices) |
|
|
|
|
{ |
|
|
|
|
this._dal = dal; |
|
|
|
|
base.BaseDal = dal; |
|
|
|
|
base._caching = caching; |
|
|
|
|
_ghrh_HumanRequestDetailServices = ghrh_HumanRequestDetailServices; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region 字典映射、全称、单位转换等 |
|
|
|
@ -28,10 +32,69 @@ public class Ghrh_HumanRequestServices : BaseServices<Ghrh_HumanRequest, Ghrh_Hu |
|
|
|
|
x.InTime1 = DateTimeHelper.ConvertToDayString(x.InTime); |
|
|
|
|
x.AgeLabel = await GetParaLabel("AgePeriodSetup", x.Age); |
|
|
|
|
x.ResumeTypeLabel = await GetParaLabel("ResumeType", x.ResumeType); |
|
|
|
|
//x.AgeLabel = DateTimeHelper.ConvertToDayString(x.Age); |
|
|
|
|
|
|
|
|
|
if (x.WorkState.IsNotEmptyOrNull()) |
|
|
|
|
{ |
|
|
|
|
if (x.WorkState == 0) x.WorkStateLabel = "审批中"; |
|
|
|
|
if (x.WorkState == 1) x.WorkStateLabel = "审批通过"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 新增 |
|
|
|
|
public override async Task<long> Add(InsertGhrh_HumanRequestInput entity) |
|
|
|
|
{ |
|
|
|
|
entity.ApplicantId = GetStaffId(); |
|
|
|
|
|
|
|
|
|
var id = await base.Add(entity); |
|
|
|
|
|
|
|
|
|
var sql = $"SELECT ISNULL(MAX(id)+1,1) FROM Ghrh_HumanRequest WHERE Id !='{id}'"; |
|
|
|
|
var id1 = await Db.Ado.GetLongAsync(sql); |
|
|
|
|
sql = $"UPDATE Ghrh_HumanRequest SET Id={id1} WHERE Id ='{id}'"; |
|
|
|
|
if (entity.Quality != null && entity.Quality.Any()) |
|
|
|
|
{ |
|
|
|
|
var qualitys = entity.Quality.Select(x => new InsertGhrh_HumanRequestDetailInput() |
|
|
|
|
{ |
|
|
|
|
RequestId = id1, |
|
|
|
|
DetailName = x, |
|
|
|
|
Source = "Quality" |
|
|
|
|
}).ToList(); |
|
|
|
|
await _ghrh_HumanRequestDetailServices.Add(qualitys); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (entity.Experience != null && entity.Experience.Any()) |
|
|
|
|
{ |
|
|
|
|
var experiences = entity.Experience.Select(x => new InsertGhrh_HumanRequestDetailInput() |
|
|
|
|
{ |
|
|
|
|
RequestId = id1, |
|
|
|
|
DetailName = x.value, |
|
|
|
|
DetailValue = x.text, |
|
|
|
|
Source = "Experience" |
|
|
|
|
}).ToList(); |
|
|
|
|
await _ghrh_HumanRequestDetailServices.Add(experiences); |
|
|
|
|
} |
|
|
|
|
await Db.Ado.ExecuteCommandAsync(sql); |
|
|
|
|
return id1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult<long>> InsertByStatus(InsertGhrh_HumanRequestInput insertModel, string status) |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 查询 |
|
|
|
|
public override async Task<ServicePageResult<Ghrh_HumanRequestDto>> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) |
|
|
|
|
{ |
|
|
|
|
var result = await base.QueryFilterPage(filter, condition, IsEnable); |
|
|
|
@ -41,7 +104,7 @@ public class Ghrh_HumanRequestServices : BaseServices<Ghrh_HumanRequest, Ghrh_Hu |
|
|
|
|
var gradeIds = entitys.Where(x => x.GradeId != null).Select(x => x.GradeId).ToList(); |
|
|
|
|
var jobIds = entitys.Where(x => x.JobId != null).Select(x => x.JobId).ToList(); |
|
|
|
|
var titleIds = entitys.Where(x => x.TitleId != null).Select(x => x.TitleId).ToList(); |
|
|
|
|
var reportIds = entitys.Where(x => x.ReportId != null).Select(x => x.ReportId).ToList(); |
|
|
|
|
var reportIds = entitys.Where(x => x.ReportId != null).Select(x => x.ReportId).ToList(); |
|
|
|
|
|
|
|
|
|
if (reportIds.Any()) |
|
|
|
|
{ |
|
|
|
@ -102,10 +165,17 @@ FROM Ghrh_YearHumanSettings A |
|
|
|
|
LEFT JOIN Ghra_Job C ON A.JobId = C.JobID |
|
|
|
|
WHERE A.IsEnable = 1 AND A.Id = {entitys[i].YearHumanId}");
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var userIds = entitys.Where(x => x.RefuseUserId != null).Select(x => x.RefuseUserId).Distinct().ToList(); |
|
|
|
|
userIds.AddRange(entitys.Where(x => x.AgreeUserId != null).Select(x => x.AgreeUserId).Distinct()); |
|
|
|
|
var users = await Db.Queryable<Ghrs_User>().Where(x => userIds.Contains(x.UserId)).ToListAsync(); |
|
|
|
|
entitys.ForEach(async x => |
|
|
|
|
{ |
|
|
|
|
await SetLabel(x); |
|
|
|
|
if (x.AgreeUserId != null) |
|
|
|
|
x.AgreeUserName = users.Where(o => x.AgreeUserId == o.UserId).FirstOrDefault()?.UserName; |
|
|
|
|
|
|
|
|
|
if (x.RefuseUserId != null) |
|
|
|
|
x.RefuseUserName = users.Where(o => x.RefuseUserId == o.UserId).FirstOrDefault()?.UserName; |
|
|
|
|
}); |
|
|
|
|
result.result.DT_TableDataT1 = entitys; |
|
|
|
|
return result; |
|
|
|
@ -132,4 +202,102 @@ WHERE A.IsEnable = 1 AND A.Id = {entitys[i].YearHumanId}"); |
|
|
|
|
#endregion |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override async Task<ServiceFormResult<Ghrh_HumanRequestDto>> QueryForm(QueryForm body) |
|
|
|
|
{ |
|
|
|
|
var result = await base.QueryForm(body); |
|
|
|
|
|
|
|
|
|
var DT_TableDataT1 = result.result.DT_TableDataT1; |
|
|
|
|
|
|
|
|
|
if (DT_TableDataT1 != null && DT_TableDataT1.Any()) |
|
|
|
|
{ |
|
|
|
|
var details = await _ghrh_HumanRequestDetailServices.Query(x => x.RequestId == DT_TableDataT1[0].Id); |
|
|
|
|
DT_TableDataT1[0].Quality = details.Where(x => x.Source == "Quality").Select(x => x.DetailName).ToList(); |
|
|
|
|
DT_TableDataT1[0].Experience = details.Where(x => x.Source == "Experience").Select(x => new Ghrh_HumanRequestExperience() |
|
|
|
|
{ |
|
|
|
|
value = x.DetailName, |
|
|
|
|
text = x.DetailValue, |
|
|
|
|
}).ToList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.result.DT_TableDataT1 = DT_TableDataT1; |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 更新 |
|
|
|
|
public override async Task<bool> Update(long Id, EditGhrh_HumanRequestInput entity) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
await _ghrh_HumanRequestDetailServices.Delete(x => x.RequestId == Id && x.Source == "Quality"); |
|
|
|
|
await _ghrh_HumanRequestDetailServices.Delete(x => x.RequestId == Id && x.Source == "Experience"); |
|
|
|
|
|
|
|
|
|
if (entity.Quality != null && entity.Quality.Any()) |
|
|
|
|
{ |
|
|
|
|
var qualitys = entity.Quality.Select(x => new InsertGhrh_HumanRequestDetailInput() |
|
|
|
|
{ |
|
|
|
|
RequestId = Id, |
|
|
|
|
DetailName = x, |
|
|
|
|
Source = "Quality" |
|
|
|
|
}).ToList(); |
|
|
|
|
await _ghrh_HumanRequestDetailServices.Add(qualitys); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (entity.Experience != null && entity.Experience.Any()) |
|
|
|
|
{ |
|
|
|
|
var experiences = entity.Experience.Select(x => new InsertGhrh_HumanRequestDetailInput() |
|
|
|
|
{ |
|
|
|
|
RequestId = Id, |
|
|
|
|
DetailName = x.value, |
|
|
|
|
DetailValue = x.text, |
|
|
|
|
Source = "Experience" |
|
|
|
|
}).ToList(); |
|
|
|
|
await _ghrh_HumanRequestDetailServices.Add(experiences); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return await base.Update(Id, entity, null, ["Status"]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public async Task<ServiceResult> UpdateStatus(InsertGhrh_HumanRequestInput input, string status) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
HttpRequest request = UserContext.Context.Request; |
|
|
|
|
var api = request.Path.ObjToString().TrimEnd('/').ToLower(); |
|
|
|
|
var ip = GetUserIp(UserContext.Context); |
|
|
|
|
|
|
|
|
|
var entities = new List<Ghrh_HumanRequest>(); |
|
|
|
|
foreach (var id in input.Ids) |
|
|
|
|
{ |
|
|
|
|
if (!BaseDal.Any(id)) |
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
var entity = await BaseDal.QueryById(id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (status) |
|
|
|
|
{ |
|
|
|
|
case DIC_REQUEST_STATUS.Active: |
|
|
|
|
entity.AgreeReason = input.Reason; |
|
|
|
|
entity.AgreeTime = DateTime.Now; |
|
|
|
|
entity.AgreeUserId = App.User.ID; |
|
|
|
|
break; |
|
|
|
|
case DIC_REQUEST_STATUS.Temporary: |
|
|
|
|
entity.RefuseReason = input.Reason; |
|
|
|
|
entity.RefuseTime = DateTime.Now; |
|
|
|
|
entity.RefuseUserId = App.User.ID; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
entity.UpdateIP = ip; |
|
|
|
|
entity.UpdateProg = api; |
|
|
|
|
entity.Status = status; |
|
|
|
|
entities.Add(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var result = await BaseDal.Update(entities); |
|
|
|
|
return ServiceResult.OprateSuccess("执行成功!"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
} |