add new metod
This commit is contained in:
@@ -5,6 +5,7 @@ using _0_Framework.Application;
|
|||||||
using _0_Framework.Domain;
|
using _0_Framework.Domain;
|
||||||
using CompanyManagment.App.Contracts.LeftWork;
|
using CompanyManagment.App.Contracts.LeftWork;
|
||||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||||
|
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||||
|
|
||||||
namespace Company.Domain.LeftWorkAgg;
|
namespace Company.Domain.LeftWorkAgg;
|
||||||
|
|
||||||
@@ -46,4 +47,11 @@ public interface ILeftWorkRepository : IRepository<long, LeftWork>
|
|||||||
|
|
||||||
Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId);
|
Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId);
|
||||||
List<LeftWorkViewModel> SearchCreateContract(LeftWorkSearchModel searchModel);
|
List<LeftWorkViewModel> SearchCreateContract(LeftWorkSearchModel searchModel);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت اطلاعات کارگاه و پرسنل برای ایجاد قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
AutoExtensionDto AutoExtentionEmployees(long workshopId);
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using CompanyManagment.App.Contracts.PersonnleCode;
|
using CompanyManagment.App.Contracts.PersonnleCode;
|
||||||
|
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace CompanyManagment.App.Contracts.LeftWork;
|
namespace CompanyManagment.App.Contracts.LeftWork;
|
||||||
@@ -30,4 +31,10 @@ public interface ILeftWorkApplication
|
|||||||
OperationResult CreateLeftWorkByLeftWorkGroups(string employeeFullName, long commandEmployeeId, List<PersonnelCodeViewModel> commandPersonnelCode, List<LeftWorkGroup> leftWorkGroups);
|
OperationResult CreateLeftWorkByLeftWorkGroups(string employeeFullName, long commandEmployeeId, List<PersonnelCodeViewModel> commandPersonnelCode, List<LeftWorkGroup> leftWorkGroups);
|
||||||
OperationResult CheckDeleteLeftWork(long workshopId, long employeeId, string date, int type);
|
OperationResult CheckDeleteLeftWork(long workshopId, long employeeId, string date, int type);
|
||||||
OperationResult CheckEditLeftWork(long workshopId, long employeeId, string date, int type);
|
OperationResult CheckEditLeftWork(long workshopId, long employeeId, string date, int type);
|
||||||
|
/// <summary>
|
||||||
|
/// دریافت اطلاعات کارگاه و پرسنل برای ایجاد قرارداد
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="workshopId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
AutoExtensionDto AutoExtentionEmployees(long workshopId);
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ using CompanyManagment.App.Contracts.PersonnleCode;
|
|||||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||||
using CompanyManagment.App.Contracts.WorkingHours;
|
using CompanyManagment.App.Contracts.WorkingHours;
|
||||||
using CompanyManagment.App.Contracts.WorkingHoursItems;
|
using CompanyManagment.App.Contracts.WorkingHoursItems;
|
||||||
|
using CompanyManagment.App.Contracts.Workshop.DTOs;
|
||||||
using PersianTools.Core;
|
using PersianTools.Core;
|
||||||
|
|
||||||
namespace CompanyManagment.Application;
|
namespace CompanyManagment.Application;
|
||||||
@@ -600,6 +601,11 @@ public class LeftWorkApplication : ILeftWorkApplication
|
|||||||
return _leftWorkRepository.CheckEditLeftWork(workshopId, employeeId, date.ToGeorgianDateTime(), type);
|
return _leftWorkRepository.CheckEditLeftWork(workshopId, employeeId, date.ToGeorgianDateTime(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AutoExtensionDto AutoExtentionEmployees(long workshopId)
|
||||||
|
{
|
||||||
|
return _leftWorkRepository.AutoExtentionEmployees(workshopId);
|
||||||
|
}
|
||||||
|
|
||||||
#region Pooya
|
#region Pooya
|
||||||
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
|
//این متد ترک کار های کارمند را با فعالیت حضور غیاب یکپارچه می کند
|
||||||
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
|
private void IfEmployeeHasNewLeftWorkDateAddEndDateToRollCallStatus(long employeeId)
|
||||||
|
|||||||
@@ -26,18 +26,18 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
public EditLeftWork GetDetails(long id)
|
public EditLeftWork GetDetails(long id)
|
||||||
{
|
{
|
||||||
return _context.LeftWorkList.Select(x => new EditLeftWork()
|
return _context.LeftWorkList.Select(x => new EditLeftWork()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
||||||
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
||||||
EmployeeFullName = x.EmployeeFullName,
|
EmployeeFullName = x.EmployeeFullName,
|
||||||
WorkshopName = x.WorkshopName,
|
WorkshopName = x.WorkshopName,
|
||||||
WorkshopId = x.WorkshopId,
|
WorkshopId = x.WorkshopId,
|
||||||
EmployeeId = x.EmployeeId
|
EmployeeId = x.EmployeeId
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.FirstOrDefault(x => x.Id == id);
|
.FirstOrDefault(x => x.Id == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,10 +95,10 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
AddYearsPay = x.AddYearsPay,
|
AddYearsPay = x.AddYearsPay,
|
||||||
AddLeavePay = x.AddLeavePay,
|
AddLeavePay = x.AddLeavePay,
|
||||||
JobId = x.JobId,
|
JobId = x.JobId,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}).Where(x=>x.WorkshopId == workshopId);
|
|
||||||
|
}).Where(x => x.WorkshopId == workshopId);
|
||||||
|
|
||||||
return query.ToList();
|
return query.ToList();
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
|
|
||||||
public List<LeftWorkViewModel> search(LeftWorkSearchModel searchModel)
|
public List<LeftWorkViewModel> search(LeftWorkSearchModel searchModel)
|
||||||
{
|
{
|
||||||
|
|
||||||
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
@@ -138,24 +138,24 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
public LeftWorkViewModel CheckoutleftWorkCheck(DateTime contractStart, long workshopId, long employeeId)
|
public LeftWorkViewModel CheckoutleftWorkCheck(DateTime contractStart, long workshopId, long employeeId)
|
||||||
{
|
{
|
||||||
return _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
return _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
||||||
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
||||||
StartWorkDateGr = x.StartWorkDate,
|
StartWorkDateGr = x.StartWorkDate,
|
||||||
LeftWorkDateGr = x.LeftWorkDate,
|
LeftWorkDateGr = x.LeftWorkDate,
|
||||||
EmployeeFullName = x.EmployeeFullName,
|
EmployeeFullName = x.EmployeeFullName,
|
||||||
WorkshopName = x.WorkshopName,
|
WorkshopName = x.WorkshopName,
|
||||||
WorkshopId = x.WorkshopId,
|
WorkshopId = x.WorkshopId,
|
||||||
EmployeeId = x.EmployeeId,
|
EmployeeId = x.EmployeeId,
|
||||||
AddLeavePay = x.AddLeavePay,
|
AddLeavePay = x.AddLeavePay,
|
||||||
AddBonusesPay = x.AddBonusesPay,
|
AddBonusesPay = x.AddBonusesPay,
|
||||||
AddYearsPay = x.AddYearsPay,
|
AddYearsPay = x.AddYearsPay,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId
|
})
|
||||||
|
.FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId
|
||||||
&& contractStart >= x.StartWorkDateGr && contractStart <= x.LeftWorkDateGr);
|
&& contractStart >= x.StartWorkDateGr && contractStart <= x.LeftWorkDateGr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
_context.LeftWorkList.Remove(item);
|
_context.LeftWorkList.Remove(item);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
if (!_context.LeftWorkList.Any(x => x.WorkshopId == item.WorkshopId && x.EmployeeId == item.EmployeeId && item.id != x.id) && HasActiveRollCallStatus(item.WorkshopId, item.EmployeeId))
|
if (!_context.LeftWorkList.Any(x => x.WorkshopId == item.WorkshopId && x.EmployeeId == item.EmployeeId && item.id != x.id) && HasActiveRollCallStatus(item.WorkshopId, item.EmployeeId))
|
||||||
@@ -182,31 +182,31 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
|
|
||||||
public LeftWorkViewModel GetByDateAndWorkshopIdAndEmployeeId(long workshopId, long employeeId, DateTime dateTime)
|
public LeftWorkViewModel GetByDateAndWorkshopIdAndEmployeeId(long workshopId, long employeeId, DateTime dateTime)
|
||||||
{
|
{
|
||||||
var entity = _context.LeftWorkList.FirstOrDefault(x =>
|
var entity = _context.LeftWorkList.FirstOrDefault(x =>
|
||||||
x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
||||||
(x.StartWorkDate <= dateTime && x.LeftWorkDate >= dateTime));
|
(x.StartWorkDate <= dateTime && x.LeftWorkDate >= dateTime));
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new()
|
return new()
|
||||||
{
|
{
|
||||||
EmployeeId = entity.EmployeeId,
|
EmployeeId = entity.EmployeeId,
|
||||||
WorkshopId = entity.WorkshopId,
|
WorkshopId = entity.WorkshopId,
|
||||||
LeftWorkDate = entity.LeftWorkDate.ToFarsi(),
|
LeftWorkDate = entity.LeftWorkDate.ToFarsi(),
|
||||||
HasLeft = entity.HasLeft,
|
HasLeft = entity.HasLeft,
|
||||||
LeftWorkDateGr = entity.LeftWorkDate,
|
LeftWorkDateGr = entity.LeftWorkDate,
|
||||||
StartWorkDateGr = entity.StartWorkDate,
|
StartWorkDateGr = entity.StartWorkDate,
|
||||||
Id = entity.id
|
Id = entity.id
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<long> GetAllEmployeeIdsInWorkshop(long workshopId)
|
public List<long> GetAllEmployeeIdsInWorkshop(long workshopId)
|
||||||
{
|
{
|
||||||
var leftWorks = _context.LeftWorkList
|
var leftWorks = _context.LeftWorkList
|
||||||
.Where(x => x.WorkshopId == workshopId)
|
.Where(x => x.WorkshopId == workshopId)
|
||||||
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
||||||
var insuranceLeftWork = _context.LeftWorkInsuranceList
|
var insuranceLeftWork = _context.LeftWorkInsuranceList
|
||||||
.Where(x => x.WorkshopId == workshopId)
|
.Where(x => x.WorkshopId == workshopId)
|
||||||
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
||||||
@@ -270,7 +270,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
RemoveEmployeeRollCallStatus(workshopId, employeeId);
|
RemoveEmployeeRollCallStatus(workshopId, employeeId);
|
||||||
if (hasLeftWorkInsurance)
|
if (hasLeftWorkInsurance)
|
||||||
return
|
return
|
||||||
op.Succcedded(1, "حذف با موفقیت انجام شد."); //+ "<br/>" + "<span class='text-danger'>" + "کد پرسنلی این شخص به دلیل استفاده در ترک کار بیمه قابل حذف نمی باشد. " + "</span>");
|
op.Succcedded(1, "حذف با موفقیت انجام شد."); //+ "<br/>" + "<span class='text-danger'>" + "کد پرسنلی این شخص به دلیل استفاده در ترک کار بیمه قابل حذف نمی باشد. " + "</span>");
|
||||||
else
|
else
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
}
|
}
|
||||||
@@ -372,7 +372,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
_context.LeftWorkList.RemoveRange(LeftWork);
|
_context.LeftWorkList.RemoveRange(LeftWork);
|
||||||
DateTime left = item2.LeftWorkDate.ToGeorgianDateTime();
|
DateTime left = item2.LeftWorkDate.ToGeorgianDateTime();
|
||||||
var start = item2.StartWorkDate.ToGeorgianDateTime();
|
var start = item2.StartWorkDate.ToGeorgianDateTime();
|
||||||
var leftwork = new LeftWork(left, start, item2.WorkshopId, item2.EmployeeId, command.EmployeeFullName, item2.WorkshopName, item2.JobId, item2.IncludeStatus,item2.AddBonusesPay,item2.AddYearsPay,item2.AddLeavePay, workshopComputeOptions, workshopBonusesOptions);
|
var leftwork = new LeftWork(left, start, item2.WorkshopId, item2.EmployeeId, command.EmployeeFullName, item2.WorkshopName, item2.JobId, item2.IncludeStatus, item2.AddBonusesPay, item2.AddYearsPay, item2.AddLeavePay, workshopComputeOptions, workshopBonusesOptions);
|
||||||
Create(leftwork);
|
Create(leftwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -396,7 +396,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (var item in leftWorkGroups)
|
foreach (var item in leftWorkGroups)
|
||||||
{
|
{
|
||||||
#region PersonelCode
|
#region PersonelCode
|
||||||
@@ -404,7 +404,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
if (commandPersonnelCode != null && commandPersonnelCode.Count > 0)
|
if (commandPersonnelCode != null && commandPersonnelCode.Count > 0)
|
||||||
{
|
{
|
||||||
var personelcode = commandPersonnelCode.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).FirstOrDefault();
|
var personelcode = commandPersonnelCode.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).FirstOrDefault();
|
||||||
if (personelcode != null && personelcode.HasPersonelCode==false)
|
if (personelcode != null && personelcode.HasPersonelCode == false)
|
||||||
{
|
{
|
||||||
if (_context.PersonnelCodeSet.Any(x => x.WorkshopId == item.WorkshopId && x.PersonnelCode == personelcode.PersonnelCode))
|
if (_context.PersonnelCodeSet.Any(x => x.WorkshopId == item.WorkshopId && x.PersonnelCode == personelcode.PersonnelCode))
|
||||||
{
|
{
|
||||||
@@ -419,18 +419,18 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
_context.PersonnelCodeSet.Add(new PersonnelCodeDomain(item.WorkshopId, commandEmployeeId, personelcode.PersonnelCode));
|
_context.PersonnelCodeSet.Add(new PersonnelCodeDomain(item.WorkshopId, commandEmployeeId, personelcode.PersonnelCode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
if (item.LeftWorkViewModels != null && item.LeftWorkViewModels.Count > 0)
|
if (item.LeftWorkViewModels != null && item.LeftWorkViewModels.Count > 0)
|
||||||
{
|
{
|
||||||
bool checkRegister = false;
|
bool checkRegister = false;
|
||||||
|
|
||||||
|
|
||||||
var LeftWorkList = _context.LeftWorkList.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).ToList();
|
var LeftWorkList = _context.LeftWorkList.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).ToList();
|
||||||
|
|
||||||
var removeList = new List<LeftWork>();
|
var removeList = new List<LeftWork>();
|
||||||
|
|
||||||
foreach (var removeItem in LeftWorkList)
|
foreach (var removeItem in LeftWorkList)
|
||||||
{
|
{
|
||||||
if (!item.LeftWorkViewModels.Any(x => x.Id == removeItem.id))
|
if (!item.LeftWorkViewModels.Any(x => x.Id == removeItem.id))
|
||||||
@@ -466,7 +466,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
{
|
{
|
||||||
_context.LeftWorkList.RemoveRange(removeList);
|
_context.LeftWorkList.RemoveRange(removeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
//foreach (var item2 in item.LeftWorkViewModels)
|
//foreach (var item2 in item.LeftWorkViewModels)
|
||||||
//{
|
//{
|
||||||
// var LeftWork = _context.LeftWorkList.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).ToList();
|
// var LeftWork = _context.LeftWorkList.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).ToList();
|
||||||
@@ -483,7 +483,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
|
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
transaction.Commit();
|
transaction.Commit();
|
||||||
op.Succcedded(-1, " ثبت با موفقیت انجام شد. ");
|
op.Succcedded(-1, " ثبت با موفقیت انجام شد. ");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -500,8 +500,8 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
var op = new OperationResult();
|
var op = new OperationResult();
|
||||||
bool hasContracts = false;
|
bool hasContracts = false;
|
||||||
var endDateSend = date.Date.AddDays(-1);
|
var endDateSend = date.Date.AddDays(-1);
|
||||||
if (type==1)
|
if (type == 1)
|
||||||
hasContracts= _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date >= endDateSend) && x.IsActiveString == "true");
|
hasContracts = _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date >= endDateSend) && x.IsActiveString == "true");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
endDateSend = date.Date;
|
endDateSend = date.Date;
|
||||||
@@ -517,23 +517,23 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
|
|
||||||
return op.Failed("در این تاریخ تصفیه حساب ثبت شده است.برای حذف تاریخ ترک کار، ابتدا تصفیه حساب های مربوطه را حذف کنید");
|
return op.Failed("در این تاریخ تصفیه حساب ثبت شده است.برای حذف تاریخ ترک کار، ابتدا تصفیه حساب های مربوطه را حذف کنید");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
}
|
}
|
||||||
public OperationResult CheckEditLeftWork(long workshopId, long employeeId, DateTime date, int type)
|
public OperationResult CheckEditLeftWork(long workshopId, long employeeId, DateTime date, int type)
|
||||||
{
|
{
|
||||||
var op = new OperationResult();
|
var op = new OperationResult();
|
||||||
bool hasContracts = false;
|
bool hasContracts = false;
|
||||||
|
|
||||||
|
|
||||||
if (type == 1)
|
if (type == 1)
|
||||||
{
|
{
|
||||||
hasContracts= _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date>= date) && x.IsActiveString == "true");
|
hasContracts = _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date >= date) && x.IsActiveString == "true");
|
||||||
if(hasContracts)
|
if (hasContracts)
|
||||||
return op.Failed("لطفا ابتدا تصفیه حساب های آتی را حذف نمایید");
|
return op.Failed("لطفا ابتدا تصفیه حساب های آتی را حذف نمایید");
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var LeftDay = date.Date;
|
var LeftDay = date.Date;
|
||||||
@@ -556,16 +556,16 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
var LastDayContract = _context.CheckoutSet.Any(x =>
|
var LastDayContract = _context.CheckoutSet.Any(x =>
|
||||||
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.IsActiveString == "true" &&
|
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.IsActiveString == "true" &&
|
||||||
x.ContractEnd.Date > lastDay.Date);
|
x.ContractEnd.Date > lastDay.Date);
|
||||||
if(LastDayContract)
|
if (LastDayContract)
|
||||||
return op.Failed("AfterContracts");
|
return op.Failed("AfterContracts");
|
||||||
// var contract = _context.Contracts.Where(x => x.EmployeeId == employeeId && x.WorkshopIds == workshopId && x.IsActiveString == "true").OrderByDescending(x=>x.ContarctStart).FirstOrDefault();
|
// var contract = _context.Contracts.Where(x => x.EmployeeId == employeeId && x.WorkshopIds == workshopId && x.IsActiveString == "true").OrderByDescending(x=>x.ContarctStart).FirstOrDefault();
|
||||||
|
|
||||||
//if (contract != null)
|
//if (contract != null)
|
||||||
//{
|
//{
|
||||||
|
|
||||||
// if ((contract.ContarctStart.Date <= endDateSend.Date && contract.ContractEnd.Date >= endDateSend.Date))
|
// if ((contract.ContarctStart.Date <= endDateSend.Date && contract.ContractEnd.Date >= endDateSend.Date))
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// var checkout = _context.CheckoutSet.Where(x =>
|
// var checkout = _context.CheckoutSet.Where(x =>
|
||||||
// x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
|
// x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
|
||||||
// (x.ContractStart.Date <= date.Date && x.ContractEnd.Date >= date.Date)).FirstOrDefault();
|
// (x.ContractStart.Date <= date.Date && x.ContractEnd.Date >= date.Date)).FirstOrDefault();
|
||||||
@@ -594,7 +594,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
// //}
|
// //}
|
||||||
//}
|
//}
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return op.Succcedded();
|
return op.Succcedded();
|
||||||
@@ -647,7 +647,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
|
|
||||||
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
|
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
|
||||||
{
|
{
|
||||||
var leftWork =await _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
var leftWork = await _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
|
||||||
.OrderByDescending(x => x.StartWorkDate).FirstOrDefaultAsync();
|
.OrderByDescending(x => x.StartWorkDate).FirstOrDefaultAsync();
|
||||||
return leftWork;
|
return leftWork;
|
||||||
}
|
}
|
||||||
@@ -658,9 +658,9 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
.Select(x => x.EmployeeId)
|
.Select(x => x.EmployeeId)
|
||||||
.Except([5976]).ToList();
|
.Except([5976]).ToList();
|
||||||
var clientTemps = _context.EmployeeClientTemps.Where(x => x.WorkshopId == searchModel.WorkshopId)
|
var clientTemps = _context.EmployeeClientTemps.Where(x => x.WorkshopId == searchModel.WorkshopId)
|
||||||
.Select(x => x.EmployeeId);
|
.Select(x => x.EmployeeId);
|
||||||
|
|
||||||
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
||||||
{
|
{
|
||||||
Id = x.id,
|
Id = x.id,
|
||||||
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
||||||
@@ -678,7 +678,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
JobName = _context.Jobs.FirstOrDefault(j => j.id == x.JobId).JobName
|
JobName = _context.Jobs.FirstOrDefault(j => j.id == x.JobId).JobName
|
||||||
|
|
||||||
|
|
||||||
}).Where(x=> !vipGroup.Contains(x.EmployeeId) && !clientTemps.Contains(x.EmployeeId));
|
}).Where(x => !vipGroup.Contains(x.EmployeeId) && !clientTemps.Contains(x.EmployeeId));
|
||||||
if (searchModel.WorkshopId != 0 && searchModel.EmployeeId != 0)
|
if (searchModel.WorkshopId != 0 && searchModel.EmployeeId != 0)
|
||||||
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
||||||
if (searchModel.EmployeeId != 0 && searchModel.WorkshopId == 0)
|
if (searchModel.EmployeeId != 0 && searchModel.WorkshopId == 0)
|
||||||
@@ -698,7 +698,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
}
|
}
|
||||||
private void RemoveEmployeeRollCallStatus(long workshopId, long employeeId)
|
private void RemoveEmployeeRollCallStatus(long workshopId, long employeeId)
|
||||||
{
|
{
|
||||||
var entity = _context.RollCallEmployees.Include(x=>x.EmployeesStatus).FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
var entity = _context.RollCallEmployees.Include(x => x.EmployeesStatus).FirstOrDefault(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId);
|
||||||
|
|
||||||
if (entity == null)
|
if (entity == null)
|
||||||
return;
|
return;
|
||||||
@@ -727,7 +727,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
|
|
||||||
}
|
}
|
||||||
//_context.RollCallEmployees.Remove(entity);
|
//_context.RollCallEmployees.Remove(entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -738,44 +738,112 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
{
|
{
|
||||||
if (workshopId == 0)
|
if (workshopId == 0)
|
||||||
return new AutoExtensionDto();
|
return new AutoExtensionDto();
|
||||||
|
var query = _context.LeftWorkList
|
||||||
|
.Include(x => x.Employee)
|
||||||
|
.Include(x => x.Workshop)
|
||||||
|
.Where(x => x.WorkshopId == workshopId)
|
||||||
|
|
||||||
|
// Left Join با PersonnelCodeSet
|
||||||
|
.GroupJoin(_context.PersonnelCodeSet.Where(p => p.WorkshopId == workshopId),
|
||||||
|
leftList => leftList.EmployeeId,
|
||||||
|
personnelCode => personnelCode.EmployeeId,
|
||||||
|
(leftList, personnelCodes) => new { leftList, personnelCodes })
|
||||||
|
.SelectMany(
|
||||||
|
x => x.personnelCodes.DefaultIfEmpty(),
|
||||||
|
(x, personnelCode) => new { x.leftList, personnelCode })
|
||||||
|
|
||||||
|
// Left Join با Jobs
|
||||||
|
.GroupJoin(_context.Jobs,
|
||||||
|
x => x.leftList.JobId,
|
||||||
|
job => job.id,
|
||||||
|
(x, jobs) => new { x.leftList, x.personnelCode, jobs })
|
||||||
|
.SelectMany(
|
||||||
|
x => x.jobs.DefaultIfEmpty(),
|
||||||
|
(x, job) => new { x.leftList, x.personnelCode, job })
|
||||||
|
|
||||||
|
// Left Join با EmployeeComputeOptionsSet
|
||||||
|
.GroupJoin(_context.EmployeeComputeOptionsSet.Where(o => o.WorkshopId == workshopId),
|
||||||
|
x => x.leftList.EmployeeId,
|
||||||
|
option => option.EmployeeId,
|
||||||
|
(x, options) => new { x.leftList, x.personnelCode, x.job, options })
|
||||||
|
.SelectMany(
|
||||||
|
x => x.options.DefaultIfEmpty(),
|
||||||
|
(x, option) => new { x.leftList, x.personnelCode, x.job, option })
|
||||||
|
|
||||||
|
.Select(result => new AutoExtensionEmployeeListDto
|
||||||
|
{
|
||||||
|
EmployeeId = result.leftList.EmployeeId,
|
||||||
|
EmployeeName = result.leftList.EmployeeFullName,
|
||||||
|
PersonnelCode = result.personnelCode != null ? result.personnelCode.PersonnelCode : 0,
|
||||||
|
JobType = result.job != null ? result.job.JobName : "نامشخص",
|
||||||
|
JobTypeId = result.job != null ? result.job.id : 0,
|
||||||
|
EmployeeHasCreateContract = result.option != null
|
||||||
|
? result.option.CreateContract
|
||||||
|
: result.leftList.Workshop.CreateContract
|
||||||
|
}).GroupBy(x => x.EmployeeId)
|
||||||
|
.Select(g => g.First())
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
|
||||||
var query = _context.LeftWorkList.Include(x => x.Employee).Include(w=>w.Workshop)
|
|
||||||
.Where(x => x.WorkshopId == workshopId)
|
|
||||||
.Join(_context.PersonnelCodeSet.AsSplitQuery().Where(p => p.WorkshopId == workshopId),
|
|
||||||
leftList => leftList.EmployeeId,
|
|
||||||
personnelCode => personnelCode.EmployeeId,
|
|
||||||
(leftList, personnelCode) =>
|
|
||||||
new { leftList, personnelCode })
|
|
||||||
.Join(_context.Jobs,
|
|
||||||
left => left.leftList.JobId,
|
|
||||||
job => job.id,
|
|
||||||
(left, job) => new { left, job })
|
|
||||||
.Join(_context.EmployeeComputeOptionsSet.Where(o=>o.WorkshopId == workshopId),
|
|
||||||
leftResult => leftResult.left.leftList.EmployeeId,
|
|
||||||
options => options.EmployeeId,
|
|
||||||
(leftResult, options) => new { leftResult, options })
|
|
||||||
.Select(result => new AutoExtensionEmployeeListDto()
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
EmployeeId = result.leftResult.left.leftList.EmployeeId,
|
//var query = _context.LeftWorkList.Include(x => x.Employee).Include(w => w.Workshop)
|
||||||
EmployeeName = result.leftResult.left.leftList.EmployeeFullName,
|
// .Where(x => x.WorkshopId == workshopId)
|
||||||
PersonnelCode = result.leftResult.left.personnelCode == null ? 0 : result.leftResult.left.personnelCode.PersonnelCode,
|
// .Join(_context.PersonnelCodeSet.AsSplitQuery().Where(p => p.WorkshopId == workshopId),
|
||||||
|
// leftList => leftList.EmployeeId,
|
||||||
JobType = result.leftResult.job.JobName,
|
// personnelCode => personnelCode.EmployeeId,
|
||||||
JobTypeId = result.leftResult.job.id,
|
// (leftList, personnelCode) =>
|
||||||
EmployeeHasCreateContract = result.options == null ? result.leftResult.left.leftList.Workshop.CreateContract : result.options.CreateContract
|
// new { leftList, personnelCode })
|
||||||
|
// .Join(_context.Jobs,
|
||||||
|
// left => left.leftList.JobId,
|
||||||
|
// job => job.id,
|
||||||
|
// (left, job) => new { left, job })
|
||||||
|
// .Join(_context.EmployeeComputeOptionsSet.Where(o => o.WorkshopId == workshopId),
|
||||||
|
// leftResult => leftResult.left.leftList.EmployeeId,
|
||||||
|
// options => options.EmployeeId,
|
||||||
|
// (leftResult, options) => new { leftResult, options })
|
||||||
|
// .Select(result => new AutoExtensionEmployeeListDto()
|
||||||
|
// {
|
||||||
|
|
||||||
|
|
||||||
}).ToList();
|
// EmployeeId = result.leftResult.left.leftList.EmployeeId,
|
||||||
|
// EmployeeName = result.leftResult.left.leftList.EmployeeFullName,
|
||||||
|
// PersonnelCode = result.leftResult.left.personnelCode == null ? 0 : result.leftResult.left.personnelCode.PersonnelCode,
|
||||||
|
|
||||||
|
// JobType = result.leftResult.job.JobName,
|
||||||
|
// JobTypeId = result.leftResult.job.id,
|
||||||
|
// EmployeeHasCreateContract = result.options == null ? result.leftResult.left.leftList.Workshop.CreateContract : result.options.CreateContract
|
||||||
|
|
||||||
|
|
||||||
|
// }).ToList();
|
||||||
|
var result = new AutoExtensionDto();
|
||||||
var workshop = _context.Workshops.FirstOrDefault(x => x.id == workshopId);
|
var workshop = _context.Workshops.FirstOrDefault(x => x.id == workshopId);
|
||||||
|
var employerId = _context.WorkshopEmployers.FirstOrDefault(x => x.WorkshopId == workshopId)!.EmployerId;
|
||||||
|
|
||||||
if (query.Count > 0 && workshop != null)
|
var employer = _context.Employers.FirstOrDefault(x => x.id == employerId);
|
||||||
|
var employerWarning = false;
|
||||||
|
var employerWarningMessage = "";
|
||||||
|
|
||||||
|
|
||||||
|
if (employer != null && employer.IsLegal == "حقوقی")
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(employer.NationalId) || string.IsNullOrWhiteSpace(employer.RegisterId))
|
||||||
var result = new AutoExtensionDto()
|
{
|
||||||
|
employerWarning = true;
|
||||||
|
employerWarningMessage = "شناسه ملی ، شماره ثبت کارفرمای این کارگاه را بررسی کنید";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(employer.Nationalcode) || string.IsNullOrWhiteSpace(employer.Gender))
|
||||||
|
{
|
||||||
|
employerWarning = true;
|
||||||
|
employerWarningMessage = "کد ملی ، جنسیت کارفرمای این کارگاه را بررسی گنید";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (query.Any() && workshop != null)
|
||||||
|
{
|
||||||
|
|
||||||
|
result = new AutoExtensionDto()
|
||||||
{
|
{
|
||||||
WorkshopId = workshopId,
|
WorkshopId = workshopId,
|
||||||
HavingPersonel = true,
|
HavingPersonel = true,
|
||||||
@@ -783,7 +851,10 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
ArchiveCode = workshop.ArchiveCode,
|
ArchiveCode = workshop.ArchiveCode,
|
||||||
WAddress1 = workshop.Address,
|
WAddress1 = workshop.Address,
|
||||||
CreateContract = workshop.CreateContract,
|
CreateContract = workshop.CreateContract,
|
||||||
EmployeeList = query.Select(x=> new AutoExtensionEmployeeListDto()
|
EmployerId = employerId,
|
||||||
|
EmployerWarning = employerWarning,
|
||||||
|
EmployerWarningMessage = employerWarningMessage,
|
||||||
|
EmployeeList = query.Select(x => new AutoExtensionEmployeeListDto()
|
||||||
{
|
{
|
||||||
EmployeeId = x.EmployeeId,
|
EmployeeId = x.EmployeeId,
|
||||||
EmployeeName = x.EmployeeName,
|
EmployeeName = x.EmployeeName,
|
||||||
@@ -791,16 +862,16 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|||||||
JobType = x.JobType,
|
JobType = x.JobType,
|
||||||
JobTypeId = x.JobTypeId,
|
JobTypeId = x.JobTypeId,
|
||||||
EmployeeHasCreateContract = x.EmployeeHasCreateContract
|
EmployeeHasCreateContract = x.EmployeeHasCreateContract
|
||||||
|
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
EmployeeSelectList = new SelectList(query.Where(x=>x.EmployeeHasCreateContract), "EmployeeId", "EmployeeName ")
|
EmployeeSelectList = new SelectList(query.Where(x => x.EmployeeHasCreateContract), "EmployeeId", "EmployeeName ")
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var result = new AutoExtensionDto()
|
result = new AutoExtensionDto()
|
||||||
{
|
{
|
||||||
WorkshopId = workshopId,
|
WorkshopId = workshopId,
|
||||||
HavingPersonel = false,
|
HavingPersonel = false,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Diagnostics;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using _0_Framework.Application;
|
using _0_Framework.Application;
|
||||||
using Company.Domain.ContractAgg;
|
using Company.Domain.ContractAgg;
|
||||||
@@ -82,6 +83,8 @@ public class AutoExtensionModel : PageModel
|
|||||||
|
|
||||||
public void OnGet(long id)
|
public void OnGet(long id)
|
||||||
{
|
{
|
||||||
|
var watch = new Stopwatch();
|
||||||
|
watch.Start();
|
||||||
var selctedWorkshop = _workshopApplication.GetDetails(id);
|
var selctedWorkshop = _workshopApplication.GetDetails(id);
|
||||||
workshopName = selctedWorkshop?.WorkshopFullName;
|
workshopName = selctedWorkshop?.WorkshopFullName;
|
||||||
YearlyList =
|
YearlyList =
|
||||||
@@ -159,6 +162,12 @@ public class AutoExtensionModel : PageModel
|
|||||||
WorkshopAddress1 = selctedWorkshop.Address
|
WorkshopAddress1 = selctedWorkshop.Address
|
||||||
}).OrderBy(x => x.PersonnelCode).ToList();
|
}).OrderBy(x => x.PersonnelCode).ToList();
|
||||||
EmployeeSelectList = new SelectList(personelList, "EmployeeId", "EmployeeFullName");
|
EmployeeSelectList = new SelectList(personelList, "EmployeeId", "EmployeeFullName");
|
||||||
|
|
||||||
|
Console.WriteLine(" old : " + watch.Elapsed);
|
||||||
|
watch.Reset();
|
||||||
|
watch.Start();
|
||||||
|
var res = _leftWorkApplication.AutoExtentionEmployees(id);
|
||||||
|
Console.WriteLine(" new : " + watch.Elapsed);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user