- 移除实体:MES 删除 FlowMaterial(工艺物料)与 MixProductionTemplate(混产模板)全套(schema/ent 生成码/handler/logic),清理关联路由与种子 - 新增功能:产线清线(line_clearance handler + logic)、PLC 监控 WebSocket 实时推送(ws/plc_monitor_hub + handler) - 看板增强:新增管理屏与 KPI 组件(BoardManage/BoardKpi),调整演示屏 Mock 与各看板面板 - MES 完善:PLC 匹配/扭矩扫描/签收、工艺卡 PDF 与工单、AGV 链路、叫料/备料/在制品/短料预测等逻辑与前端调整 - 工位终端:删除离线面板 OfflinePanel,调整主界面/物料面板与 api/store/handler/路由 - WMS:AGV 托盘、物料与 MES 客户端调整及前端帮助/基础数据/叫料/托盘页 - 文档:更新产线API/客户问题/案例/部署手册/问题记录
284 lines
13 KiB
Vue
284 lines
13 KiB
Vue
<script setup>
|
||
defineOptions({ name: 'LineManagement' })
|
||
import { computed, onMounted, reactive, ref } from 'vue'
|
||
import { useRouter } from 'vue-router'
|
||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||
import request from '../utils/request'
|
||
import { can } from '../utils/perm'
|
||
import { fmtTime } from '../utils/format'
|
||
import PageHelp from '../components/PageHelp.vue'
|
||
import { helpLineManagement } from '../help'
|
||
import { dockCn } from '../utils/dockLabel'
|
||
|
||
const router = useRouter()
|
||
|
||
// 产线管理(块 E):页面区块
|
||
// ① 接驳台维护(CRUD) ② 工件位置纠正
|
||
// 2026-11-18 三菜单职责收口:原「① 工位状态 / ② 缓存状态」48 位点位展示已去重,统一到「PLC管理」页;
|
||
// 本页只保留接驳台表格里的「占用状态」一列(仍读同一批 PLC 位信号,供台账维护参考)。
|
||
// 2026-11-18 定稿:完工/暂存退库即自动释放点位台账,「末端取件释放」子块整体退役。
|
||
|
||
const loading = ref(false)
|
||
const lastRefresh = ref('')
|
||
|
||
// 工件六态映射(2026-10-19:原列直显英文枚举,与全项目口径统一)
|
||
const pieceStatusMap = { NEW: '待上线', ONLINE: '已上线', PROCESSING: '在制', SEMI_STORED: '在制品入库', DONE: '完工', SCRAPPED: '报废' }
|
||
const pieceStatusText = (s) => pieceStatusMap[s] || '—'
|
||
|
||
/* ===================== PLC 点位(仅保留接驳台占用态所需的 dock/jbt 位) ===================== */
|
||
const docksBits = ref([])
|
||
const jbt = ref(null)
|
||
// 工件位置核对
|
||
const mismatches = ref([])
|
||
|
||
async function loadBits() {
|
||
const d = await request.get('/plc/monitor/bits')
|
||
// 工位/缓存 48 位点位展示已统一到「PLC管理」页;这里只取接驳台占用态所需
|
||
docksBits.value = d.dock || []
|
||
jbt.value = d.jbt || null
|
||
}
|
||
|
||
async function loadPositionCheck() {
|
||
const d = await request.get('/plc/monitor/position-check')
|
||
mismatches.value = d?.mismatches || []
|
||
}
|
||
|
||
async function refreshAll() {
|
||
loading.value = true
|
||
try {
|
||
await Promise.all([loadBits(), loadPositionCheck()])
|
||
lastRefresh.value = new Date().toLocaleString()
|
||
} finally {
|
||
loading.value = false
|
||
}
|
||
}
|
||
|
||
// 位置纠正:MES 记录在工位、PLC 该工位无托盘 → 清为不在工位
|
||
const correcting = ref(0)
|
||
async function correctPosition(row) {
|
||
try {
|
||
await ElMessageBox.confirm(
|
||
`确认纠正工件 ${row.sn} 的位置?\n\nMES 记录:在工位 ${row.atStationNo}\nPLC 实际:工位 ${row.atStationNo} 无托盘\n\n纠正后该工件位置将置为「不在工位」,并写入操作日志。`,
|
||
'纠正工件位置',
|
||
{ type: 'warning', confirmButtonText: '确认纠正', cancelButtonText: '取消' }
|
||
)
|
||
} catch { return }
|
||
correcting.value = row.workpieceId
|
||
try {
|
||
await request.post('/plc/monitor/position-correct', { workpieceId: row.workpieceId })
|
||
ElMessage.success('已纠正')
|
||
await refreshAll()
|
||
} catch { /* 拦截器已提示 */ }
|
||
finally { correcting.value = 0 }
|
||
}
|
||
|
||
/* ===================== ③ 接驳台维护(CRUD) ===================== */
|
||
const list = ref([])
|
||
const filter = reactive({ dockCode: '', name: '', dockType: '', status: '' })
|
||
const TYPE_LABEL = { line: '产线', store: '库房', other: '其他' }
|
||
function typeLabel(t) { return TYPE_LABEL[t] || '其他' }
|
||
function tagType(t) { return t === 'line' ? 'success' : (t === 'store' ? 'warning' : 'info') }
|
||
// 显示层统一(2026-10-17 裁定):库房接驳台一律显示「库房接驳台」,不显示 JBT21 编号
|
||
// (JBT21 仅作后端映射,T7 2026-11-03 统一代号;PLC 侧对应点位于 PLC 监控页同样只显示「库房接驳台」)
|
||
function dockCodeLabel(code) { return dockCn(code, list.value) }
|
||
|
||
async function loadDocks() {
|
||
const params = {}
|
||
if (filter.dockCode.trim()) params.dockCode = filter.dockCode.trim()
|
||
if (filter.name.trim()) params.name = filter.name.trim()
|
||
if (filter.dockType) params.dockType = filter.dockType
|
||
if (filter.status) params.status = filter.status
|
||
const data = await request.get('/docks/maint', { params })
|
||
list.value = (data || []).slice().sort((a, b) => String(a.dockCode || '').localeCompare(String(b.dockCode || '')))
|
||
}
|
||
function search() { loadDocks() }
|
||
function reset() {
|
||
filter.dockCode = ''
|
||
filter.name = ''
|
||
filter.dockType = ''
|
||
filter.status = ''
|
||
loadDocks()
|
||
}
|
||
|
||
async function del(row) {
|
||
try {
|
||
await ElMessageBox.confirm(`确认删除接驳台 ${dockCodeLabel(row.dockCode)}(${row.name})?`, '删除确认',
|
||
{ type: 'warning', confirmButtonText: '确认删除', cancelButtonText: '取消' })
|
||
} catch { return }
|
||
try {
|
||
await request.delete(`/docks/${row.id}`)
|
||
ElMessage.success('已删除')
|
||
await loadDocks()
|
||
} catch { /* 拦截器已提示 */ }
|
||
}
|
||
|
||
async function toggleStatus(row) {
|
||
const next = row.status === 'ENABLED' ? 'DISABLED' : 'ENABLED'
|
||
try {
|
||
await request.post('/docks/status', { id: row.id, status: next })
|
||
ElMessage.success(next === 'ENABLED' ? '已启用' : '已停用')
|
||
await loadDocks()
|
||
} catch { /* 拦截器已提示 */ }
|
||
}
|
||
|
||
// 接驳台占用态(PLC 实时):按 dockCode 关联 ①/② 中的位信号
|
||
const palletByDock = computed(() => {
|
||
const m = {}
|
||
docksBits.value.forEach((b) => { m[b.code] = b.has })
|
||
if (jbt.value) m[jbt.value.code] = jbt.value.has
|
||
return m
|
||
})
|
||
|
||
onMounted(() => { refreshAll(); loadDocks() })
|
||
</script>
|
||
|
||
<template>
|
||
<div class="page">
|
||
<PageHelp :data="helpLineManagement" page="LineManagement" />
|
||
|
||
<el-alert type="info" :closable="false" class="tip" show-icon>
|
||
<template #title>本页管什么</template>
|
||
这里只管产线的台账与规则:接驳台主数据、这条线能生产哪些产品、工件位置对账。
|
||
完工与暂存退库会自动释放点位台账,无需人工释放。
|
||
看 PLC 实时点位(哪个位置有托盘、在途指令)请到「<el-link type="primary" :underline="false" @click="router.push('/plc-monitor')">PLC管理</el-link>」,
|
||
给工件下发工艺码、撤回或人工完成请到「<el-link type="primary" :underline="false" @click="router.push('/plc-send')">工位下发</el-link>」。
|
||
</el-alert>
|
||
|
||
<!-- ③ 接驳台维护 -->
|
||
<el-card class="block">
|
||
<template #header>
|
||
<div class="card-head">
|
||
<span>③ 接驳台维护</span>
|
||
</div>
|
||
</template>
|
||
<el-alert type="info" :closable="false" class="tip">
|
||
接驳台是产线与库房之间供 AGV 取送货的物理停靠位,为产线主数据(真源在 MES)。占用状态由 PLC 传感器实时读取,不可人工维护。
|
||
</el-alert>
|
||
<el-form inline :model="filter">
|
||
<el-form-item label="接驳台编码">
|
||
<el-input v-model="filter.dockCode" clearable style="width:160px" placeholder="精确匹配,如 DOCK01" @keyup.enter="search" />
|
||
</el-form-item>
|
||
<el-form-item label="接驳台名称">
|
||
<el-input v-model="filter.name" clearable style="width:180px" placeholder="名称模糊匹配" @keyup.enter="search" />
|
||
</el-form-item>
|
||
<el-form-item label="类型">
|
||
<el-select v-model="filter.dockType" clearable style="width:120px" placeholder="全部">
|
||
<el-option label="产线" value="line" />
|
||
<el-option label="库房" value="store" />
|
||
<el-option label="其他" value="other" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item label="状态">
|
||
<el-select v-model="filter.status" clearable style="width:110px" placeholder="全部">
|
||
<el-option label="启用" value="ENABLED" />
|
||
<el-option label="停用" value="DISABLED" />
|
||
</el-select>
|
||
</el-form-item>
|
||
<el-form-item>
|
||
<el-button type="primary" @click="search">查询</el-button>
|
||
<el-button @click="reset">重置</el-button>
|
||
</el-form-item>
|
||
</el-form>
|
||
|
||
<el-table :data="list" border size="small">
|
||
<el-table-column label="接驳台编码" width="140">
|
||
<template #default="{ row }">{{ dockCodeLabel(row.dockCode) }}</template>
|
||
</el-table-column>
|
||
<el-table-column prop="name" label="接驳台名称" min-width="200" show-overflow-tooltip />
|
||
<el-table-column label="类型" width="100" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag size="small" :type="tagType(row.dockType)">{{ typeLabel(row.dockType) }}</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="绑定工位" width="110" align="center">
|
||
<template #default="{ row }">{{ row.stationNo > 0 ? '工位' + row.stationNo : '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="占用状态" width="110" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag size="small" :type="palletByDock[row.dockCode] ? 'warning' : 'info'">
|
||
{{ palletByDock[row.dockCode] ? '有托盘' : '空闲' }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column prop="palletRef" label="托盘关联" min-width="160" show-overflow-tooltip>
|
||
<template #default="{ row }">{{ row.palletRef || '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="启用状态" width="90" align="center">
|
||
<template #default="{ row }">
|
||
<el-tag size="small" :type="row.status === 'ENABLED' ? 'success' : 'info'">
|
||
{{ row.status === 'ENABLED' ? '启用' : '停用' }}
|
||
</el-tag>
|
||
</template>
|
||
</el-table-column>
|
||
<el-table-column label="创建时间" width="170">
|
||
<template #default="{ row }">{{ fmtTime(row.createdAt) }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="150" align="center" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button v-if="can('produce.line.manage')" link size="small"
|
||
:type="row.status === 'ENABLED' ? 'warning' : 'success'"
|
||
@click="toggleStatus(row)">{{ row.status === 'ENABLED' ? '停用' : '启用' }}</el-button>
|
||
<el-popconfirm v-if="can('produce.line.manage')" :title="`确认删除接驳台 ${dockCodeLabel(row.dockCode)}?`" @confirm="del(row)">
|
||
<template #reference>
|
||
<el-button link type="danger" size="small">删除</el-button>
|
||
</template>
|
||
</el-popconfirm>
|
||
<span v-if="!can('produce.line.manage')">—</span>
|
||
</template>
|
||
</el-table-column>
|
||
<template #empty>
|
||
<el-empty description="暂无接驳台数据" />
|
||
</template>
|
||
</el-table>
|
||
</el-card>
|
||
|
||
<!-- ⑤ 工件位置纠正 -->
|
||
<el-card class="block">
|
||
<template #header>
|
||
<div class="card-head">
|
||
<span>④ 工件位置纠正</span>
|
||
<el-button size="small" :loading="loading" @click="refreshAll">核对</el-button>
|
||
</div>
|
||
</template>
|
||
<el-alert type="info" :closable="false" class="tip">
|
||
核对「MES 记录的工件物理位置」与「PLC 实际托盘位」:MES 记录工件在工位 n,但 PLC 工位 n 无托盘
|
||
⇒ 记录已过期/错位,可一键纠正为「不在工位」。纠正写入操作日志(plc_position_correct)。
|
||
当前待纠正 {{ mismatches.length }} 条。最后核对时间:{{ lastRefresh || '—' }}
|
||
</el-alert>
|
||
<el-table :data="mismatches" border size="small">
|
||
<el-table-column prop="sn" label="工件序列号" width="200" show-overflow-tooltip />
|
||
<el-table-column prop="orderNo" label="所属工单" min-width="150" show-overflow-tooltip />
|
||
<el-table-column prop="status" label="工件状态" width="110" align="center">
|
||
<template #default="{ row }">{{ pieceStatusText(row.status) }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="记录位置" width="110" align="center">
|
||
<template #default="{ row }">工位 {{ row.atStationNo }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="PLC 实际" width="110" align="center">
|
||
<template #default="{ row }">无托盘</template>
|
||
</el-table-column>
|
||
<el-table-column label="业务位置" width="120" align="center">
|
||
<template #default="{ row }">{{ row.curStationNo > 0 ? '工位 ' + row.curStationNo : '—' }}</template>
|
||
</el-table-column>
|
||
<el-table-column label="操作" width="120" align="center" fixed="right">
|
||
<template #default="{ row }">
|
||
<el-button v-if="can('produce.line.manage')" link type="warning" size="small"
|
||
:loading="correcting === row.workpieceId" @click="correctPosition(row)">纠正</el-button>
|
||
<span v-else>—</span>
|
||
</template>
|
||
</el-table-column>
|
||
<template #empty>
|
||
<el-empty description="无待纠正工件(MES 记录与 PLC 实际一致)" />
|
||
</template>
|
||
</el-table>
|
||
</el-card>
|
||
|
||
</div>
|
||
</template>
|
||
|
||
<style scoped>
|
||
.block { margin-bottom: 16px; }
|
||
.card-head { display: flex; justify-content: space-between; align-items: center; }
|
||
.tip { margin-bottom: 12px; }
|
||
</style>
|