feat: 移除工艺物料与混产模板实体、新增产线清线与 PLC 监控实时推送、看板双屏增强

- 移除实体: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/客户问题/案例/部署手册/问题记录
This commit is contained in:
SunYF
2026-11-19 08:31:05 +08:00
parent f8482b18f6
commit 4c4cda1d41
148 changed files with 2511 additions and 9735 deletions
@@ -1,6 +1,7 @@
<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'
@@ -9,9 +10,13 @@ import PageHelp from '../components/PageHelp.vue'
import { helpLineManagement } from '../help'
import { dockCn } from '../utils/dockLabel'
const router = useRouter()
// 产线管理(块 E):页面区块
// ① 工位状态 G1~G12 ② 缓存状态 C1~C15 ③ 接驳台维护(CRUD) ④ 当前产线可生产产品(混产配置) ⑤ 工件位置纠正
// ①/②/④ 读 PLC 实时点位(§4.1,一次性读取不轮询);③ 为接驳台主数据维护。
// ① 接驳台维护(CRUD) ② 工件位置纠正
// 2026-11-18 三菜单职责收口:原「① 工位状态 / ② 缓存状态」48 位点位展示已去重,统一到「PLC管理」页;
// 本页只保留接驳台表格里的「占用状态」一列(仍读同一批 PLC 位信号,供台账维护参考)。
// 2026-11-18 定稿:完工/暂存退库即自动释放点位台账,「末端取件释放」子块整体退役。
const loading = ref(false)
const lastRefresh = ref('')
@@ -20,22 +25,15 @@ const lastRefresh = ref('')
const pieceStatusMap = { NEW: '待上线', ONLINE: '已上线', PROCESSING: '在制', SEMI_STORED: '在制品入库', DONE: '完工', SCRAPPED: '报废' }
const pieceStatusText = (s) => pieceStatusMap[s] || '—'
/* ===================== ① ② ④ PLC 点位(工位 / 主线缓存) ===================== */
const stations = ref([])
const mains = ref([])
/* ===================== PLC 点位(仅保留接驳台占用态所需的 dock/jbt 位) ===================== */
const docksBits = ref([])
const jbt = ref(null)
// ④ 工件位置核对
// 工件位置核对
const mismatches = ref([])
// ④ 末端取件释放(末端下料检测位有工位在位信号,但无工位终端/接驳台、不下发装配工序码;取件无完成信号,占用台账须人工确认释放)
const endPoints = ref([])
const selectedEnd = ref([])
const releasing = ref(false)
async function loadBits() {
const d = await request.get('/plc/monitor/bits')
stations.value = d.station || []
mains.value = d.main || []
// 工位/缓存 48 位点位展示已统一到「PLC管理」页;这里只取接驳台占用态所需
docksBits.value = d.dock || []
jbt.value = d.jbt || null
}
@@ -43,51 +41,18 @@ async function loadBits() {
async function loadPositionCheck() {
const d = await request.get('/plc/monitor/position-check')
mismatches.value = d?.mismatches || []
if (!stations.value.length && d?.stations) stations.value = d.stations
}
async function loadEndPoints() {
const d = await request.get('/plc/monitor/end-points')
endPoints.value = d?.list || []
selectedEnd.value = []
}
async function refreshAll() {
loading.value = true
try {
await Promise.all([loadBits(), loadPositionCheck(), loadEndPoints()])
await Promise.all([loadBits(), loadPositionCheck()])
lastRefresh.value = new Date().toLocaleString()
} finally {
loading.value = false
}
}
// 末端取件释放:人工确认工件已从 G11/G12 取走,释放点位占用并写操作日志
async function releaseEndPoints() {
const rows = selectedEnd.value
if (!rows.length) {
ElMessage.warning('请先勾选要释放的点位记录')
return
}
const lines = rows.map((r) => `${r.pointNo}(${r.label})· ${r.sn || '无序列号'}`).join('\n')
try {
await ElMessageBox.confirm(
`确认以下工件已从末端取走并释放点位?\n\n${lines}\n\n释放后点位台账置为「空闲」,并写入操作日志(point_release_manual)。`,
'末端取件释放',
{ type: 'warning', confirmButtonText: '确认已取件', cancelButtonText: '取消' }
)
} catch { return }
releasing.value = true
try {
for (const r of rows) {
await request.post('/plc/monitor/release-end-point', { pointNo: r.pointNo })
}
ElMessage.success(`已释放 ${rows.length} 个点位`)
await loadEndPoints()
} catch { /* 拦截器已提示 */ }
finally { releasing.value = false }
}
// 位置纠正:MES 记录在工位、PLC 该工位无托盘 → 清为不在工位
const correcting = ref(0)
async function correctPosition(row) {
@@ -110,11 +75,6 @@ async function correctPosition(row) {
/* ===================== ③ 接驳台维护(CRUD) ===================== */
const list = ref([])
const filter = reactive({ dockCode: '', name: '', dockType: '', status: '' })
const dlg = reactive({
show: false,
dockCode: '', name: '', dockType: 'line', status: 'ENABLED'
})
const TYPE_LABEL = { line: '产线', store: '库房', other: '其他' }
function typeLabel(t) { return TYPE_LABEL[t] || '其他' }
function tagType(t) { return t === 'line' ? 'success' : (t === 'store' ? 'warning' : 'info') }
@@ -122,45 +82,6 @@ function tagType(t) { return t === 'line' ? 'success' : (t === 'store' ? 'warnin
// (JBT21 仅作后端映射,T7 2026-11-03 统一代号;PLC 侧对应点位于 PLC 监控页同样只显示「库房接驳台」)
function dockCodeLabel(code) { return dockCn(code, list.value) }
// 接驳台编码格式校验(运行期禁用正则:仅大写字母与数字,长度 2~16)。
function isDockCodeAlnum(code) {
const s = String(code || '').trim().toUpperCase()
if (s.length < 2 || s.length > 16) return false
for (let i = 0; i < s.length; i++) {
const c = s.charCodeAt(i)
const isUpper = c >= 65 && c <= 90 // A-Z
const isDigit = c >= 48 && c <= 57 // 0-9
if (!isUpper && !isDigit) return false
}
return true
}
// 接驳台编码规范(产线类必须为 DOCK 开头 + 数字,如 DOCK05;对应硬件工位,由末位编号派生)。
function isDockCodeStandard(code) {
const s = String(code || '').trim().toUpperCase()
if (s.length < 5 || s.slice(0, 4) !== 'DOCK') return false
for (let i = 4; i < s.length; i++) {
const c = s.charCodeAt(i)
if (c < 48 || c > 57) return false // 末段必须全为数字
}
return true
}
// 接驳台↔工位为硬件级对应关系:stationNo 由 dockCode 末位编号派生(DOCKnn → 工位 (nn+1)/2),不可人工编辑。
// 运行期不使用正则,用 charCodeAt 取末位连续数字。
function trailingNum(s) {
s = s || ''
let i = s.length
while (i > 0 && s.charCodeAt(i - 1) >= 48 && s.charCodeAt(i - 1) <= 57) i--
if (i === s.length) return 0
return parseInt(s.slice(i), 10)
}
const lineStationNo = computed(() => {
const n = trailingNum(dlg.dockCode)
if (!n) return 0
const s = Math.floor((n + 1) / 2)
return s >= 1 && s <= 12 ? s : 0
})
async function loadDocks() {
const params = {}
if (filter.dockCode.trim()) params.dockCode = filter.dockCode.trim()
@@ -179,36 +100,6 @@ function reset() {
loadDocks()
}
function openAdd() {
dlg.dockCode = ''
dlg.name = ''
dlg.dockType = 'line'
dlg.status = 'ENABLED'
dlg.show = true
}
async function save() {
const code = String(dlg.dockCode || '').trim().toUpperCase()
if (!isDockCodeAlnum(code)) {
return ElMessage.warning('接驳台编码必填,仅支持大写字母与数字(2~16 位),如 DOCK05')
}
if (dlg.dockType === 'line' && !isDockCodeStandard(code)) {
return ElMessage.warning('接驳台编码不规范(必须为 DOCK 开头+数字),请修正')
}
if (!String(dlg.name || '').trim()) return ElMessage.warning('接驳台名称必填')
try {
await request.post('/docks', {
dockCode: code,
name: String(dlg.name).trim(),
dockType: dlg.dockType,
status: dlg.status
})
ElMessage.success('新增成功')
dlg.show = false
await Promise.all([loadDocks(), loadBits()])
} catch { /* 拦截器已提示(编码重复等) */ }
}
async function del(row) {
try {
await ElMessageBox.confirm(`确认删除接驳台 ${dockCodeLabel(row.dockCode)}(${row.name})?`, '删除确认',
@@ -238,106 +129,26 @@ const palletByDock = computed(() => {
return m
})
/* ===================== ④ 混产配置:当前产线可生产产品 ===================== */
// 2026-11-16 纠偏:混产配置从工位编辑弹窗移到产线管理,明确为全产线共用配置(底层仍是全局单一在用混产模板)。
const productOptions = ref([])
const mixProducts = ref([])
const mixSavedCodes = ref([])
const mixSaving = ref(false)
const activeMix = reactive({ id: 0, name: '', remark: '' })
const mixChanged = computed(() => {
const a = mixProducts.value
const b = mixSavedCodes.value
return a.length !== b.length || a.some((c, i) => c !== b[i])
})
async function loadProductOptions() {
try {
const list = (await request.get('/product-types', { params: { isActive: 'true' } })) || []
productOptions.value = Array.isArray(list) ? list.filter((p) => p && p.code) : []
} catch { productOptions.value = [] }
}
async function loadMixProducts() {
try {
const list = (await request.get('/mix-templates'))?.list || []
const cur = list.find((r) => r.isActive) || list.find((r) => r.status === 'ACTIVE') || null
activeMix.id = cur ? Number(cur.id) : 0
activeMix.name = cur ? (cur.name || '') : ''
activeMix.remark = cur ? (cur.remark || '') : ''
const codes = cur ? (Array.isArray(cur.products) ? cur.products : String(cur.productCodes || '').split(',').map((s) => s.trim()).filter(Boolean)) : []
mixProducts.value = [...codes]
mixSavedCodes.value = [...codes]
} catch { /* 拦截器已提示 */ }
}
async function saveMixProducts() {
const codes = (mixProducts.value || []).filter(Boolean)
if (codes.length < 2) {
ElMessage.warning('可生产产品至少选 2 个')
return
}
try {
await ElMessageBox.confirm(
'此配置为全产线共用配置,修改后将影响所有工位的可混产范围。',
'保存确认',
{ type: 'warning', confirmButtonText: '确认保存', cancelButtonText: '取消' }
)
} catch { return }
mixSaving.value = true
try {
await request.post('/mix-templates/save', {
id: activeMix.id, name: activeMix.name || '产线混产模板',
productCodes: codes.join(','), remark: activeMix.remark, status: 'ACTIVE'
})
await loadMixProducts()
ElMessage.success('已保存')
} catch { /* 拦截器已提示 */ }
finally { mixSaving.value = false }
}
onMounted(() => { refreshAll(); loadDocks(); loadProductOptions(); loadMixProducts() })
onMounted(() => { refreshAll(); loadDocks() })
</script>
<template>
<div class="page">
<PageHelp :data="helpLineManagement" page="LineManagement" />
<el-card class="block">
<template #header>
<div class="card-head">
<span>产线点位(PLC 实时,一次性读取,不轮询)</span>
<el-button size="small" :loading="loading" @click="refreshAll">刷新</el-button>
</div>
</template>
<el-alert type="info" :closable="false" class="tip">
读产线布局说明 §4.1 的 48 位点位信号。● 表示有托盘,○ 表示空。打开页面自动读取一次,需最新状态点「刷新」。
</el-alert>
<div class="group">
<div class="group-title">① 工位托盘位(G1~G12)</div>
<div class="chips">
<div class="chip" v-for="b in stations" :key="b.code">
<span class="dot" :class="b.has ? 'on' : 'off'"></span>{{ b.code }}
</div>
<el-empty v-if="!stations.length" description="暂无数据" :image-size="40" />
</div>
</div>
<div class="group">
<div class="group-title">② 主线缓存位(C1~C15)</div>
<div class="chips">
<div class="chip" v-for="b in mains" :key="b.code">
<span class="dot" :class="b.has ? 'on' : 'off'"></span>{{ b.code }}
</div>
<el-empty v-if="!mains.length" description="暂无数据" :image-size="40" />
</div>
</div>
</el-card>
<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>
<el-button v-if="can('produce.line.manage')" size="small" type="primary" @click="openAdd">新增接驳台</el-button>
</div>
</template>
<el-alert type="info" :closable="false" class="tip">
@@ -421,29 +232,11 @@ onMounted(() => { refreshAll(); loadDocks(); loadProductOptions(); loadMixProduc
</el-table>
</el-card>
<!-- ④ 混产配置:当前产线可生产产品(写入现有在用混产模板,底层表/清线逻辑不动,产线级口径) -->
<el-card class="block">
<template #header>
<div class="card-head">
<span>④ 当前产线可生产产品</span>
<el-button size="small" :loading="mixSaving" type="primary" :disabled="!mixChanged" @click="saveMixProducts">保存配置</el-button>
</div>
</template>
<el-alert type="info" :closable="false" class="tip">
全产线共用一套配置:勾选的产品可在同一套工位绑定下生产;换到清单外的产品需先清线。保存后立即生效(影响建单校验与清线校验),至少 2 个产品。
</el-alert>
<el-select v-model="mixProducts" multiple filterable collapse-tags collapse-tags-tooltip
placeholder="选择本产线可生产的产品(至少 2 个)" style="width:100%;margin-top:8px">
<el-option v-for="p in productOptions" :key="p.code" :value="p.code"
:label="p.name + (p.code ? ' / ' + p.code : '')" />
</el-select>
</el-card>
<!-- ⑤ 工件位置纠正 -->
<el-card class="block">
<template #header>
<div class="card-head">
<span>⑤ 工件位置纠正</span>
<span>④ 工件位置纠正</span>
<el-button size="small" :loading="loading" @click="refreshAll">核对</el-button>
</div>
</template>
@@ -478,78 +271,8 @@ onMounted(() => { refreshAll(); loadDocks(); loadProductOptions(); loadMixProduc
<el-empty description="无待纠正工件(MES 记录与 PLC 实际一致)" />
</template>
</el-table>
<el-divider class="sub-divider" />
<!-- ④-2 末端取件释放子块:末端下料检测位有工位在位信号但无工位终端/接驳台/装配工序码,取件无完成信号,须人工确认释放 -->
<div class="sub-title">末端取件释放(G11 / G12 下料检测位)</div>
<el-alert type="warning" :closable="false" class="tip">
末端下料检测位有工位在位信号,但没有工位终端、没有接驳台,也不下发 PLC 装配工序码(人工确认工位);取件动作没有「已取走」完成信号,点位台账不会自动清,必须确认实物已取走后人工释放。释放写入操作日志。当前占用 {{ endPoints.length }} 条。
</el-alert>
<el-table :data="endPoints" border size="small" @selection-change="(rows) => (selectedEnd = rows)">
<el-table-column type="selection" width="42" />
<el-table-column label="点位" width="220" align="center">
<template #default="{ row }">
{{ row.pointNo === 'END-U' ? '下料检测位 G11(上排)' : '下料检测位 G12(下排)' }}({{ row.pointNo }})
</template>
</el-table-column>
<el-table-column prop="sn" label="工件序列号" min-width="180" show-overflow-tooltip>
<template #default="{ row }">{{ row.sn || '—' }}</template>
</el-table-column>
<el-table-column label="来源(所属工单)" min-width="160" show-overflow-tooltip>
<template #default="{ row }">{{ row.orderNo || '—' }}</template>
</el-table-column>
<el-table-column label="占用时间" width="170">
<template #default="{ row }">{{ row.updatedAt ? fmtTime(row.updatedAt) : '—' }}</template>
</el-table-column>
<template #empty>
<el-empty description="末端下料检测位均空闲" :image-size="40" />
</template>
</el-table>
<div class="sub-actions">
<el-button v-if="can('produce.line.manage')" type="warning" size="small"
:disabled="!selectedEnd.length" :loading="releasing" @click="releaseEndPoints">
确认已取件{{ selectedEnd.length ? `(${selectedEnd.length})` : '' }}
</el-button>
<span v-if="!can('produce.line.manage')" class="no-perm">无「产线管理」权限,不可释放</span>
</div>
</el-card>
<!-- ③ 接驳台新增弹窗 -->
<el-dialog v-model="dlg.show" title="新增接驳台" width="480px">
<el-form :model="dlg" label-width="100px">
<el-form-item label="接驳台编码" required>
<el-input v-model="dlg.dockCode" maxlength="16" placeholder="如 DOCK05(大写字母与数字)" />
</el-form-item>
<el-form-item label="接驳台名称" required>
<el-input v-model="dlg.name" maxlength="64" placeholder="如 产线接驳台 DOCK05(工位3)" />
</el-form-item>
<el-form-item label="类型" required>
<el-radio-group v-model="dlg.dockType">
<el-radio value="line">产线</el-radio>
<el-radio value="store">库房</el-radio>
<el-radio value="other">其他</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="绑定工位" required>
<template v-if="dlg.dockType === 'line'">
<span style="color:#303133">工位 {{ lineStationNo || '—' }}</span>
<div style="color:#909399;font-size:12px;margin-top:4px">由接驳台编码派生(DOCKnn → 工位),硬件级对应关系,不可编辑</div>
</template>
<span v-else style="color:#909399">非产线类型不绑定工位</span>
</el-form-item>
<el-form-item label="启用状态">
<el-radio-group v-model="dlg.status">
<el-radio value="ENABLED">启用</el-radio>
<el-radio value="DISABLED">停用</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="dlg.show = false">取消</el-button>
<el-button type="primary" @click="save">保存</el-button>
</template>
</el-dialog>
</div>
</template>
@@ -557,18 +280,4 @@ onMounted(() => { refreshAll(); loadDocks(); loadProductOptions(); loadMixProduc
.block { margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.tip { margin-bottom: 12px; }
.sub-title { font-weight: 600; margin: 4px 0 8px; color: #303133; }
.sub-divider { margin: 16px 0 12px; }
.sub-actions { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.no-perm { color: #909399; font-size: 12px; }
.group { margin-bottom: 10px; }
.group-title { font-weight: 600; margin: 6px 0; color: #606266; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 28px; align-items: center; }
.chip {
display: inline-flex; align-items: center; gap: 6px;
border: 1px solid #dcdfe6; border-radius: 4px; padding: 4px 8px; font-size: 13px; background: #fafafa;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot.on { background: #67c23a; box-shadow: 0 0 0 2px rgba(103,194,58,.25); }
.dot.off { background: #c0c4cc; }
</style>