Bonus Process Employee Loading
This commit is contained in:
parent
072b0a63c4
commit
9944262dd1
|
|
@ -563,6 +563,7 @@ namespace HRM.BO
|
|||
//void SaveBasicInfo(Employee item);
|
||||
List<Employee> GetByEmpIDs(string empIDs, int payrollTypeID);
|
||||
List<Employee> GetByEmpIDs(string empIDs);
|
||||
List<EmployeeLite> GetLiteByEmpIDs(List<int> empIDs);
|
||||
List<Employee> GetFssEmp(string empIDs, int payrollTypeID);
|
||||
List<Employee> GetEmpsWithDiscontinue(string empIDs, int payrollTypeID);
|
||||
DataSet GetEmpJoining4Novartis(DateTime dEffectDate, int payrollTypeID);
|
||||
|
|
|
|||
17
HRM.BO/Employee/EmployeeLite.cs
Normal file
17
HRM.BO/Employee/EmployeeLite.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
|
|
@ -798,6 +798,34 @@ namespace HRM.DA
|
|||
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)
|
||||
{
|
||||
string sTableName;
|
||||
|
|
|
|||
|
|
@ -1890,6 +1890,51 @@ namespace HRM.DA
|
|||
|
||||
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)
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import {TrainingType} from '../../_models/Basic/trainingType';
|
|||
import {EducationType} from '../../_models/HRBasic/education-type';
|
||||
import {NominationPurpose} from '../../_models/HRBasic/nomination-purpose';
|
||||
import {Employee} from '../../_models/Employee/employee';
|
||||
import {EmployeeLite} from '../../_models/Employee/employeeLite';
|
||||
import {EmployeeBankAccount} from '../../_models/Employee/employeeBankAccount';
|
||||
import {EmployeeCostCenter} from '../../_models/Employee/employeeCostCenter';
|
||||
import {Relation} from '../../_models/HRBasic/relation';
|
||||
|
|
@ -135,6 +136,11 @@ export class EmployeeServices {
|
|||
getEmployeesByEmpIDs(data: any) {
|
||||
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) {
|
||||
return this.apiService.httpPost<Employee[]>('/Employee/getEmployeeDetailByEmpIDs', data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,10 @@
|
|||
</div>
|
||||
|
||||
<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>
|
||||
<button type="button" kendoGridExcelCommand [svgIcon]="apiService.KendoSVGIcon['fileExcel']">
|
||||
Export to Excel
|
||||
|
|
@ -195,7 +198,7 @@
|
|||
</button>
|
||||
</ng-template>
|
||||
</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>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import {loadingPanelService} from '../../hrm-loding panel/loding.panel.service';
|
|||
import {PayrollType} from '../../_models/Authentication/payrollType';
|
||||
import {Bonus} from '../../_models/Basic/bonus';
|
||||
import {Employee} from '../../_models/Employee/employee';
|
||||
import {EmployeeLite} from '../../_models/Employee/employeeLite';
|
||||
import {SearchEmployee} from '../../_models/Employee/searchEmployee';
|
||||
import {EnumIncomeTaxItemGroup, EnumStatus, EnumTaxMergeType} from '../../_models/enums';
|
||||
import {BonusProcess, BonusProcessDetail} from '../../_models/Payroll/bonusProcess';
|
||||
|
|
@ -126,6 +127,7 @@ export class BonusProcessComponent implements OnInit {
|
|||
this.returnMessage = err.error;
|
||||
},
|
||||
() => {
|
||||
debugger;
|
||||
this.loadingPanelService.ShowLoadingPanel = false;
|
||||
this.RefreshDefaultGrid();
|
||||
}
|
||||
|
|
@ -159,6 +161,7 @@ export class BonusProcessComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
});
|
||||
this.bonusProcess.bonusProcessDetails = [...this.bonusProcess.bonusProcessDetails];
|
||||
this.RefreshEmployees();
|
||||
if (this.alreadyProcessesList.length > 0) {
|
||||
this.showModal = true;
|
||||
|
|
@ -167,37 +170,29 @@ export class BonusProcessComponent implements OnInit {
|
|||
}
|
||||
RefreshEmployees() {
|
||||
if (this.selectedEmps == undefined) return;
|
||||
var ids = SearchEmployee.getEmpIds(this.selectedEmps);
|
||||
|
||||
const data = {
|
||||
dataList: ids,
|
||||
};
|
||||
var emps: Employee[];
|
||||
|
||||
const empIds: number[] = this.selectedEmps.map(e => e.employeeID);
|
||||
var emps: EmployeeLite[];
|
||||
this.loadingPanelService.ShowLoadingPanel = true;
|
||||
this.empService.getEmployeesByEmpIDs(data).subscribe(
|
||||
this.empService.getEmployeeLiteByEmpIDs(empIds).subscribe(
|
||||
(resp: any) => {
|
||||
emps = resp;
|
||||
},
|
||||
(err: any) => {
|
||||
this.loadingPanelService.ShowLoadingPanel = false;
|
||||
this.notificationService.showWarning(err.error);
|
||||
|
||||
},
|
||||
() => {
|
||||
this.loadingPanelService.ShowLoadingPanel = false;
|
||||
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) {
|
||||
this.bonusProcess.bonusProcessDetails[bindex].employee.isConfirmed = x.isConfirmed;
|
||||
this.bonusProcess.bonusProcessDetails[bindex].employee.joiningDate = x.joiningDate;
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
checkWithOrTax(from: number, value: boolean) {
|
||||
debugger;
|
||||
if (from == 1) {
|
||||
if (value == true) {
|
||||
this.isTaxProcess = false;
|
||||
|
|
@ -509,8 +504,16 @@ export class BonusProcessComponent implements OnInit {
|
|||
|
||||
removefromList(rowIndex: number) {
|
||||
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}) {
|
||||
console.log(dataItem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@
|
|||
<div class="grid">
|
||||
<div class="col-12">
|
||||
<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"
|
||||
(selectedKeysChange)="onSelectedKeysChange($event)" [selectable]="selectableSettings"
|
||||
[kendoGridSelectBy]="'employeeID'">
|
||||
|
|
|
|||
|
|
@ -2293,6 +2293,27 @@ namespace HRM.UI.Controllers
|
|||
|
||||
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")]
|
||||
public ActionResult updateBanglaInformation(dynamic data)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user