[feat] negodata: 통계 인상억제율(재협상)·월별 차트 — 직전 라운드 투찰가 대비 인하율 파생 집계

This commit is contained in:
minaChoi committed 2026-07-22 15:19:14 +09:00
1 parent e7a51b1b75
commit e8d2acaade
10 files changed
+172 -4

No files matched your search

@@ -13,4 +13,5 @@ export interface StatKpi {
savings_delta_mom?: number;
closed_count?: number;
regen_avg_round?: number;
markup_suppression_rate?: number;
}
@@ -0,0 +1,11 @@
/**
* Generated by orval v7.21.0 🍺
* Do not edit manually.
* Negodata Api Server
* OpenAPI spec version: 0.1.0
*/
export interface StatMarkupPoint {
month: string;
rate?: number;
}
@@ -6,6 +6,7 @@
*/
import type { StatKpi } from './statKpi';
import type { StatMonthPoint } from './statMonthPoint';
import type { StatMarkupPoint } from './statMarkupPoint';
import type { StatOutcome } from './statOutcome';
import type { StatParticipation } from './statParticipation';
import type { StatTypeRow } from './statTypeRow';
@@ -15,6 +16,7 @@ import type { StatCardUsage } from './statCardUsage';
export interface StatScope {
kpi?: StatKpi;
trend?: StatMonthPoint[];
markup_trend?: StatMarkupPoint[];
outcome?: StatOutcome;
participation?: StatParticipation;
type_split?: StatTypeRow[];
@@ -2,6 +2,7 @@ import { Award, Percent, RefreshCw, Target, TrendingDown, CircleCheckBig } from
import { Panel } from './components/Panel';
import { StatTile } from './components/StatTile';
import { SavingsTrendChart } from './components/SavingsTrendChart';
import { MarkupTrendChart } from './components/MarkupTrendChart';
import { OutcomeChart } from './components/OutcomeChart';
import { ParticipationChart } from './components/ParticipationChart';
import { TypeSplitChart } from './components/TypeSplitChart';
@@ -9,9 +10,11 @@ import { CategoryChart } from './components/CategoryChart';
import { CardEffectChart } from './components/CardEffectChart';
import { wonCompact, pct, signedWonCompact } from './fmt';
import type { StatData } from './types';
import { useLabels } from '@/features/settings/useCompanySettings';
// 통계 본문. KPI 요약 + 절감 분석 + 성사/프로세스 + 카드 효과. scope(회사/내견적)별로 동일 레이아웃.
export function StatisticsView({ data }: { data: StatData }) {
const label = useLabels(); // 회사 설정 용어(카테고리 등)
const k = data.kpi;
return (
<div className="space-y-4">
@@ -40,6 +43,10 @@ export function StatisticsView({ data }: { data: StatData }) {
>
<SavingsTrendChart data={data.trend} />
</Panel>
<Panel title="월별 인상억제율" subtitle="재협상: 직전 라운드 투찰가 대비 인하율">
<MarkupTrendChart data={data.markupTrend} />
</Panel>
<Panel title="마감 결과" subtitle="낙찰 vs 개찰 사유 4종">
<OutcomeChart data={data.outcome} />
</Panel>
@@ -57,7 +64,7 @@ export function StatisticsView({ data }: { data: StatData }) {
{/* 카테고리 · 카드 */}
<div className="grid gap-4 lg:grid-cols-2">
<Panel title="카테고리별 절감" subtitle="어디서 절감이 났나">
<Panel title={`${label('category')}별 절감`} subtitle="어디서 절감이 났나">
<CategoryChart data={data.categories} />
</Panel>
<Panel title="협상카드 효과" subtitle="유형별 사용빈도 + 사용 직후 평균 제시가 하락">
@@ -17,8 +17,10 @@ function mapScope(s?: ApiScope): StatData {
savingsDeltaMoM: k.savings_delta_mom ?? 0,
closedCount: k.closed_count ?? 0,
regenAvgRound: k.regen_avg_round ?? 0,
markupSuppressionRate: k.markup_suppression_rate ?? 0,
},
trend: (s?.trend ?? []).map((t) => ({ month: t.month, savings: t.savings ?? 0, rate: t.rate ?? 0 })),
markupTrend: (s?.markup_trend ?? []).map((t) => ({ month: t.month, rate: t.rate ?? 0 })),
outcome: {
awarded: o.awarded ?? 0,
openPrice: o.open_price ?? 0,
@@ -0,0 +1,36 @@
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from 'recharts';
import { ChartContainer, ChartTooltip, type ChartConfig } from '@/components/ui/chart';
import { Typography } from '@/components/ui/typography';
import { themeOf } from '../palette';
import { pct, monthLabel } from '../fmt';
import type { MarkupPoint } from '../types';
// 월별 인상억제율(재협상: 직전 라운드 투찰가 대비 이번 투찰가 인하율).
const config = {
rate: { label: '인상억제율', theme: themeOf('rose') },
} satisfies ChartConfig;
export function MarkupTrendChart({ data }: { data: MarkupPoint[] }) {
return (
<ChartContainer config={config} className="aspect-auto h-56 w-full">
<BarChart data={data} margin={{ top: 8, right: 8, left: 4, bottom: 0 }}>
<CartesianGrid vertical={false} strokeDasharray="3 3" />
<XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} tickFormatter={monthLabel} />
<YAxis tickLine={false} axisLine={false} width={44} tickFormatter={(v) => pct(Number(v))} />
<ChartTooltip cursor={false} content={<MarkupTooltip />} />
<Bar dataKey="rate" fill="var(--color-rate)" radius={[4, 4, 0, 0]} maxBarSize={48} />
</BarChart>
</ChartContainer>
);
}
function MarkupTooltip({ active, payload }: { active?: boolean; payload?: { payload: MarkupPoint }[] }) {
if (!active || !payload?.length) return null;
const p = payload[0].payload;
return (
<div className="rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl">
<Typography as="p" variant="caption" className="mb-0.5 font-medium text-foreground">{monthLabel(p.month)}</Typography>
<Typography as="p" variant="caption" className="font-mono text-foreground">인상억제율 {pct(p.rate)}</Typography>
</div>
);
}
@@ -11,6 +11,7 @@ export interface StatKpi {
savingsDeltaMoM: number; // 전월 대비 절감액 증감
closedCount: number; // 마감 견적 수(창)
regenAvgRound: number; // 평균 재견적 라운드(1=재견적 없음)
markupSuppressionRate: number; // 인상억제율(재협상: 직전 라운드 투찰가 대비 이번 투찰가 인하율)
}
export interface MonthPoint {
@@ -19,6 +20,11 @@ export interface MonthPoint {
rate: number;
}
export interface MarkupPoint {
month: string; // 'YYYY-MM'
rate: number; // 인상억제율
}
export interface OutcomeBreakdown {
awarded: number;
openPrice: number; // 가격 미달
@@ -57,6 +63,7 @@ export interface CardTypeUsage {
export interface StatData {
kpi: StatKpi;
trend: MonthPoint[];
markupTrend: MarkupPoint[];
outcome: OutcomeBreakdown;
participation: ParticipationBreakdown;
typeSplit: TypeSplitRow[];