Bonus Process Employee Loading

This commit is contained in:
Mohaimen Hasan 2026-11-11 13:15:14 +06:00
parent 072b0a63c4
commit 9944262dd1
10 changed files with 147 additions and 16 deletions

View File

@ -563,6 +563,7 @@ namespace HRM.BO
//void SaveBasicInfo(Employee item); //void SaveBasicInfo(Employee item);
List<Employee> GetByEmpIDs(string empIDs, int payrollTypeID); List<Employee> GetByEmpIDs(string empIDs, int payrollTypeID);
List<Employee> GetByEmpIDs(string empIDs); List<Employee> GetByEmpIDs(string empIDs);
List<EmployeeLite> GetLiteByEmpIDs(List<int> empIDs);
List<Employee> GetFssEmp(string empIDs, int payrollTypeID); List<Employee> GetFssEmp(string empIDs, int payrollTypeID);
List<Employee> GetEmpsWithDiscontinue(string empIDs, int payrollTypeID); List<Employee> GetEmpsWithDiscontinue(string empIDs, int payrollTypeID);
DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID); DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID);

View File

@ -0,0 +1,17 @@
using System;
namespace HRM.BO
{
/// <summary>
/// A light Employee: only the few columns that screens working on thousands of employees at once need
/// (Bonus Process today). Loading the whole Employee row for 10k+ employees never reached the browser.
/// To add a field: add the property here, the column in EmployeeDA.GetLiteByEmpIDs, and the read in
/// EmployeeService.GetLiteByEmpIDs (and in ClientApp _models/Employee/employeeLite.ts).
/// </summary>
public class EmployeeLite
{
public int EmployeeID { get; set; }
public bool IsConfirmed { get; set; }
public DateTime? JoiningDate { get; set; }
}
}

View File

@ -798,6 +798,34 @@ namespace HRM.DA
return dr; return dr;
} }
/// <summary>
/// The EmployeeLite columns only, for any number of employees (10k+ at a time).
/// The IDs go in as ONE varchar(max) parameter and land in a temp table with a primary key, so the
/// SQL text stays small and SQL Server knows how many rows to expect (an inline IN list or
/// STRING_SPLIT in the join is much slower at this size). Needs SQL Server 2016+ (STRING_SPLIT).
/// </summary>
internal static IDataReader GetLiteByEmpIDs(TransactionContext tc, List<int> empIDs)
{
const string sql = @"SET NOCOUNT ON;
IF OBJECT_ID('tempdb..#elEmpIds') IS NOT NULL DROP TABLE #elEmpIds;
CREATE TABLE #elEmpIds (ID int NOT NULL PRIMARY KEY);
INSERT INTO #elEmpIds (ID) SELECT DISTINCT CONVERT(int, value) FROM STRING_SPLIT(@empIds, ',') WHERE value <> '';
SELECT e.EMPLOYEEID AS EmployeeID, e.ISCONFIRMED AS IsConfirmed, e.JOININGDATE AS JoiningDate
FROM Employee e
INNER JOIN #elEmpIds t ON t.ID = e.EMPLOYEEID;
DROP TABLE #elEmpIds;";
// ints only (the caller passes List<int>), so the parameter can never carry anything but digits and commas
string ids = string.Join(",", empIDs);
// must be a SqlParameter[]: Ease.Core casts the array to SqlParameter[], and a lone parameter
// passed to "params IDataParameter[]" would arrive as an IDataParameter[] and fail that cast
SqlParameter[] parameters =
{
SqlHelperExtension.CreateInParam("@empIds", SqlDbType.VarChar, ids, -1) // varchar(max)
};
return tc.ExecuteReader(CommandType.Text, sql, parameters);
}
internal static IDataReader GetFssEmp(TransactionContext tc, string empIDs, int payrollTypeID) internal static IDataReader GetFssEmp(TransactionContext tc, string empIDs, int payrollTypeID)
{ {
string sTableName; string sTableName;

View File

@ -1890,6 +1890,51 @@ namespace HRM.DA
return employees; return employees;
} }
/// <summary>
/// A light Employee (EmployeeLite) for each of the given employees — an alternative to GetByEmpIDs
/// for screens that need only a few fields for thousands of employees (Bonus Process).
/// </summary>
public List<EmployeeLite> GetLiteByEmpIDs(List<int> empIDs)
{
List<EmployeeLite> items = new List<EmployeeLite>();
if (empIDs == null || empIDs.Count == 0)
return items;
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(EmployeeDA.GetLiteByEmpIDs(tc, empIDs.Distinct().ToList()));
while (dr.Read())
{
items.Add(new EmployeeLite
{
EmployeeID = dr.GetInt32("EmployeeID").Value,
IsConfirmed = dr.GetBoolean("IsConfirmed", false),
JoiningDate = dr.GetDateTime("JoiningDate")
});
}
dr.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return items;
}
public void UpdateBanglaInformation(List<object> employeBanglaInfo) public void UpdateBanglaInformation(List<object> employeBanglaInfo)
{ {

View File

@ -0,0 +1,7 @@
// A light Employee: only the few fields screens working on thousands of employees at once need
// (api/Employee/getEmployeeLiteByEmpIDs). Mirrors HRM.BO.EmployeeLite — add a field in both.
export class EmployeeLite {
public employeeID: number;
public isConfirmed: boolean;
public joiningDate: Date;
}

View File

@ -11,6 +11,7 @@ import {TrainingType} from '../../_models/Basic/trainingType';
import {EducationType} from '../../_models/HRBasic/education-type'; import {EducationType} from '../../_models/HRBasic/education-type';
import {NominationPurpose} from '../../_models/HRBasic/nomination-purpose'; import {NominationPurpose} from '../../_models/HRBasic/nomination-purpose';
import {Employee} from '../../_models/Employee/employee'; import {Employee} from '../../_models/Employee/employee';
import {EmployeeLite} from '../../_models/Employee/employeeLite';
import {EmployeeBankAccount} from '../../_models/Employee/employeeBankAccount'; import {EmployeeBankAccount} from '../../_models/Employee/employeeBankAccount';
import {EmployeeCostCenter} from '../../_models/Employee/employeeCostCenter'; import {EmployeeCostCenter} from '../../_models/Employee/employeeCostCenter';
import {Relation} from '../../_models/HRBasic/relation'; import {Relation} from '../../_models/HRBasic/relation';
@ -135,6 +136,11 @@ export class EmployeeServices {
getEmployeesByEmpIDs(data: any) { getEmployeesByEmpIDs(data: any) {
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeesByEmpIDs', data); return this.apiService.httpPost<Employee[]>('/Employee/getEmployeesByEmpIDs', data);
} }
// A light Employee (only a few fields) — light enough for 10k+ employees (Bonus Process).
getEmployeeLiteByEmpIDs(empIds: number[]) {
return this.apiService.httpPost<EmployeeLite[]>('/Employee/getEmployeeLiteByEmpIDs', empIds);
}
getEmployeeDetailByEmpIDs(data: any) { getEmployeeDetailByEmpIDs(data: any) {
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeeDetailByEmpIDs', data); return this.apiService.httpPost<Employee[]>('/Employee/getEmployeeDetailByEmpIDs', data);
} }

View File

@ -131,7 +131,10 @@
</div> </div>
<div class="col-12"> <div class="col-12">
<kendo-grid [data]="$safeNavigationMigration(bonusProcess?.bonusProcessDetails)"> <!-- virtual scrolling: only the rows on screen are rendered, so 10k+ employees (two numeric
textboxes per row) do not freeze the page. kendoGridBinding pages the array itself. -->
<kendo-grid [kendoGridBinding]="$safeNavigationMigration(bonusProcess?.bonusProcessDetails)"
scrollable="virtual" [pageSize]="50" [rowHeight]="40" [height]="500">
<ng-template kendoGridToolbarTemplate> <ng-template kendoGridToolbarTemplate>
<button type="button" kendoGridExcelCommand [svgIcon]="apiService.KendoSVGIcon['fileExcel']"> <button type="button" kendoGridExcelCommand [svgIcon]="apiService.KendoSVGIcon['fileExcel']">
Export to Excel Export to Excel
@ -195,7 +198,7 @@
</button> </button>
</ng-template> </ng-template>
</kendo-grid-command-column> </kendo-grid-command-column>
<kendo-grid-excel fileName="BonusProcess.xlsx"></kendo-grid-excel> <kendo-grid-excel fileName="BonusProcess.xlsx" [fetchData]="allBonusRows"></kendo-grid-excel>
</kendo-grid> </kendo-grid>
</div> </div>

View File

@ -8,6 +8,7 @@ import {loadingPanelService} from '../../hrm-loding panel/loding.panel.service';
import {PayrollType} from '../../_models/Authentication/payrollType'; import {PayrollType} from '../../_models/Authentication/payrollType';
import {Bonus} from '../../_models/Basic/bonus'; import {Bonus} from '../../_models/Basic/bonus';
import {Employee} from '../../_models/Employee/employee'; import {Employee} from '../../_models/Employee/employee';
import {EmployeeLite} from '../../_models/Employee/employeeLite';
import {SearchEmployee} from '../../_models/Employee/searchEmployee'; import {SearchEmployee} from '../../_models/Employee/searchEmployee';
import {EnumIncomeTaxItemGroup, EnumStatus, EnumTaxMergeType} from '../../_models/enums'; import {EnumIncomeTaxItemGroup, EnumStatus, EnumTaxMergeType} from '../../_models/enums';
import {BonusProcess, BonusProcessDetail} from '../../_models/Payroll/bonusProcess'; import {BonusProcess, BonusProcessDetail} from '../../_models/Payroll/bonusProcess';
@ -126,6 +127,7 @@ export class BonusProcessComponent implements OnInit {
this.returnMessage = err.error; this.returnMessage = err.error;
}, },
() => { () => {
debugger;
this.loadingPanelService.ShowLoadingPanel = false; this.loadingPanelService.ShowLoadingPanel = false;
this.RefreshDefaultGrid(); this.RefreshDefaultGrid();
} }
@ -159,6 +161,7 @@ export class BonusProcessComponent implements OnInit {
} }
} }
}); });
this.bonusProcess.bonusProcessDetails = [...this.bonusProcess.bonusProcessDetails];
this.RefreshEmployees(); this.RefreshEmployees();
if (this.alreadyProcessesList.length > 0) { if (this.alreadyProcessesList.length > 0) {
this.showModal = true; this.showModal = true;
@ -167,27 +170,21 @@ export class BonusProcessComponent implements OnInit {
} }
RefreshEmployees() { RefreshEmployees() {
if (this.selectedEmps == undefined) return; if (this.selectedEmps == undefined) return;
var ids = SearchEmployee.getEmpIds(this.selectedEmps); const empIds: number[] = this.selectedEmps.map(e => e.employeeID);
var emps: EmployeeLite[];
const data = {
dataList: ids,
};
var emps: Employee[];
this.loadingPanelService.ShowLoadingPanel = true; this.loadingPanelService.ShowLoadingPanel = true;
this.empService.getEmployeesByEmpIDs(data).subscribe( this.empService.getEmployeeLiteByEmpIDs(empIds).subscribe(
(resp: any) => { (resp: any) => {
emps = resp; emps = resp;
}, },
(err: any) => { (err: any) => {
this.loadingPanelService.ShowLoadingPanel = false; this.loadingPanelService.ShowLoadingPanel = false;
this.notificationService.showWarning(err.error); this.notificationService.showWarning(err.error);
}, },
() => { () => {
this.loadingPanelService.ShowLoadingPanel = false; this.loadingPanelService.ShowLoadingPanel = false;
emps.forEach(x => { emps.forEach(x => {
let bindex = this.bonusProcess.bonusProcessDetails.findIndex(b => b.employeeID == x.id); let bindex = this.bonusProcess.bonusProcessDetails.findIndex(b => b.employeeID == x.employeeID);
if (bindex != -1) { if (bindex != -1) {
this.bonusProcess.bonusProcessDetails[bindex].employee.isConfirmed = x.isConfirmed; this.bonusProcess.bonusProcessDetails[bindex].employee.isConfirmed = x.isConfirmed;
this.bonusProcess.bonusProcessDetails[bindex].employee.joiningDate = x.joiningDate; this.bonusProcess.bonusProcessDetails[bindex].employee.joiningDate = x.joiningDate;
@ -195,9 +192,7 @@ export class BonusProcessComponent implements OnInit {
}); });
}); });
} }
checkWithOrTax(from: number, value: boolean) { checkWithOrTax(from: number, value: boolean) {
debugger;
if (from == 1) { if (from == 1) {
if (value == true) { if (value == true) {
this.isTaxProcess = false; this.isTaxProcess = false;
@ -509,8 +504,16 @@ export class BonusProcessComponent implements OnInit {
removefromList(rowIndex: number) { removefromList(rowIndex: number) {
this.bonusProcess.bonusProcessDetails.splice(rowIndex, 1); this.bonusProcess.bonusProcessDetails.splice(rowIndex, 1);
// new array reference so the (virtual) grid re-reads it
this.bonusProcess.bonusProcessDetails = [...this.bonusProcess.bonusProcessDetails];
} }
// Excel export: every row, not only the rows the virtual grid has on screen
public allBonusRows = (): any => {
const rows = this.bonusProcess?.bonusProcessDetails ?? [];
return { data: rows, total: rows.length };
};
removeHandler({dataItem}) { removeHandler({dataItem}) {
console.log(dataItem); console.log(dataItem);
} }

View File

@ -316,7 +316,7 @@
<div class="grid"> <div class="grid">
<div class="col-12"> <div class="col-12">
<kendo-grid [data]="gridView" (pageChange)="onDataChange($event)" [pageSize]="pageSize" <kendo-grid [data]="gridView" (pageChange)="onDataChange($event)" [pageSize]="pageSize"
[pageable]="true" scrollable="virtual" [skip]="skip" [rowHeight]="36" [pageable]="false" scrollable="virtual" [skip]="skip" [rowHeight]="36"
[(selectedKeys)]="selectedItems" [state]="selectAllState" [style.height.px]="gridHeight" [(selectedKeys)]="selectedItems" [state]="selectAllState" [style.height.px]="gridHeight"
(selectedKeysChange)="onSelectedKeysChange($event)" [selectable]="selectableSettings" (selectedKeysChange)="onSelectedKeysChange($event)" [selectable]="selectableSettings"
[kendoGridSelectBy]="'employeeID'"> [kendoGridSelectBy]="'employeeID'">

View File

@ -2293,6 +2293,27 @@ namespace HRM.UI.Controllers
return Ok(employeeList); return Ok(employeeList);
} }
/// <summary>
/// A light Employee (EmployeeLite) for each posted employee ID (body: [1, 2, 3]).
/// For screens that pick 10k+ employees and need only a few fields (Bonus Process);
/// getEmployeesByEmpIDs returns the whole Employee row and is too heavy for that.
/// </summary>
[HttpPost("getEmployeeLiteByEmpIDs")]
public ActionResult GetEmployeeLiteByEmpIDs([FromBody] List<int> empIds)
{
List<EmployeeLite> items = new List<EmployeeLite>();
try
{
items = _EmployeeService.GetLiteByEmpIDs(empIds);
}
catch (Exception ex)
{
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
}
return Ok(items);
}
[HttpPost("updateBanglaInformation")] [HttpPost("updateBanglaInformation")]
public ActionResult updateBanglaInformation(dynamic data) public ActionResult updateBanglaInformation(dynamic data)
{ {