feat: 完成产线与仓储系统多模块迭代升级
本次迭代覆盖MES与WMS核心业务: 1. 新增接驳台托盘传感器读取与AGV对接能力 2. 完善工单排产、备料流程与权限体系拆分 3. 优化看板接口与前端路由、样式 4. 新增操作日志、库存盘点与角色保护逻辑 5. 修复代理地址、BOM保存等已知问题
This commit is contained in:
@@ -1,157 +1,253 @@
|
||||
import { Card, Progress, Tag, Typography } from '@douyinfe/semi-ui';
|
||||
import type { EChartsOption } from 'echarts';
|
||||
import type { DashboardData } from '../types';
|
||||
import type { DashboardData, Station } from '../types';
|
||||
import { EChart } from '../components/EChart';
|
||||
|
||||
const gridLabel = {
|
||||
color: '#8fa3bf',
|
||||
fontSize: 13,
|
||||
const C = {
|
||||
cyan: '#22d3ee',
|
||||
green: '#34d399',
|
||||
blue: '#60a5fa',
|
||||
amber: '#fbbf24',
|
||||
panel: '#0d1a33',
|
||||
border: 'rgba(56,189,248,0.22)',
|
||||
text: '#e2e8f0',
|
||||
sub: '#94a3b8',
|
||||
dim: '#64748b',
|
||||
};
|
||||
|
||||
export function ProductionBoard({ data }: { data: DashboardData }) {
|
||||
const { production, progress, trends } = data;
|
||||
const st = production.stationSummary;
|
||||
const prog =
|
||||
progress.totalQty > 0 ? (progress.completedQty / progress.totalQty) * 100 : 0;
|
||||
const statusColor: Record<Station['status'], string> = {
|
||||
running: C.green,
|
||||
idle: C.blue,
|
||||
alarm: '#f87171',
|
||||
offline: '#475569',
|
||||
};
|
||||
|
||||
const ringOption: EChartsOption = {
|
||||
tooltip: {
|
||||
formatter: '{b}: {c}({d}%)',
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'pie',
|
||||
radius: ['62%', '82%'],
|
||||
silent: true,
|
||||
label: { show: true, position: 'center', formatter: '{value}%'.replace('{value}', String(production.qualifiedRate)), fontSize: 30, fontWeight: 'bold', color: '#00d68f' },
|
||||
data: [
|
||||
{ value: production.qualityOk, name: '合格', itemStyle: { color: '#00d68f' } },
|
||||
{ value: production.qualityNg, name: '不合格', itemStyle: { color: '#ff5252' } },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
const gridLabel = { color: '#8fa3bf', fontSize: 13 };
|
||||
|
||||
export function ProductionBoard({ data }: { data: DashboardData }) {
|
||||
const { production, progress, trends, equipment } = data;
|
||||
|
||||
const trendOption: EChartsOption = {
|
||||
grid: { left: 40, right: 16, top: 28, bottom: 24 },
|
||||
grid: { left: 48, right: 20, top: 28, bottom: 28 },
|
||||
tooltip: { trigger: 'axis' },
|
||||
legend: { textStyle: gridLabel, top: 0, data: ['当日产量', '合格率'] },
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: trends.production.map((t) => t.time),
|
||||
axisLine: { lineStyle: { color: '#335' } },
|
||||
axisLabel: gridLabel,
|
||||
},
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: '产量',
|
||||
splitLine: { lineStyle: { color: '#1f2a3f' } },
|
||||
axisLabel: gridLabel,
|
||||
},
|
||||
{
|
||||
type: 'value',
|
||||
name: '合格率',
|
||||
min: 80,
|
||||
max: 100,
|
||||
splitLine: { show: false },
|
||||
axisLabel: gridLabel,
|
||||
},
|
||||
],
|
||||
yAxis: {
|
||||
type: 'value',
|
||||
name: '产量',
|
||||
splitLine: { lineStyle: { color: '#1f2a3f' } },
|
||||
axisLabel: gridLabel,
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '当日产量',
|
||||
name: '日产量',
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
data: trends.production.map((t) => t.output),
|
||||
itemStyle: { color: '#36a3f7' },
|
||||
areaStyle: { color: 'rgba(54,163,247,0.2)' },
|
||||
},
|
||||
{
|
||||
name: '合格率',
|
||||
type: 'line',
|
||||
yAxisIndex: 1,
|
||||
smooth: true,
|
||||
data: trends.production.map((t) => t.qualifiedRate),
|
||||
itemStyle: { color: '#00d68f' },
|
||||
itemStyle: { color: C.cyan },
|
||||
areaStyle: { color: 'rgba(34,211,238,0.18)' },
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 }}>
|
||||
<Card title="产线运行状态" style={{ gridColumn: 'span 2' }}>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 14 }}>
|
||||
<Kpi value={production.outputToday} label="今日产量" sub={`目标 ${production.targetToday}`} color={C.cyan} />
|
||||
<Kpi value={production.passCount} label="一次通过" sub="件 · 全工序合格" color={C.green} />
|
||||
<Kpi value={production.inLine} label="在制工件" sub="产线流转中" color={C.blue} />
|
||||
<Kpi
|
||||
value={production.deviceOnline}
|
||||
label="设备在线"
|
||||
sub={`共 ${production.deviceTotal} 台 · 全部在线`}
|
||||
color={C.green}
|
||||
/>
|
||||
|
||||
<Panel title="近 7 日产量趋势" style={{ gridColumn: 'span 2' }}>
|
||||
<EChart option={trendOption} height={230} />
|
||||
</Panel>
|
||||
|
||||
<Panel title="当前订单" style={{ gridColumn: 'span 2' }} accent>
|
||||
<div
|
||||
style={{
|
||||
display: 'grid',
|
||||
gridTemplateColumns: 'repeat(4, 1fr)',
|
||||
gap: 12,
|
||||
textAlign: 'center',
|
||||
gridTemplateColumns: 'auto 1fr',
|
||||
rowGap: 10,
|
||||
columnGap: 14,
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<Cell value={st.running} label="运行中" color="#00d68f" />
|
||||
<Cell value={st.idle} label="空闲" color="#36a3f7" />
|
||||
<Cell value={st.alarm} label="报警" color="#ff5252" />
|
||||
<Cell value={st.offline} label="离线" color="#8fa3bf" />
|
||||
</div>
|
||||
</Card>
|
||||
<Field label="合同号" />
|
||||
<span style={{ fontSize: 15, fontWeight: 500 }}>{progress.contractNo || progress.orderNo}</span>
|
||||
|
||||
<Card title="当日产量">
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 8 }}>
|
||||
<span style={{ fontSize: 36, fontWeight: 700, color: '#36a3f7' }}>
|
||||
{production.outputToday}
|
||||
<Field label="产品" />
|
||||
<span style={{ fontSize: 14 }}>{progress.productName}</span>
|
||||
|
||||
<Field label="负责人" />
|
||||
<span style={{ fontSize: 14, color: C.cyan }}>{progress.owner || '—'}</span>
|
||||
|
||||
<Field label="工期" />
|
||||
<span style={{ fontSize: 14 }}>
|
||||
{progress.planStart} ~ {progress.planEnd}
|
||||
<span style={{ marginLeft: 10, color: progress.remainDays >= 0 ? C.green : C.amber }}>
|
||||
剩余 {Math.max(progress.remainDays, 0)} 天
|
||||
</span>
|
||||
</span>
|
||||
<span style={{ color: '#8fa3bf' }}>/ {production.targetToday}</span>
|
||||
</div>
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<Typography.Text type="tertiary">日计划达成率</Typography.Text>
|
||||
<Progress
|
||||
percent={
|
||||
production.targetToday
|
||||
? Math.round((production.outputToday / production.targetToday) * 100)
|
||||
: 0
|
||||
}
|
||||
showInfo
|
||||
style={{ marginTop: 8 }}
|
||||
|
||||
<div style={{ marginTop: 16 }}>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'baseline',
|
||||
marginBottom: 8,
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 13, color: C.sub }}>完成度</span>
|
||||
<span style={{ fontSize: 13, color: C.sub }}>
|
||||
<span style={{ fontSize: 20, fontWeight: 500, color: C.cyan }}>{progress.doneQty}</span>
|
||||
{' / '}
|
||||
{progress.totalQty} 台
|
||||
</span>
|
||||
</div>
|
||||
<Bar percent={progress.progress} />
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 10, marginTop: 16 }}>
|
||||
<Chip label="工序进度" value={`${progress.processDone} / ${progress.processTotal} 序`} color={C.cyan} />
|
||||
<Chip label="当前工序" value={progress.currentProcess || '—'} color={C.blue} />
|
||||
<Chip
|
||||
label="责任追溯"
|
||||
value={progress.traceable ? `${progress.traceStepCount} 条 · 全程可追溯` : '待采集'}
|
||||
color={progress.traceable ? C.green : C.dim}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</Panel>
|
||||
|
||||
<Card title="合格率">
|
||||
<EChart option={ringOption} height={170} />
|
||||
</Card>
|
||||
|
||||
<Card title="工单进度">
|
||||
<div style={{ marginBottom: 8 }}>
|
||||
<Typography.Text strong>{progress.orderNo}</Typography.Text>
|
||||
<Tag size="small" style={{ marginLeft: 8 }} color="green">
|
||||
{progress.status}
|
||||
</Tag>
|
||||
<Panel title="工位状态(12 工位 · 扫码枪 + 拧紧枪)" style={{ gridColumn: 'span 4' }}>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(6, 1fr)', gap: 10 }}>
|
||||
{equipment.map((s) => (
|
||||
<div
|
||||
key={s.id}
|
||||
style={{
|
||||
border: `1px solid ${statusColor[s.status]}55`,
|
||||
borderLeft: `3px solid ${statusColor[s.status]}`,
|
||||
borderRadius: 6,
|
||||
padding: '8px 10px',
|
||||
background: 'rgba(255,255,255,0.02)',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<span style={{ fontSize: 13, fontWeight: 500 }}>{s.name}</span>
|
||||
<span style={{ fontSize: 11, color: statusColor[s.status] }}>
|
||||
{s.status === 'running'
|
||||
? '作业中'
|
||||
: s.status === 'idle'
|
||||
? '待料'
|
||||
: s.status === 'alarm'
|
||||
? '异常'
|
||||
: '离线'}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ fontSize: 11, color: C.dim, marginTop: 4 }}>
|
||||
{s.currentOperator || '—'}
|
||||
</div>
|
||||
{s.currentSn && <div style={{ fontSize: 11, color: C.sub, marginTop: 2 }}>{s.currentSn}</div>}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<Typography.Text type="tertiary">{progress.productName}</Typography.Text>
|
||||
<div style={{ margin: '10px 0' }}>
|
||||
<Typography.Text>
|
||||
完成 {progress.completedQty} / {progress.totalQty}
|
||||
</Typography.Text>
|
||||
<div style={{ marginTop: 12, fontSize: 12, color: C.dim }}>
|
||||
运行中 {production.stationSummary.running} · 待料 {production.stationSummary.idle} · 离线{' '}
|
||||
{production.stationSummary.offline}
|
||||
</div>
|
||||
<Progress percent={Math.round(prog)} showInfo stroke="#5cabff" />
|
||||
<div style={{ marginTop: 12 }}>
|
||||
<Typography.Text type="secondary">当前工序:{progress.currentProcess}</Typography.Text>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card title="产量与合格率趋势" style={{ gridColumn: 'span 4' }}>
|
||||
<EChart option={trendOption} height={280} />
|
||||
</Card>
|
||||
</Panel>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Cell({ value, label, color }: { value: number; label: string; color: string }) {
|
||||
function Field({ label }: { label: string }) {
|
||||
return <span style={{ fontSize: 12, color: C.dim }}>{label}</span>;
|
||||
}
|
||||
|
||||
function Kpi({ value, label, sub, color }: { value: number; label: string; sub: string; color: string }) {
|
||||
return (
|
||||
<div>
|
||||
<div style={{ fontSize: 32, fontWeight: 600, color }}>{value}</div>
|
||||
<div style={{ color: '#8fa3bf', fontSize: 13 }}>{label}</div>
|
||||
<div
|
||||
style={{
|
||||
background: C.panel,
|
||||
border: `1px solid ${C.border}`,
|
||||
borderRadius: 8,
|
||||
padding: '16px 18px',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: 12, color: C.sub }}>{label}</div>
|
||||
<div style={{ fontSize: 32, fontWeight: 500, color, lineHeight: 1.3 }}>{value}</div>
|
||||
<div style={{ fontSize: 11, color: C.dim }}>{sub}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function Panel({
|
||||
title,
|
||||
children,
|
||||
style,
|
||||
accent,
|
||||
}: {
|
||||
title: string;
|
||||
children: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
accent?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
background: C.panel,
|
||||
border: `1px solid ${accent ? 'rgba(34,211,238,0.42)' : C.border}`,
|
||||
borderRadius: 8,
|
||||
padding: '14px 16px',
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 13,
|
||||
fontWeight: 500,
|
||||
color: accent ? C.cyan : C.text,
|
||||
marginBottom: 12,
|
||||
letterSpacing: 0.5,
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Bar({ percent }: { percent: number }) {
|
||||
const p = Math.max(0, Math.min(100, percent));
|
||||
return (
|
||||
<div style={{ height: 8, background: '#1e293b', borderRadius: 4, overflow: 'hidden' }}>
|
||||
<div style={{ width: `${p}%`, height: '100%', background: C.cyan, transition: 'width 0.6s ease' }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Chip({ label, value, color }: { label: string; value: string; color: string }) {
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
border: `1px solid ${color}44`,
|
||||
borderRadius: 6,
|
||||
padding: '8px 10px',
|
||||
background: 'rgba(255,255,255,0.02)',
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: 11, color: C.dim }}>{label}</div>
|
||||
<div style={{ fontSize: 13, color, marginTop: 3 }}>{value}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user