wangzhibo
4 天以前 656e2507b9aa388afa4c3346927b1b94ab70a0b2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
export type TimeRange = 'today' | 'week' | 'month' | 'quarter' | 'year';
export type ScreenKey = 'overview' | 'resource' | 'carbon' | 'participation' | 'operation';
export type RankMetric = 'weight' | 'people' | 'pointPerCapita' | 'weightPerCapita' | 'carbon';
 
export const SCREEN_NAV: { key: ScreenKey; path: string; index: string; label: string; audience: string }[] = [
    { key: 'overview', path: '/report/screen/overview', index: '01', label: '绿色校园总览', audience: '校领导' },
    { key: 'resource', path: '/report/screen/resource', index: '02', label: '垃圾资源化分析', audience: '后勤 / 环保' },
    { key: 'carbon', path: '/report/screen/carbon', index: '03', label: '碳减排与绿色贡献', audience: '双碳 / ESG' },
    { key: 'participation', path: '/report/screen/participation', index: '04', label: '师生参与与碳积分', audience: '学工 / 团委' },
    { key: 'operation', path: '/report/screen/operation', index: '05', label: '回收运营监控', audience: '运营公司' }
];
 
export const TIME_RANGE_OPTIONS: { label: string; value: TimeRange }[] = [
    { label: '今日', value: 'today' },
    { label: '本周', value: 'week' },
    { label: '本月', value: 'month' },
    { label: '本季度', value: 'quarter' },
    { label: '本年度', value: 'year' }
];
 
export interface ScreenData {
    range: TimeRange | string;
    axis: string[];
    kpis: Record<string, number>;
    wasteMix: { name: string; code?: string; weight: number; value: number; count: number; color: string }[];
    recycleItems: { name: string; weight: number; value: number; carbon: number; color: string }[];
    trend: { weight: number[]; value: number[]; carbon: number[] };
    yearCarbon: number[];
    deptRank: any[];
    classRank: any[];
    majorRank: any[];
    pointFlow: { issued: number; transfer: number; donate: number; mall: number; balance: number };
    participateTrend: number[];
    deliverTrend: number[];
    ordersByType: { axis: string[]; 现场回收: number[]; 预约上门: number[]; 大屏投递: number[]; 活动回收: number[] };
    appointmentFlow: { name: string; value: number }[];
    sorterStatus: { name: string; value: number; color: string }[];
    vehicles: { no: string; km: number; idle: number; overspeed: number; status: string }[];
    sites: { name: string; weight: number; online: boolean }[];
    unavailable?: string[];
}
 
export function emptyScreen(range: TimeRange = 'month'): ScreenData {
    return {
        range,
        axis: [],
        kpis: {
            todayWeightKg: 0,
            periodWeightTon: 0,
            resourceRate: 0,
            periodValue: 0,
            periodCarbonTon: 0,
            totalWeightTon: 0,
            totalParticipants: 0,
            totalPoints: 0,
            recyclableTon: 0,
            bulkTon: 0,
            elecTon: 0,
            fabricTon: 0,
            yearCarbonTon: 0,
            monthCarbonTon: 0,
            totalCarbonTon: 0,
            greenActions: 0,
            newParticipants: 0,
            participateRate: 0,
            pointsIssued: 0,
            pointsConsumed: 0,
            pointsBalance: 0,
            sorterOnline: 0,
            sorterTotal: 0,
            vehicleOnline: 0,
            vehicleTotal: 0,
            siteOnline: 0,
            siteTotal: 0,
            todayOrders: 0,
            todayAppointments: 0,
            pendingAppointments: 0,
            alerts: 0,
            healthAlerts: 0
        },
        wasteMix: [],
        recycleItems: [],
        trend: { weight: [], value: [], carbon: [] },
        yearCarbon: Array.from({ length: 12 }, () => 0),
        deptRank: [],
        classRank: [],
        majorRank: [],
        pointFlow: { issued: 0, transfer: 0, donate: 0, mall: 0, balance: 0 },
        participateTrend: [],
        deliverTrend: [],
        ordersByType: { axis: [], 现场回收: [], 预约上门: [], 大屏投递: [], 活动回收: [] },
        appointmentFlow: [
            { name: '预约', value: 0 },
            { name: '接单', value: 0 },
            { name: '完成', value: 0 }
        ],
        sorterStatus: [
            { name: '工作中', value: 0, color: '#22c55e' },
            { name: '休息', value: 0, color: '#f59e0b' },
            { name: '异常', value: 0, color: '#ef4444' },
            { name: '离线', value: 0, color: '#94a3b8' }
        ],
        vehicles: [],
        sites: [],
        unavailable: []
    };
}