Merge branch 'WorskhopClassifiedPlan' into Main
This commit is contained in:
@@ -44,11 +44,18 @@ public interface IClassificationGroupRepository : IRepository<long, Classificati
|
||||
Task<bool> CheckIfEmployeeHasThisJob(long jobId, long groupId);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت مشاغل گروه توسط آی دی گروه
|
||||
/// ذخیر ایجاد یا ویرایش مشاغل در گروه
|
||||
/// </summary>
|
||||
/// <param name="groupId"></param>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EditClassificationGroupJob>> GetGroupJobs(long groupId);
|
||||
Task<bool> SaveJobsToGroup(AddOrEditJobInGroupDto command);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت مشاغل گروه توسط آی دی گروه
|
||||
/// </summary>
|
||||
/// <param name="groupId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<EditClassificationGroupJob>> GetGroupJobs(long groupId);
|
||||
|
||||
/// <summary>
|
||||
/// چک میکند که آی پرسنلی وجود دارد که این شغل به او نسبت داده شده
|
||||
|
||||
@@ -30,5 +30,16 @@ public interface IClassificationGroupSalariesRepository : IRepository<long, Clas
|
||||
/// <param name="schemeId"></param>
|
||||
/// <returns></returns>
|
||||
Task<SalaryAndRialCoefficientTab> GetSalariesTabData(long schemeId);
|
||||
|
||||
|
||||
#region ForApi
|
||||
/// <summary>
|
||||
/// لیست دستمزدها بر اساس تاریخ و سال برای تب دستمزدها
|
||||
/// </summary>
|
||||
/// <param name="schemeId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SalaryAndRialCoefficientTabDataList>> GetSalaryList(long schemeId);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -225,6 +225,20 @@ public interface IClassificationSchemeApplication
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CheckIfEmployeeHasThisJob(long jobId, long groupId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ذخیر ایجاد یا ویرایش مشاغل در گروه
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> SaveJobsToGroup(AddOrEditJobInGroupDto command);
|
||||
|
||||
/// <summary>
|
||||
/// لیست دستمزدها بر اساس تاریخ و سال برای تب دستمزدها
|
||||
/// </summary>
|
||||
/// <param name="schemeId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<SalaryAndRialCoefficientTabDataList>> GetSalaryList(long schemeId);
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -603,6 +603,7 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
|
||||
|
||||
}
|
||||
#region ForApi
|
||||
|
||||
public async Task<OperationResult> DeleteScheme(long id)
|
||||
{
|
||||
@@ -633,4 +634,21 @@ public class ClassificationSchemeApplication : IClassificationSchemeApplication
|
||||
|
||||
return op.Succcedded(-1, "حذف با موفقیت انجام شد");
|
||||
}
|
||||
|
||||
public async Task<OperationResult> SaveJobsToGroup(AddOrEditJobInGroupDto command)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
var res = await _classificationGroupRepository.SaveJobsToGroup(command);
|
||||
if (!res)
|
||||
return op.Failed("خطا در انجام عملیات");
|
||||
|
||||
return op.Succcedded();
|
||||
}
|
||||
|
||||
public async Task<List<SalaryAndRialCoefficientTabDataList>> GetSalaryList(long schemeId)
|
||||
{
|
||||
return await _classificationGroupSalariesRepository.GetSalaryList(schemeId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -224,5 +224,73 @@ public class ClassificationGroupRepository : RepositoryBase<long, Classification
|
||||
return await _context.ClassificationEmployees.AnyAsync(x =>
|
||||
x.ClassificationGroupJobId == id && x.ClassificationGroupId == groupId);
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> SaveJobsToGroup(AddOrEditJobInGroupDto command)
|
||||
{
|
||||
var newJoblist = new List<ClassificationGroupJob>();
|
||||
var alreadyExitjobs = new List<ClassificationGroupJob>();
|
||||
var alreadyAdded = await _context.ClassificationGroups.Where(x => x.id == command.GroupId)
|
||||
.Include(x => x.ClassificationGroupJobs).FirstOrDefaultAsync();
|
||||
if (command.AddJobListDto.Count > 0)
|
||||
{
|
||||
var addedJobsIds = command.AddJobListDto.Where(x => x.JobId > 0).Select(x => x.JobId).ToList();
|
||||
var getJobs = _context.Jobs.Where(x => addedJobsIds.Contains(x.id));
|
||||
|
||||
foreach (var item in getJobs)
|
||||
{
|
||||
|
||||
var newJob = new ClassificationGroupJob(item.id, item.JobName, item.JobCode, command.GroupId,
|
||||
$"{command.GroupNoInt}");
|
||||
|
||||
if (alreadyAdded.ClassificationGroupJobs.Any(x => x.JobId == item.id))
|
||||
{
|
||||
alreadyExitjobs.Add(newJob);
|
||||
}
|
||||
else
|
||||
{
|
||||
newJoblist.Add(newJob);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (alreadyAdded.ClassificationGroupJobs.Count == 0)
|
||||
{
|
||||
|
||||
if (command.AddJobListDto.Count > 0)
|
||||
{
|
||||
|
||||
await _context.ClassificationGroupJobs.AddRangeAsync(newJoblist);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
var alreadyExitJobsIds = alreadyExitjobs.Select(x => x.JobId).ToList();
|
||||
|
||||
var toBeRemove = alreadyAdded.ClassificationGroupJobs.Where(x => !alreadyExitJobsIds.Contains(x.JobId))
|
||||
.ToList();
|
||||
if (toBeRemove.Count > 0)
|
||||
{
|
||||
_context.ClassificationGroupJobs.RemoveRange(toBeRemove);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
if (newJoblist.Count > 0)
|
||||
{
|
||||
await _context.ClassificationGroupJobs.AddRangeAsync(newJoblist);
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -139,5 +139,49 @@ public class ClassificationGroupSalariesRepository : RepositoryBase<long, Classi
|
||||
|
||||
}
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<List<SalaryAndRialCoefficientTabDataList>> GetSalaryList(long schemeId)
|
||||
{
|
||||
var scheme = await _context.ClassificationSchemes.AsSplitQuery().Include(xc => xc.ClassificationRialCoefficients)
|
||||
.Include(xg => xg.ClassificationGroups)
|
||||
.ThenInclude(xs => xs.ClassificationGroupSalaries)
|
||||
.FirstOrDefaultAsync(x => x.id == schemeId);
|
||||
|
||||
if (scheme == null)
|
||||
return null;
|
||||
|
||||
// جمعآوری همهی حقوقها از تمام گروهها
|
||||
var allSalaries = scheme.ClassificationGroups
|
||||
.SelectMany(g => g.ClassificationGroupSalaries)
|
||||
.ToList();
|
||||
|
||||
// اگر هیچ حقوقی وجود ندارد
|
||||
if (!allSalaries.Any())
|
||||
{
|
||||
return new List<SalaryAndRialCoefficientTabDataList>();
|
||||
}
|
||||
|
||||
// گروهبندی بر اساس StartDate و EndDate برای حذف موارد تکراری
|
||||
var distinctPeriods = allSalaries
|
||||
.GroupBy(s => new { s.StartDate, s.EndDate })
|
||||
.Select(g => g.First()) // فقط یکی از هر بازه تاریخ
|
||||
.OrderByDescending(x => x.StartDate)
|
||||
.ToList();
|
||||
|
||||
//تبدیل به مدل خروجی
|
||||
var dataList = distinctPeriods
|
||||
.Select(s => new SalaryAndRialCoefficientTabDataList
|
||||
{
|
||||
RialCoefficientStr = $"{scheme.ClassificationRialCoefficients.FirstOrDefault(x => x.StartDate.Date == s.StartDate.Date && x.EndDate.Date == s.EndDate.Date)?.RialCoefficient}",
|
||||
StartDateFa = s.StartDate.ToFarsi(),
|
||||
EndDateFa = s.EndDate.ToFarsi(),
|
||||
Year = s.Year
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return dataList;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -23,6 +23,7 @@ public class ClassificationSchemeController : AdminBaseController
|
||||
_jobApplication = jobApplication;
|
||||
}
|
||||
|
||||
// تب لیست طرح
|
||||
#region SchemeTab
|
||||
|
||||
/// <summary>
|
||||
@@ -100,6 +101,7 @@ public class ClassificationSchemeController : AdminBaseController
|
||||
|
||||
#endregion
|
||||
|
||||
// تب تعیین مشاغل گروه
|
||||
#region GroupsTab
|
||||
/// <summary>
|
||||
/// دریافت لیست گروه ها
|
||||
@@ -149,6 +151,33 @@ public class ClassificationSchemeController : AdminBaseController
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ذخیره افزودن یا ویرایش مشاغل گروه
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("SaveJobsToGroup")]
|
||||
public async Task<ActionResult<OperationResult>> SaveJobsToGroup(AddOrEditJobInGroupDto command)
|
||||
{
|
||||
var result = await _classificationSchemeApplication.SaveJobsToGroup(command);
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
//تب تعیین دستمزد
|
||||
#region SalariesTab
|
||||
|
||||
/// <summary>
|
||||
/// دریافت لیست دستمزدها
|
||||
/// </summary>
|
||||
/// <param name="schemeId"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetSalariesList")]
|
||||
public async Task<List<SalaryAndRialCoefficientTabDataList>> GetSalariesList(long schemeId)
|
||||
{
|
||||
var result =await _classificationSchemeApplication.GetSalaryList(schemeId);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user