mahan changed

This commit is contained in:
SamSys
2025-03-13 00:04:47 +03:30
parent 6b543b4627
commit a60e0bd211
4 changed files with 31 additions and 6 deletions

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.Domain;
using CompanyManagment.App.Contracts.LeftWork;
@@ -39,5 +40,7 @@ public interface ILeftWorkRepository : IRepository<long, LeftWork>
bool IsEmployeeWorkingInDates(long employeeId, long workshopId, List<(DateTime, DateTime)> dates);
List<LeftWorkViewModel> GetByWorkshopIdInDates(long workshopId, DateTime startDateGr, DateTime endDateGr);
LeftWorkViewModel GetByWorkshopIdEmployeeIdInDates(long workshopId, long employeeId, DateTime start, DateTime end);
#endregion
#endregion
Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId);
}

View File

@@ -7,6 +7,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Company.Domain.RollCallServiceAgg;
using System.Globalization;
namespace CompanyManagment.Application
@@ -35,7 +36,7 @@ namespace CompanyManagment.Application
return op.Failed("کارمند مجاز نیست");
if (!_leftWorkRepository.Exists(x => x.EmployeeId == rollCallEmployee.EmployeeId && x.WorkshopId == rollCallEmployee.WorkshopId &&
x.LeftWorkDate.Date > DateTime.Now.Date && x.StartWorkDate.Date <= DateTime.Now.Date))
(x.LeftWorkDate.Date > DateTime.Now.Date && x.StartWorkDate.Date <= DateTime.Now.Date) || x.StartWorkDate >= DateTime.Today))
return op.Failed("کارمند در کارگاه شروع به کار نکرده است");
if (_employeeRollCallStatusRepository.Exists(y =>
@@ -50,7 +51,21 @@ namespace CompanyManagment.Application
}
else
{
RollCallEmployeeStatus newRecord = new(rollCallEmployee.id, DateTime.Now.Date);
var pc = new PersianCalendar();
var startStatus = DateTime.Today;
LeftWork leftWork =
_leftWorkRepository.GetLastLeftWork(rollCallEmployee.EmployeeId, rollCallEmployee.WorkshopId).GetAwaiter().GetResult();
if (leftWork.StartWorkDate > DateTime.Today)
startStatus = leftWork.StartWorkDate;
//else if(pc.GetMonth(DateTime.Today) == pc.GetMonth(leftWork.StartWorkDate))
//{
// startStatus = new DateTime(pc.GetYear(leftWork.StartWorkDate), pc.GetMonth(leftWork.StartWorkDate),
// 1, pc);
//}
RollCallEmployeeStatus newRecord = new(rollCallEmployee.id, startStatus);
_employeeRollCallStatusRepository.Create(newRecord);
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using Company.Domain.LeftWorkAgg;
@@ -675,4 +676,10 @@ public class LeftWorkRepository : RepositoryBase<long, LeftWork>, ILeftWorkRepos
}
#endregion
public async Task<LeftWork> GetLastLeftWork(long employeeId, long workshopId)
{
var leftWork = await _context.LeftWorkList.Where(x => x.WorkshopId == workshopId && x.EmployeeId == employeeId)
.OrderByDescending(x => x.StartWorkDate).FirstOrDefaultAsync();
return leftWork;
}
}

View File

@@ -95,15 +95,15 @@ public class RollCallEmployeeRepository : RepositoryBase<long, RollCallEmployee>
var rawQuery = employeeQuery.Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
.Where(x => x.LeftWorks.Any(y =>
y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
y.LeftWorkDate > dateNow) ||
(y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
y.LeftWorkDate > dateNow) || y.StartWorkDate > dateNow) ||
x.LeftWorkInsurances.Any(y =>
y.WorkshopId == command.WorkshopId && y.StartWorkDate <= dateNow &&
(y.LeftWorkDate > dateNow || y.LeftWorkDate == null))).OrderByDescending(x => x.id)
.Select(x => new
{
Id = x.id,
FullName =x.FName +" "+x.LName,
FullName = x.FName + " " + x.LName,
x.NationalCode,
}).AsSplitQuery();