|
|
|
|
@@ -26,18 +26,18 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
public EditLeftWork GetDetails(long id)
|
|
|
|
|
{
|
|
|
|
|
return _context.LeftWorkList.Select(x => new EditLeftWork()
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
|
|
|
|
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
|
|
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
|
|
|
WorkshopName = x.WorkshopName,
|
|
|
|
|
WorkshopId = x.WorkshopId,
|
|
|
|
|
EmployeeId = x.EmployeeId
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
|
|
|
|
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
|
|
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
|
|
|
WorkshopName = x.WorkshopName,
|
|
|
|
|
WorkshopId = x.WorkshopId,
|
|
|
|
|
EmployeeId = x.EmployeeId
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
.FirstOrDefault(x => x.Id == id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -95,10 +95,10 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
AddYearsPay = x.AddYearsPay,
|
|
|
|
|
AddLeavePay = x.AddLeavePay,
|
|
|
|
|
JobId = x.JobId,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).Where(x=>x.WorkshopId == workshopId);
|
|
|
|
|
|
|
|
|
|
}).Where(x => x.WorkshopId == workshopId);
|
|
|
|
|
|
|
|
|
|
return query.ToList();
|
|
|
|
|
}
|
|
|
|
|
@@ -106,7 +106,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
|
|
|
|
|
public List<LeftWorkViewModel> search(LeftWorkSearchModel searchModel)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var query = _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
@@ -138,24 +138,24 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
public LeftWorkViewModel CheckoutleftWorkCheck(DateTime contractStart, long workshopId, long employeeId)
|
|
|
|
|
{
|
|
|
|
|
return _context.LeftWorkList.Select(x => new LeftWorkViewModel()
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
|
|
|
|
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
|
|
|
|
StartWorkDateGr = x.StartWorkDate,
|
|
|
|
|
LeftWorkDateGr = x.LeftWorkDate,
|
|
|
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
|
|
|
WorkshopName = x.WorkshopName,
|
|
|
|
|
WorkshopId = x.WorkshopId,
|
|
|
|
|
EmployeeId = x.EmployeeId,
|
|
|
|
|
AddLeavePay = x.AddLeavePay,
|
|
|
|
|
AddBonusesPay = x.AddBonusesPay,
|
|
|
|
|
AddYearsPay = x.AddYearsPay,
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
Id = x.id,
|
|
|
|
|
LeftWorkDate = x.LeftWorkDate.ToFarsi(),
|
|
|
|
|
StartWorkDate = x.StartWorkDate.ToFarsi(),
|
|
|
|
|
StartWorkDateGr = x.StartWorkDate,
|
|
|
|
|
LeftWorkDateGr = x.LeftWorkDate,
|
|
|
|
|
EmployeeFullName = x.EmployeeFullName,
|
|
|
|
|
WorkshopName = x.WorkshopName,
|
|
|
|
|
WorkshopId = x.WorkshopId,
|
|
|
|
|
EmployeeId = x.EmployeeId,
|
|
|
|
|
AddLeavePay = x.AddLeavePay,
|
|
|
|
|
AddBonusesPay = x.AddBonusesPay,
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -166,7 +166,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
if (item != null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_context.LeftWorkList.Remove(item);
|
|
|
|
|
_context.SaveChanges();
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
var entity = _context.LeftWorkList.FirstOrDefault(x =>
|
|
|
|
|
x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
|
|
|
|
(x.StartWorkDate <= dateTime && x.LeftWorkDate >= dateTime));
|
|
|
|
|
if (entity == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
EmployeeId = entity.EmployeeId,
|
|
|
|
|
WorkshopId = entity.WorkshopId,
|
|
|
|
|
LeftWorkDate = entity.LeftWorkDate.ToFarsi(),
|
|
|
|
|
HasLeft = entity.HasLeft,
|
|
|
|
|
LeftWorkDateGr = entity.LeftWorkDate,
|
|
|
|
|
StartWorkDateGr = entity.StartWorkDate,
|
|
|
|
|
Id = entity.id
|
|
|
|
|
var entity = _context.LeftWorkList.FirstOrDefault(x =>
|
|
|
|
|
x.WorkshopId == workshopId && x.EmployeeId == employeeId &&
|
|
|
|
|
(x.StartWorkDate <= dateTime && x.LeftWorkDate >= dateTime));
|
|
|
|
|
if (entity == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
return new()
|
|
|
|
|
{
|
|
|
|
|
EmployeeId = entity.EmployeeId,
|
|
|
|
|
WorkshopId = entity.WorkshopId,
|
|
|
|
|
LeftWorkDate = entity.LeftWorkDate.ToFarsi(),
|
|
|
|
|
HasLeft = entity.HasLeft,
|
|
|
|
|
LeftWorkDateGr = entity.LeftWorkDate,
|
|
|
|
|
StartWorkDateGr = entity.StartWorkDate,
|
|
|
|
|
Id = entity.id
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<long> GetAllEmployeeIdsInWorkshop(long workshopId)
|
|
|
|
|
{
|
|
|
|
|
var leftWorks = _context.LeftWorkList
|
|
|
|
|
.Where(x => x.WorkshopId == workshopId)
|
|
|
|
|
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
|
|
|
|
var leftWorks = _context.LeftWorkList
|
|
|
|
|
.Where(x => x.WorkshopId == workshopId)
|
|
|
|
|
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
|
|
|
|
var insuranceLeftWork = _context.LeftWorkInsuranceList
|
|
|
|
|
.Where(x => x.WorkshopId == workshopId)
|
|
|
|
|
.GroupBy(x => x.EmployeeId).Select(x => x.Key).ToList();
|
|
|
|
|
@@ -270,7 +270,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
RemoveEmployeeRollCallStatus(workshopId, employeeId);
|
|
|
|
|
if (hasLeftWorkInsurance)
|
|
|
|
|
return
|
|
|
|
|
op.Succcedded(1, "حذف با موفقیت انجام شد."); //+ "<br/>" + "<span class='text-danger'>" + "کد پرسنلی این شخص به دلیل استفاده در ترک کار بیمه قابل حذف نمی باشد. " + "</span>");
|
|
|
|
|
op.Succcedded(1, "حذف با موفقیت انجام شد."); //+ "<br/>" + "<span class='text-danger'>" + "کد پرسنلی این شخص به دلیل استفاده در ترک کار بیمه قابل حذف نمی باشد. " + "</span>");
|
|
|
|
|
else
|
|
|
|
|
return op.Succcedded();
|
|
|
|
|
}
|
|
|
|
|
@@ -372,7 +372,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
_context.LeftWorkList.RemoveRange(LeftWork);
|
|
|
|
|
DateTime left = item2.LeftWorkDate.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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -396,7 +396,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var item in leftWorkGroups)
|
|
|
|
|
{
|
|
|
|
|
#region PersonelCode
|
|
|
|
|
@@ -404,7 +404,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
if (commandPersonnelCode != null && commandPersonnelCode.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
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))
|
|
|
|
|
{
|
|
|
|
|
@@ -419,18 +419,18 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
_context.PersonnelCodeSet.Add(new PersonnelCodeDomain(item.WorkshopId, commandEmployeeId, personelcode.PersonnelCode));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
if (item.LeftWorkViewModels != null && item.LeftWorkViewModels.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
bool checkRegister = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var LeftWorkList = _context.LeftWorkList.Where(x => x.EmployeeId == commandEmployeeId && x.WorkshopId == item.WorkshopId).ToList();
|
|
|
|
|
|
|
|
|
|
var removeList = new List<LeftWork>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var removeItem in LeftWorkList)
|
|
|
|
|
{
|
|
|
|
|
if (!item.LeftWorkViewModels.Any(x => x.Id == removeItem.id))
|
|
|
|
|
@@ -466,7 +466,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
{
|
|
|
|
|
_context.LeftWorkList.RemoveRange(removeList);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//foreach (var item2 in item.LeftWorkViewModels)
|
|
|
|
|
//{
|
|
|
|
|
// 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();
|
|
|
|
|
transaction.Commit();
|
|
|
|
|
op.Succcedded(-1, " ثبت با موفقیت انجام شد. ");
|
|
|
|
|
op.Succcedded(-1, " ثبت با موفقیت انجام شد. ");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
@@ -500,8 +500,8 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
var op = new OperationResult();
|
|
|
|
|
bool hasContracts = false;
|
|
|
|
|
var endDateSend = date.Date.AddDays(-1);
|
|
|
|
|
if (type==1)
|
|
|
|
|
hasContracts= _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date >= endDateSend) && x.IsActiveString == "true");
|
|
|
|
|
if (type == 1)
|
|
|
|
|
hasContracts = _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date >= endDateSend) && x.IsActiveString == "true");
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
endDateSend = date.Date;
|
|
|
|
|
@@ -517,23 +517,23 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
|
|
|
|
|
return op.Failed("در این تاریخ تصفیه حساب ثبت شده است.برای حذف تاریخ ترک کار، ابتدا تصفیه حساب های مربوطه را حذف کنید");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
bool hasContracts = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == 1)
|
|
|
|
|
{
|
|
|
|
|
hasContracts= _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date>= date) && x.IsActiveString == "true");
|
|
|
|
|
if(hasContracts)
|
|
|
|
|
hasContracts = _context.CheckoutSet.Any(x => x.EmployeeId == employeeId && x.WorkshopId == workshopId && (x.ContractStart.Date >= date) && x.IsActiveString == "true");
|
|
|
|
|
if (hasContracts)
|
|
|
|
|
return op.Failed("لطفا ابتدا تصفیه حساب های آتی را حذف نمایید");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var LeftDay = date.Date;
|
|
|
|
|
@@ -556,16 +556,16 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
var LastDayContract = _context.CheckoutSet.Any(x =>
|
|
|
|
|
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.IsActiveString == "true" &&
|
|
|
|
|
x.ContractEnd.Date > lastDay.Date);
|
|
|
|
|
if(LastDayContract)
|
|
|
|
|
if (LastDayContract)
|
|
|
|
|
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.ContarctStart.Date <= endDateSend.Date && contract.ContractEnd.Date >= endDateSend.Date))
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// var checkout = _context.CheckoutSet.Where(x =>
|
|
|
|
|
// x.EmployeeId == employeeId && x.WorkshopId == workshopId &&
|
|
|
|
|
// (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();
|
|
|
|
|
@@ -647,7 +647,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
return leftWork;
|
|
|
|
|
}
|
|
|
|
|
@@ -658,9 +658,9 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
.Select(x => x.EmployeeId)
|
|
|
|
|
.Except([5976]).ToList();
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).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)
|
|
|
|
|
query = query.Where(x => x.WorkshopId == searchModel.WorkshopId && x.EmployeeId == searchModel.EmployeeId);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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)
|
|
|
|
|
return;
|
|
|
|
|
@@ -727,7 +727,7 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//_context.RollCallEmployees.Remove(entity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
@@ -738,44 +738,112 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
{
|
|
|
|
|
if (workshopId == 0)
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
|
|
//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()
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).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 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 == "حقوقی")
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
var result = new AutoExtensionDto()
|
|
|
|
|
if (string.IsNullOrWhiteSpace(employer.NationalId) || string.IsNullOrWhiteSpace(employer.RegisterId))
|
|
|
|
|
{
|
|
|
|
|
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,
|
|
|
|
|
HavingPersonel = true,
|
|
|
|
|
@@ -783,7 +851,10 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
ArchiveCode = workshop.ArchiveCode,
|
|
|
|
|
WAddress1 = workshop.Address,
|
|
|
|
|
CreateContract = workshop.CreateContract,
|
|
|
|
|
EmployeeList = query.Select(x=> new AutoExtensionEmployeeListDto()
|
|
|
|
|
EmployerId = employerId,
|
|
|
|
|
EmployerWarning = employerWarning,
|
|
|
|
|
EmployerWarningMessage = employerWarningMessage,
|
|
|
|
|
EmployeeList = query.Select(x => new AutoExtensionEmployeeListDto()
|
|
|
|
|
{
|
|
|
|
|
EmployeeId = x.EmployeeId,
|
|
|
|
|
EmployeeName = x.EmployeeName,
|
|
|
|
|
@@ -791,16 +862,16 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
|
|
|
|
|
JobType = x.JobType,
|
|
|
|
|
JobTypeId = x.JobTypeId,
|
|
|
|
|
EmployeeHasCreateContract = x.EmployeeHasCreateContract
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList(),
|
|
|
|
|
EmployeeSelectList = new SelectList(query.Where(x=>x.EmployeeHasCreateContract), "EmployeeId", "EmployeeName ")
|
|
|
|
|
|
|
|
|
|
EmployeeSelectList = new SelectList(query.Where(x => x.EmployeeHasCreateContract), "EmployeeId", "EmployeeName ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var result = new AutoExtensionDto()
|
|
|
|
|
result = new AutoExtensionDto()
|
|
|
|
|
{
|
|
|
|
|
WorkshopId = workshopId,
|
|
|
|
|
HavingPersonel = false,
|
|
|
|
|
|