refactor: 사양 부족 및 노후 장비의 교체 수요를 해당 사용자의 직무 권장 사양 등급에 맞추어 분산 합계 계산

This commit is contained in:
2026-06-15 13:19:10 +09:00
parent d6e75f8b2c
commit 132e37d0d3

View File

@@ -305,28 +305,30 @@ function updateDashboardData(pcs: any[], selectedDept: string) {
const stockYn = isStock(p);
const win11Incompatible = isWindows11Incompatible(p.cpu, p.ram);
let target: typeof matrix.premium;
// 1. 현재 물리적 자산 등급 판정
let currentGradeKey: keyof typeof matrix;
if (score >= 85) {
target = matrix.premium;
currentGradeKey = 'premium';
} else if (score >= 70) {
target = matrix.high;
currentGradeKey = 'high';
} else if (score >= 40) {
target = matrix.normal;
currentGradeKey = 'normal';
} else if (score >= 20 && !win11Incompatible) {
target = matrix.entry;
currentGradeKey = 'entry';
} else {
target = matrix.replace;
currentGradeKey = 'replace';
}
target.pcs.push(p);
target.total++;
const currentTarget = matrix[currentGradeKey];
currentTarget.pcs.push(p);
currentTarget.total++;
if (stockYn) {
target.stock++;
target.stockPcs.push(p);
currentTarget.stock++;
currentTarget.stockPcs.push(p);
} else {
target.active++;
target.activePcs.push(p);
currentTarget.active++;
currentTarget.activePcs.push(p);
// 직무 적정성 계산 (재직 중이고 실 사용자 매핑 자산만 검토 대상)
const job = p[ASSET_SCHEMA.USER_POSITION.key] || '미분류';
@@ -358,8 +360,22 @@ function updateDashboardData(pcs: any[], selectedDept: string) {
if (isUnder) {
criticalList.push(p);
underSpecCount++;
target.under++;
target.underPcs.push(p);
// 2. 사양 부족 시 교체받아야 할 직무별 권장 목표 등급 판정
let targetGradeKey: keyof typeof matrix;
if (avg >= 85) {
targetGradeKey = 'premium';
} else if (avg >= 70) {
targetGradeKey = 'high';
} else if (avg >= 40) {
targetGradeKey = 'normal';
} else {
targetGradeKey = 'entry'; // 교체 대상은 최소 보급형 사양으로 교체
}
const targetGrade = matrix[targetGradeKey];
targetGrade.under++;
targetGrade.underPcs.push(p);
}
}
@@ -404,8 +420,8 @@ function updateDashboardData(pcs: any[], selectedDept: string) {
const highShortage = Math.max(0, matrix.high.under - matrix.high.stock);
const normalShortage = Math.max(0, matrix.normal.under - matrix.normal.stock);
// 보급 PC 구매 필요 = (보급 under + 교체대상 under) - 보급 stock (교체 대상을 위해 최소 보급 PC 사양을 구매한다는 논리 적용)
const entryShortage = Math.max(0, (matrix.entry.under + matrix.replace.under) - matrix.entry.stock);
// 보급 PC 구매 필요 = 보급 under - 보급 stock
const entryShortage = Math.max(0, matrix.entry.under - matrix.entry.stock);
// 교체 대상 PC 자체는 새로 구매하는 기종이 아니므로 구매 필요 0대
const replaceShortage = 0;