Compare commits

...

5 Commits

Author SHA1 Message Date
e0bdde8264 fix reward paginate problem 2025-03-25 17:30:45 +03:30
67111fff6b add filter for create reward 2025-03-25 17:22:14 +03:30
ef4c9ee201 fix rollcall mandatory repository 2025-03-25 17:01:30 +03:30
b621a709aa add reward creation method - fix create left work tremp 2025-03-25 15:36:41 +03:30
SamSys
1f96f0bc87 Merge From CustomizeCheckoutBuf To master 2025-03-25 03:39:45 +03:30
5 changed files with 254 additions and 217 deletions

View File

@@ -1695,8 +1695,8 @@ CreateWorkingHoursTemp command, bool holidayWorking)
#endregion
List<RollCallViewModel> rollCallResult = _context.RollCalls.Where(x =>
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.StartDate.Value.Date >= contractStart.Date &&
x.StartDate.Value.Date <= contractEnd.Date && x.EndDate != null)
x.EmployeeId == employeeId && x.WorkshopId == workshopId && x.ShiftDate.Date >= contractStart.Date &&
x.ShiftDate.Date <= contractEnd.Date && x.EndDate != null)
.Select(x => new RollCallViewModel()
{
StartDate = x.StartDate,

View File

@@ -13,10 +13,10 @@
<button type="submit">Upload</button>
</form> *@
@* <form asp-page-handler="ShiftDate" id="8" method="post">
<form asp-page-handler="ShiftDate" id="8" method="post">
<button type="submit">افزودن شیفت دیت</button>
</form> *@
</form>
<form asp-page-handler="ShiftDateNew" id="9" method="post">

View File

@@ -1,5 +1,6 @@
using AccountManagement.Domain.AccountLeftWorkAgg;
using AccountMangement.Infrastructure.EFCore;
using Company.Domain.RewardAgg;
using Company.Domain.RollCallAgg.DomainService;
using CompanyManagment.App.Contracts.AndroidApkVersion;
using CompanyManagment.EFCore;
@@ -10,237 +11,266 @@ using Microsoft.EntityFrameworkCore;
namespace ServiceHost.Areas.AdminNew.Pages.Company.AndroidApk
{
[Authorize]
public class IndexModel : PageModel
{
private readonly IAndroidApkVersionApplication _application;
private readonly IRollCallDomainService _rollCallDomainService;
private readonly CompanyContext _context;
private readonly AccountContext _accountContext;
[Authorize]
public class IndexModel : PageModel
{
private readonly IAndroidApkVersionApplication _application;
private readonly IRollCallDomainService _rollCallDomainService;
private readonly CompanyContext _context;
private readonly AccountContext _accountContext;
[BindProperty]
public IFormFile File { get; set; }
[BindProperty]
public IFormFile File { get; set; }
public IndexModel(IAndroidApkVersionApplication application, IRollCallDomainService rollCallDomainService, CompanyContext context, AccountContext accountContext)
{
_application = application;
_rollCallDomainService = rollCallDomainService;
_context = context;
_accountContext = accountContext;
}
public IndexModel(IAndroidApkVersionApplication application, IRollCallDomainService rollCallDomainService, CompanyContext context, AccountContext accountContext)
{
_application = application;
_rollCallDomainService = rollCallDomainService;
_context = context;
_accountContext = accountContext;
}
public void OnGet()
{
}
public void OnGet()
{
}
public async Task<IActionResult> OnPostUpload()
{
var result = await _application.CreateAndActive(File);
ViewData["message"] = result.Message;
return Page();
}
public async Task<IActionResult> OnPostUpload()
{
var result = await _application.CreateAndActive(File);
ViewData["message"] = result.Message;
return Page();
}
public IActionResult OnPostShiftDate()
{
var startRollCall = new DateTime(2025, 2, 19);
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall);
public IActionResult OnPostShiftDate()
{
//var startRollCall = new DateTime(2025, 2, 19);
//var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall);
var endedRollCalls = rollCalls.Where(x => x.EndDate != null).ToList();
//var endedRollCalls = rollCalls.Where(x => x.EndDate != null).ToList();
var notEndedRollCalls = rollCalls.Where(x => x.EndDate == null).ToList();
RefactorAllTheRollCallsOnEsfand(endedRollCalls, notEndedRollCalls);
ViewData["message"] = "تومام Refactor";
return Page();
//var notEndedRollCalls = rollCalls.Where(x => x.EndDate == null).ToList();
//RefactorAllTheRollCallsOnEsfand(endedRollCalls, notEndedRollCalls);
CreateRewardForKebabMahdi().GetAwaiter().GetResult();
ViewData["message"] = "ایجاد شد";
return Page();
}
}
public IActionResult OnPostShiftDateNew()
{
var startRollCall = new DateTime(2025, 2, 19);
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.WorkshopId == 170).ToList();
var r1 = rollCalls.Take(3000).ToList();
public IActionResult OnPostShiftDateNew()
{
var startRollCall = new DateTime(2025, 2, 19);
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.WorkshopId == 170).ToList();
var r1 = rollCalls.Take(3000).ToList();
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("endStep 1 ============");
SetRollCall(r1);
Console.ForegroundColor = ConsoleColor.DarkRed;
Console.WriteLine("endStep 1 ============");
SetRollCall(r1);
ViewData["message"] = "تومام یک";
return Page();
}
ViewData["message"] = "تومام یک";
return Page();
}
public IActionResult OnPostShiftDateNew2()
{
var startRollCall = new DateTime(2025, 2, 19);
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.WorkshopId == 170).ToList();
public IActionResult OnPostShiftDateNew2()
{
var startRollCall = new DateTime(2025, 2, 19);
var rollCalls = _context.RollCalls.Where(x => x.ShiftDate >= startRollCall && x.WorkshopId == 170).ToList();
var r2 = rollCalls.Skip(3000).ToList();
var r2 = rollCalls.Skip(3000).ToList();
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("endStep 2 ============");
SetRollCall2(r2);
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("endStep 2 ============");
SetRollCall2(r2);
ViewData["message"] = "تومام دو";
return Page();
}
ViewData["message"] = "تومام دو";
return Page();
}
#region Create reward for kebab mahdi
public async System.Threading.Tasks.Task CreateRewardForKebabMahdi()
{
var esfandCustomizeCheckouts = _context.CustomizeCheckouts
.Where(x => x.WorkshopId == 170 && x.MonthInt == 12 && x.YearInt == 1403);
#region AccountLeftwork
private void AddToAccountLeftWork()
{
List<long> roleIds = [3, 5, 7, 8, 23, 24];
var accounts = _accountContext.Accounts
.Where(x => roleIds.Contains(x.RoleId)).Where(x => x.AdminAreaPermission == "true");
var accountsIds = accounts.Select(x => x.id).ToList();
var workshopAccount = _context.WorkshopAccounts
.Where(x => accountsIds.Contains(x.AccountId))
.GroupBy(x => x.AccountId);
List<long> oldAccountleftworkActiveNow = [300, 332, 333, 334, 18, 25, 14];
List<long> oldAccountleftworkDeActivedNow = [50, 49, 15];
var continueWorking = _0_Framework.Application.StaticWorkshopAccounts.ContinuesWorkingDate;
var employeeSettings = _context.CustomizeWorkshopEmployeeSettings
.Where(x => x.WorkshopId == 170 &&
esfandCustomizeCheckouts.Any(c => c.EmployeeId == x.EmployeeId));
foreach (var item in workshopAccount)
{
var absentEmployees = employeeSettings.Where(x => !_context.RollCalls
.Any(a => a.EmployeeId == x.EmployeeId && a.ShiftDate == new DateTime(2025,03,20)))
.ToList();
foreach (var employeeSetting in absentEmployees)
{
var amount = (int) employeeSetting.Salary / 30;
var reward = new Reward(employeeSetting.EmployeeId, 170, amount, "", 0, new DateTime(2025, 3, 21),
"بابت تعطیلی روز آخر سال 1403");
_context.Rewards.Add(reward);
}
await _context.SaveChangesAsync();
}
#endregion
var oldActive = item.FirstOrDefault(x => oldAccountleftworkActiveNow.Contains(x.AccountId));
if (oldActive != null)
{
var roleId = accounts.FirstOrDefault(x => x.id == oldActive.AccountId)!.RoleId;
var startGr = item.Key != 25 ? new DateTime(2024, 07, 22) : new DateTime(2024, 08, 22);
//if (item.Key is 380 or 381)
// startGr = new DateTime(2025, 02, 19);
if (item.Key is 14 or 18)
startGr = new DateTime(2020, 05, 21);
if (item.Key is 300)
startGr = new DateTime(2024, 05, 22);
#region AccountLeftwork
foreach (var workshop in item)
{
_accountContext.AccountLeftWorks.Add(new AccountLeftWork(startGr, continueWorking, workshop.AccountId, workshop.WorkshopId, roleId, true));
private void AddToAccountLeftWork()
{
List<long> roleIds = [3, 5, 7, 8, 23, 24];
var accounts = _accountContext.Accounts
.Where(x => roleIds.Contains(x.RoleId)).Where(x => x.AdminAreaPermission == "true");
var accountsIds = accounts.Select(x => x.id).ToList();
var workshopAccount = _context.WorkshopAccounts
.Where(x => accountsIds.Contains(x.AccountId))
.GroupBy(x => x.AccountId);
}
_accountContext.SaveChanges();
}
var oldDeActive = item.FirstOrDefault(x => oldAccountleftworkDeActivedNow.Contains(x.AccountId));
if (oldDeActive != null)
{
var roleId = accounts.FirstOrDefault(x => x.id == oldDeActive.AccountId)!.RoleId;
var startGr = new DateTime(2022, 03, 21);
if (item.Key == 49)
startGr = new DateTime(2023, 04, 21);
if (item.Key == 50)
startGr = new DateTime(2023, 03, 21);
foreach (var workshop in item)
{
_accountContext.Add(new AccountLeftWork(startGr, new DateTime(2024, 07, 21), workshop.AccountId, workshop.WorkshopId, roleId, false));
}
_accountContext.SaveChanges();
}
List<long> oldAccountleftworkActiveNow = [300, 332, 333, 334, 18, 25, 14];
List<long> oldAccountleftworkDeActivedNow = [50, 49, 15];
var continueWorking = _0_Framework.Application.StaticWorkshopAccounts.ContinuesWorkingDate;
}
Console.WriteLine("finished");
}
#endregion
#region RefactorRollcall
private void RefactorAllTheRollCallsOnEsfand(List<global::Company.Domain.RollCallAgg.RollCall> endedRollCalls,List<global::Company.Domain.RollCallAgg.RollCall> notEndedRollCalls)
{
var countEndedRollCalls = endedRollCalls.Count;
var countNotEndedRollCalls = notEndedRollCalls.Count;
var step1 = 1;
foreach (var rollCall in endedRollCalls)
{
rollCall.setStartAndEnd(rollCall.StartDate.Value, rollCall.EndDate.Value, _rollCallDomainService);
Console.WriteLine($"{step1} - {countEndedRollCalls} ended Edit {rollCall.id}");
step1 += 1;
}
var step2 = 1;
foreach (var notEndedRollCall in notEndedRollCalls)
{
notEndedRollCall.SetStartAgain(notEndedRollCall.StartDate.Value);
Console.WriteLine($"{step2} - {countNotEndedRollCalls} not ended startAgain {notEndedRollCall.id}");
step2 += 1;
}
_context.SaveChanges();
}
private void SetRollCall(List<global::Company.Domain.RollCallAgg.RollCall> r1)
{
var endedRollCalls2 = r1.Where(x => x.EndDate != null).ToList();
var countSetTDRollCall = endedRollCalls2.Count;
var stepSetTDRollCal = 1;
foreach (var endedRollCall in endedRollCalls2)
{
endedRollCall.ClearTimeDiff();
_context.SaveChanges();
endedRollCall.SetEndDateTime(endedRollCall.EndDate.Value, _rollCallDomainService);
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
stepSetTDRollCal += 1;
}
//_context.SaveChanges();
}
foreach (var item in workshopAccount)
{
private void SetRollCall2(List<global::Company.Domain.RollCallAgg.RollCall> r2)
{
var endedRollCalls2 = r2.Where(x => x.EndDate != null).ToList();
var countSetTDRollCall = endedRollCalls2.Count;
var stepSetTDRollCal = 1;
foreach (var endedRollCall in endedRollCalls2)
{
endedRollCall.SetEndDateTime(endedRollCall.EndDate.Value, _rollCallDomainService);
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
stepSetTDRollCal += 1;
}
var oldActive = item.FirstOrDefault(x => oldAccountleftworkActiveNow.Contains(x.AccountId));
if (oldActive != null)
{
var roleId = accounts.FirstOrDefault(x => x.id == oldActive.AccountId)!.RoleId;
var startGr = item.Key != 25 ? new DateTime(2024, 07, 22) : new DateTime(2024, 08, 22);
//if (item.Key is 380 or 381)
// startGr = new DateTime(2025, 02, 19);
if (item.Key is 14 or 18)
startGr = new DateTime(2020, 05, 21);
if (item.Key is 300)
startGr = new DateTime(2024, 05, 22);
//_context.SaveChanges();
}
#endregion
//public async Task<IActionResult> OnPostShiftDate()
//{
// var customizeWorkshopSettings = _context.CustomizeWorkshopSettings.AsSplitQuery();
foreach (var workshop in item)
{
_accountContext.AccountLeftWorks.Add(new AccountLeftWork(startGr, continueWorking, workshop.AccountId, workshop.WorkshopId, roleId, true));
}
_accountContext.SaveChanges();
}
var oldDeActive = item.FirstOrDefault(x => oldAccountleftworkDeActivedNow.Contains(x.AccountId));
if (oldDeActive != null)
{
var roleId = accounts.FirstOrDefault(x => x.id == oldDeActive.AccountId)!.RoleId;
var startGr = new DateTime(2022, 03, 21);
if (item.Key == 49)
startGr = new DateTime(2023, 04, 21);
if (item.Key == 50)
startGr = new DateTime(2023, 03, 21);
foreach (var workshop in item)
{
_accountContext.Add(new AccountLeftWork(startGr, new DateTime(2024, 07, 21), workshop.AccountId, workshop.WorkshopId, roleId, false));
}
_accountContext.SaveChanges();
}
// customizeWorkshopSettings = customizeWorkshopSettings.Where(x => x.WorkshopId == 499);
}
// var rollCalls =
// _context.RollCalls.Where(x => customizeWorkshopSettings.Any(a => a.WorkshopId == x.WorkshopId))
// .ToList();
Console.WriteLine("finished");
}
// foreach (var rollCall in rollCalls)
// {
// rollCall.SetShiftDate(_rollCallDomainService);
// Console.WriteLine(rollCall.id);
// }
#endregion
// await _context.SaveChangesAsync();
// ViewData["message"] = "تومام";
// return Page();
//}
}
#region RefactorRollcall
private void RefactorAllTheRollCallsOnEsfand(List<global::Company.Domain.RollCallAgg.RollCall> endedRollCalls, List<global::Company.Domain.RollCallAgg.RollCall> notEndedRollCalls)
{
var countEndedRollCalls = endedRollCalls.Count;
var countNotEndedRollCalls = notEndedRollCalls.Count;
var step1 = 1;
foreach (var rollCall in endedRollCalls)
{
rollCall.setStartAndEnd(rollCall.StartDate.Value, rollCall.EndDate.Value, _rollCallDomainService);
Console.WriteLine($"{step1} - {countEndedRollCalls} ended Edit {rollCall.id}");
step1 += 1;
}
var step2 = 1;
foreach (var notEndedRollCall in notEndedRollCalls)
{
notEndedRollCall.SetStartAgain(notEndedRollCall.StartDate.Value);
Console.WriteLine($"{step2} - {countNotEndedRollCalls} not ended startAgain {notEndedRollCall.id}");
step2 += 1;
}
_context.SaveChanges();
}
private void SetRollCall(List<global::Company.Domain.RollCallAgg.RollCall> r1)
{
var endedRollCalls2 = r1.Where(x => x.EndDate != null).ToList();
var countSetTDRollCall = endedRollCalls2.Count;
var stepSetTDRollCal = 1;
foreach (var endedRollCall in endedRollCalls2)
{
endedRollCall.ClearTimeDiff();
_context.SaveChanges();
endedRollCall.SetEndDateTime(endedRollCall.EndDate.Value, _rollCallDomainService);
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
stepSetTDRollCal += 1;
}
//_context.SaveChanges();
}
private void SetRollCall2(List<global::Company.Domain.RollCallAgg.RollCall> r2)
{
var endedRollCalls2 = r2.Where(x => x.EndDate != null).ToList();
var countSetTDRollCall = endedRollCalls2.Count;
var stepSetTDRollCal = 1;
foreach (var endedRollCall in endedRollCalls2)
{
endedRollCall.SetEndDateTime(endedRollCall.EndDate.Value, _rollCallDomainService);
Console.WriteLine($"{stepSetTDRollCal} - {countSetTDRollCall} ended Set Time Differences{endedRollCall.id}");
stepSetTDRollCal += 1;
}
//_context.SaveChanges();
}
#endregion
//public async Task<IActionResult> OnPostShiftDate()
//{
// var customizeWorkshopSettings = _context.CustomizeWorkshopSettings.AsSplitQuery();
// customizeWorkshopSettings = customizeWorkshopSettings.Where(x => x.WorkshopId == 499);
// var rollCalls =
// _context.RollCalls.Where(x => customizeWorkshopSettings.Any(a => a.WorkshopId == x.WorkshopId))
// .ToList();
// foreach (var rollCall in rollCalls)
// {
// rollCall.SetShiftDate(_rollCallDomainService);
// Console.WriteLine(rollCall.id);
// }
// await _context.SaveChangesAsync();
// ViewData["message"] = "تومام";
// return Page();
//}
}
}

View File

@@ -71,8 +71,12 @@
<script src="~/assetsclient/libs/wordifyfa/wordifyfa.min.js"></script>
<script>
var antiForgeryToken = $(`@Html.AntiForgeryToken()`).val();
var employeeListAjax = `@Url.Page("./EmployeeList", "EmployeeList")`;
var dayOfWeekDataUrl = `@Url.Page("./EmployeeList", "DayOfWeek")`;
var saveLeftWorkAjax = `@Url.Page("./EmployeeList", "CreateEmployeeLeftWork")`;
var employeeListAjax = `@Url.Page("./EmployeeList", "EmployeeList")`; // EmployeeList Handler
var dayOfWeekDataUrl = `@Url.Page("./EmployeeList", "DayOfWeek")`; // EmployeeList Handler
var saveLeftWorkAjax = `@Url.Page("./EmployeeList", "CreateEmployeeLeftWork")`; // EmployeeList Handler
var employeeListHomeAjax = `@Url.Page("/Index", "LeftWorkEmployeeList")`; // Home Handler
var dayOfWeekDataHomeUrl = `@Url.Page("/Index", "DayOfWeek")`; // Home Handler
var saveLeftWorkHomeAjax = `@Url.Page("/Index", "CreateEmployeeLeftWork")`; // Home Handler
</script>
<script src="~/assetsclient/pages/Employees/js/ModalCreateLeftWorkEmployee.js?ver=@clientVersion"></script>

View File

@@ -268,6 +268,9 @@ function htmlLoadSimpleData(loadRewardListData, responsePageIndex) {
${n}
</span>
</label>
</div>
<div class="Rtable-cell d-md-block d-none width7">
<div class="Rtable-cell--content ">${item.grantDateFa}</div>
</div>
<div class="Rtable-cell justify-content-start width2">
<div class="Rtable-cell--content text-start">${item.employeeFullName}</div>
@@ -278,16 +281,18 @@ function htmlLoadSimpleData(loadRewardListData, responsePageIndex) {
<div class="Rtable-cell d-md-block d-none width4">
<div class="Rtable-cell--content ">${item.title ?? "-"}</div>
</div>
<div class="Rtable-cell d-md-block d-none width6">
<div class="tooltipfull-container">
<div class="Rtable-cell--content ellipsed" style="width: 280px;">${item.description}</div>
<span class="tooltipfull">
<span>${item.description}</span>
</span>
</div>
</div>
<div class="Rtable-cell d-md-block d-none width5">
<div class="Rtable-cell--content ">${item.amount}</div>
</div>
<div class="Rtable-cell d-md-block d-none width6">
<div class="Rtable-cell--content " style="text-overflow: ellipsis;overflow: hidden;width: 90%;white-space: nowrap;">${item.description}</div>
</div>
<div class="Rtable-cell d-md-block d-none width7">
<div class="Rtable-cell--content ">${item.grantDateFa}</div>
</div>
<div class="Rtable-cell width8">
<div class="Rtable-cell--content align-items-center justify-content-end d-flex text-end">
<button type="button" class="btn-print d-md-none d-none" onclick="printReward()">
@@ -434,8 +439,7 @@ function htmlLoadSimpleData(loadRewardListData, responsePageIndex) {
pageIndexJs++;
});
pageIndexJs = pageIndex + responsePageIndex;
//pageIndexJs = pageIndexJs + responsePageIndex;
$('#PageIndex').val(pageIndexJs);
$('#rewardListAjax').append(html);
@@ -491,16 +495,15 @@ function htmlLoadWithEmployeeData(loadRewardListData, responsePageIndex) {
<div class="Rtable-cell d-md-flex justify-content-center d-none width53">
<div class="Rtable-cell--content">${item.personnelCode}</div>
</div>
<div class="Rtable-cell d-md-block d-none width6">
<div class="Rtable-cell--content ">${item.amount}</div>
</div>
<div class="Rtable-cell d-md-block d-none width7">
<div class="Rtable-cell--content " style="text-overflow: ellipsis;overflow: hidden;width: 90%;white-space: nowrap;">${item.description}</div>
</div>
<div class="Rtable-cell d-md-block d-none width8">
<div class="Rtable-cell--content ">${item.grantDateFa}</div>
</div>
<div class="Rtable-cell d-md-block d-none width6">
<div class="Rtable-cell--content ">${item.amount}</div>
</div>
<div class="Rtable-cell width9">
<div class="Rtable-cell--content align-items-center justify-content-end d-flex text-end">
<button type="button" class="btn-print d-md-none d-none" onclick="printReward()">