feat: 同步失败台账双向可重试 + 拧紧枪按工位配置 + 虚拟工位体系 + 去Redis与文档口径对齐

- 同步失败台账:MES/WMS 双端新增台账与页面,跨系统通知失败落台账、人工重试或标记已处理,不自动重传;重试前先判对端终态;叫料、配送、出库回写失败提示指向台账;补幂等建表脚本与菜单权限。
- 拧紧枪:新增按工位配置页,展示控制器地址与三把枪通道号(仅供查看,不参与采集校验);「允许手填」由全局开关改为每工位开关,关闭时校验该工位已配控制器;终端启动/登录上报配置并按本工位拉取,扭矩手填框按本工位置灰;补全局值迁移到各工位的脚本。
- 工位体系:终端未配置工位号时登录页可选(含虚拟工位),固定工位模式保留;虚拟/线下位不叫料、不退料、不作转产目标,未采集绑定放行并说明原因;叫料期望接驳台改为选填。
- AGV与出库:补「出库单已送达」回写;空车回充、接驳台传感器失联、配送状态更新失败均落预警或留痕并提示人工核对;人工出库不引入送达状态;出库单支持目标工位/接驳台并扩展导出列。
- 基础设施:看板缓存由Redis改为MES进程内实现,文档与启动脚本同步去Redis;扫码监听支持多地址、端口被占自动降级;PLC对账与工位报警在MES不可达时降级放行并留日志。
- 文档与帮助:案例与部署手册按实测订正(工位绑定、菜单名称、补料由班组长代提、菜单覆盖对照、虚拟工位);迁移脚本改为本地即时执行并登记7个已执行脚本;三端页面帮助改为「业务/操作/影响范围/后果」四要素。
- 测试:新增独立Go模块,按三个业务场景做真实HTTP与真实写库的流水测试,含运行报告。
This commit is contained in:
SunYF
2026-11-09 18:58:47 +08:00
parent 5e2640c13a
commit af554cea75
149 changed files with 35119 additions and 296 deletions
+1 -9
View File
@@ -34,13 +34,6 @@
<el-switch v-model="form.torqueNgAlert" />
<div class="tip">开启(默认)后,拧紧扭矩不合格立即在预警中心产生报警;关闭则只记录不合格标记、不弹报警</div>
</el-form-item>
<el-form-item label="拧紧枪数据输入">
<el-radio-group v-model="form.torqueManualInput">
<el-radio value="forbid">禁止手填(默认)</el-radio>
<el-radio value="allow">允许手填</el-radio>
</el-radio-group>
<div class="tip">禁止手填(默认):扭矩必须真实采集,符合客户质量追溯要求;允许手填:拧紧枪离线/缺失时,工位终端开放手动录入扭矩输入框</div>
</el-form-item>
<el-form-item label="多工单缓存策略">
<el-radio-group v-model="form.multiOrderCachePolicy">
<el-radio value="physical">物理优先(默认)</el-radio>
@@ -111,7 +104,7 @@ const loading = ref(false)
const saving = ref(false)
const testing = ref(false)
const testMsg = ref('')
const form = reactive({ wmsBaseURL: '', demandDays: 5, extrapWindow: 3, extrapCap: 365, logRetentionDays: 0, pipelineCache: 0, allowCrossDay: 1, allowBorrow: 1, torqueNgAlert: true, dashboardRefreshSeconds: 5, archiveRemindDays: 7, dashboardTitle: '', dashboardVoice: true, torqueManualInput: 'forbid', multiOrderCachePolicy: 'physical', agvUnloadTimeoutMinutes: 5 })
const form = reactive({ wmsBaseURL: '', demandDays: 5, extrapWindow: 3, extrapCap: 365, logRetentionDays: 0, pipelineCache: 0, allowCrossDay: 1, allowBorrow: 1, torqueNgAlert: true, dashboardRefreshSeconds: 5, archiveRemindDays: 7, dashboardTitle: '', dashboardVoice: true, multiOrderCachePolicy: 'physical', agvUnloadTimeoutMinutes: 5 })
const info = ref({})
async function load() {
@@ -132,7 +125,6 @@ async function load() {
archiveRemindDays: data.archiveRemindDays ?? 7,
dashboardTitle: data.dashboardTitle || '',
dashboardVoice: data.dashboardVoice ?? true,
torqueManualInput: data.torqueManualInput || 'forbid',
multiOrderCachePolicy: data.multiOrderCachePolicy || 'physical',
agvUnloadTimeoutMinutes: data.agvUnloadTimeoutMinutes ?? 5
})
@@ -0,0 +1,115 @@
<template>
<div class="sync-failure-page">
<el-alert type="warning" :closable="false" show-icon style="margin-bottom:12px"
title="跨系统通知失败台账"
description="只记录「本地事务已提交、对端通知失败」的回调;系统不自动重试,请人工确认对端状态后点「重试」。重试只重放通知,绝不重跑本地业务。部署时需先手工执行 sync_failure 建表迁移 SQL。" />
<el-form inline size="small" style="margin-bottom:8px">
<el-form-item label="状态">
<el-select v-model="filters.status" clearable placeholder="全部" style="width:130px" @change="load">
<el-option label="待处理" value="PENDING" />
<el-option label="已成功" value="SUCCESS" />
<el-option label="已终止" value="DEAD" />
</el-select>
</el-form-item>
<el-form-item label="业务类型">
<el-input v-model="filters.bizType" clearable placeholder="如 outbound.delivered" style="width:190px" @keyup.enter="load" />
</el-form-item>
<el-form-item>
<el-button type="primary" :loading="loading" @click="load">刷新</el-button>
</el-form-item>
</el-form>
<el-table :data="rows" v-loading="loading" border size="small" style="width:100%">
<el-table-column prop="id" label="ID" width="70" />
<el-table-column prop="direction" label="方向" width="110" />
<el-table-column prop="bizType" label="业务类型" width="170" />
<el-table-column prop="bizKey" label="业务键" min-width="150" show-overflow-tooltip />
<el-table-column prop="endpoint" label="重放端点" min-width="210" show-overflow-tooltip />
<el-table-column prop="errorMsg" label="失败原因" min-width="200" show-overflow-tooltip />
<el-table-column label="状态" width="90" align="center">
<template #default="{ row }">
<el-tag :type="row.status === 'SUCCESS' ? 'success' : (row.status === 'DEAD' ? 'info' : 'danger')" size="small">
{{ statusText(row.status) }}
</el-tag>
</template>
</el-table-column>
<el-table-column prop="retryCount" label="重试次数" width="90" align="center" />
<el-table-column label="发生时间" width="150">
<template #default="{ row }">{{ fmtTime(row.createdAt) }}</template>
</el-table-column>
<el-table-column label="操作" width="160" fixed="right" align="center">
<template #default="{ row }">
<el-button v-if="row.status !== 'SUCCESS'" link type="primary" size="small" :loading="busyId === row.id" @click="retry(row)">重试</el-button>
<el-button v-if="row.status !== 'SUCCESS'" link type="info" size="small" @click="ignore(row)">标记已处理</el-button>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script setup>
import { onMounted, reactive, ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import request from '../utils/request'
const rows = ref([])
const loading = ref(false)
const busyId = ref(null)
const filters = reactive({ status: '', bizType: '' })
function statusText(s) {
return s === 'SUCCESS' ? '已成功' : (s === 'DEAD' ? '已终止' : '待处理')
}
function fmtTime(ts) {
if (!ts) return '-'
return new Date(Number(ts) * 1000).toLocaleString()
}
async function load() {
loading.value = true
try {
const res = await request.get('/sync-failures', { params: { status: filters.status, bizType: filters.bizType } })
const payload = Array.isArray(res) ? res : (res?.data ?? res?.data?.data ?? [])
rows.value = Array.isArray(payload) ? payload : []
} catch (e) {
ElMessage.error(e?.message || '加载同步失败台账失败')
} finally {
loading.value = false
}
}
async function retry(row) {
busyId.value = row.id
try {
const res = await request.post('/sync-failures/retry', {}, { params: { id: row.id } })
const data = res?.data ?? res
ElMessage.success(data?.note || '重试成功')
await load()
} catch (e) {
ElMessage.error(e?.message || '重试失败')
} finally {
busyId.value = null
}
}
async function ignore(row) {
try {
await ElMessageBox.confirm('确认该失败已在线下处理?标记后本行不再重试。', '标记已处理', { type: 'warning' })
} catch { return }
try {
await request.post('/sync-failures/ignore', {}, { params: { id: row.id } })
ElMessage.success('已标记')
await load()
} catch (e) {
ElMessage.error(e?.message || '标记失败')
}
}
onMounted(load)
</script>
<style scoped>
.sync-failure-page { padding: 4px; }
</style>
@@ -0,0 +1,151 @@
<template>
<div>
<el-alert type="info" :closable="false" show-icon style="margin-bottom:12px">
<template #title>拧紧枪接入说明</template>
<div>
本系统现支持阿特拉斯控制器 Open Protocol 接入。三把枪按通道号配置<strong>仅供查看</strong>;
实际拧紧数据收集<strong>不区分通道、不校验、不拦截</strong>,即便采集到的数据不在本页配置内也照常收录。
</div>
<div style="margin-top:6px">
「允许手填」<strong>按工位配置</strong>:实体工位连控制器可关闭手填,虚拟工位不连控制器默认允许手填。
关闭某工位手填时,须先填写该工位的控制器地址;没有控制器地址的工位不允许关闭。
</div>
<div style="margin-top:6px">
本页编辑仅保存本系统的展示记录,<strong>不下发工位终端</strong>;控制器地址等初始值由工位终端启动时上报本终端配置文件生成,页面已有配置时不会被覆盖。工位终端按自己的工位号读取本页的允许手填状态。
</div>
</el-alert>
<el-card shadow="never">
<template #header>
<div class="card-header">
<span>按工位配置拧紧枪</span>
<div>
<el-input v-model="keyword" placeholder="按工位号或名称筛选" clearable style="width:200px" />
<el-button type="primary" :loading="saving" @click="save">保存配置</el-button>
</div>
</div>
</template>
<el-table :data="filtered" v-loading="loading" border size="small" style="width:100%">
<el-table-column prop="stationNo" label="工位号" width="85" align="center" />
<el-table-column prop="stationName" label="工位名称" width="135" />
<el-table-column label="工位类型" width="115" align="center">
<template #default="{ row }">
<el-tag size="small" :type="row.stationType === 'LINE' ? 'success' : 'info'" effect="plain">
{{ row.stationType === 'LINE' ? '产线工位' : '线下虚拟位' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="控制器地址" min-width="180">
<template #default="{ row }">
<el-input v-model="row.controllerAddr" maxlength="64" clearable placeholder="如 127.0.0.1:4545" />
</template>
</el-table-column>
<el-table-column label="枪1通道号" width="125">
<template #default="{ row }">
<el-input v-model="row.gun1Channel" maxlength="16" clearable />
</template>
</el-table-column>
<el-table-column label="枪2通道号" width="125">
<template #default="{ row }">
<el-input v-model="row.gun2Channel" maxlength="16" clearable />
</template>
</el-table-column>
<el-table-column label="枪3通道号" width="125">
<template #default="{ row }">
<el-input v-model="row.gun3Channel" maxlength="16" clearable />
</template>
</el-table-column>
<el-table-column label="允许手填" width="110" align="center">
<template #default="{ row }">
<el-switch v-model="row.manualInput" active-value="allow" inactive-value="forbid" />
</template>
</el-table-column>
<el-table-column label="控制器接入" width="110" align="center">
<template #default="{ row }">
<el-tag size="small" :type="row.enable ? 'success' : 'info'" effect="plain">
{{ row.enable ? '已启用' : '未启用' }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="终端上报时间" width="165">
<template #default="{ row }">
<span>{{ row.reportedAt || '未上报' }}</span>
</template>
</el-table-column>
</el-table>
<div class="tip" style="margin-top:10px">
开关可在本行直接切换,点「保存配置」后生效;关闭某工位手填时若该工位没有控制器地址,会拒绝保存并逐条列出工位号。
</div>
</el-card>
</div>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import request from '../utils/request'
const loading = ref(false)
const saving = ref(false)
const keyword = ref('')
const items = ref([])
const filtered = computed(() => {
const k = keyword.value.trim()
if (!k) return items.value
return items.value.filter((i) => String(i.stationNo).includes(k) || (i.stationName || '').includes(k))
})
async function load() {
loading.value = true
try {
const data = await request.get('/torque-gun-config')
items.value = (data.items || []).map((x) => ({ ...x, manualInput: x.manualInput === 'forbid' ? 'forbid' : 'allow' }))
} finally {
loading.value = false
}
}
async function save() {
try {
await ElMessageBox.confirm(
'仅保存本系统的展示记录,不下发工位终端,也不影响拧紧数据收集。确认保存?',
'确认保存',
{ type: 'warning' }
)
} catch {
return
}
saving.value = true
try {
await request.put('/torque-gun-config', { items: items.value })
ElMessage.success('已保存(按工位配置)')
load()
} finally {
saving.value = false
}
}
onMounted(load)
</script>
<style scoped>
.card-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
flex-wrap: wrap;
}
.card-header > div {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.tip {
color: #909399;
font-size: 12px;
}
</style>
@@ -135,6 +135,8 @@
<el-tab-pane label="装机绑定">
<el-alert :type="data.bindTrace?.complete ? 'success' : 'warning'" :closable="false" style="margin-bottom:10px"
:title="data.bindTrace?.complete ? '装配物料已全部绑齐 ✓' : ('装配物料未绑齐:' + (data.bindTrace?.missing || ''))" show-icon />
<el-alert v-if="(data.bindTrace?.notCollected || []).length" type="info" :closable="false" style="margin-bottom:10px"
:title="'未采集绑定:' + (data.bindTrace?.notCollected || []).map(x => '工艺「' + (x.flowName || x.flowId) + '」工位' + x.stationNo + ':' + x.reason).join(';')" show-icon />
<el-table :data="data.bindTrace?.binds||[]" border size="small">
<el-table-column prop="processCode" label="工位" width="70" />
<el-table-column prop="materialCode" label="图号" min-width="110" />
+15 -13
View File
@@ -338,20 +338,19 @@
<el-descriptions-item label="剩余未排产量">{{ detail.row.remainQty ?? 0 }} 台</el-descriptions-item>
<el-descriptions-item label="计划完成">{{ fmtDateOnly(detail.row.planEnd) }}</el-descriptions-item>
<el-descriptions-item label="计划开始">{{ fmtDateOnly(detail.row.planStart) }}</el-descriptions-item>
<el-descriptions-item label="计划完成">{{ fmtDateOnly(detail.row.planEnd) }}</el-descriptions-item>
<el-descriptions-item label="实际开始">{{ fmtDateOnly(detail.row.actualStart) }}</el-descriptions-item>
<el-descriptions-item label="实际完成">{{ fmtDateOnly(detail.row.completedAt) }}</el-descriptions-item>
<el-descriptions-item label="创建人 / 创建日期">
{{ detail.row.createdBy || '-' }} / {{ fmtTime(detail.row.createdAt) }}
</el-descriptions-item>
</el-descriptions>
<div class="detail-subtitle">工艺路线({{ detailRoutes.length }} 道工艺,按工位号升序=执行顺序,不显示工位号)</div>
<div class="detail-subtitle">工艺路线({{ detailRoutes.length }} 道工艺,按工位号升序=执行顺序)</div>
<el-table :data="detailRoutes" border size="small" empty-text="该工单未配置工艺组合">
<el-table-column type="index" label="序" width="50" align="center" />
<el-table-column prop="flowName" label="工艺" min-width="140" show-overflow-tooltip />
<el-table-column label="步骤数" width="80" align="center">
<template #default="{ row }">{{ row.steps.length }}</template>
<el-table-column label="工位" min-width="110" align="center">
<template #default="{ row }">{{ (row.stationNos || []).map(n => '工位' + n).join(' / ') || '-' }}</template>
</el-table-column>
<el-table-column prop="flowName" label="工艺" min-width="140" show-overflow-tooltip />
<el-table-column label="步骤明细" min-width="260">
<template #default="{ row }">
<template v-if="!row.steps.length">-</template>
@@ -376,7 +375,7 @@
<el-table-column label="SN末段" width="90" align="center">
<template #default="{ row }">{{ pieceSerialText(row) }}</template>
</el-table-column>
<el-table-column prop="sn" label="SN" min-width="160" show-overflow-tooltip />
<el-table-column prop="sn" label="SN" min-width="120" show-overflow-tooltip />
<el-table-column label="类型" width="90" align="center">
<template #default>{{ snModeText(detail.snMode) }}</template>
</el-table-column>
@@ -428,7 +427,7 @@ const ownershipText = (t) => (ownershipOptions.find((o) => o.v === t) || {}).l |
// 工件SN列表(详情抽屉):状态/当前工位/类型(sn_mode:1=序列号=是 2=序列号=否,取自产品图号对应物料档案)
const pieceStatusMap = { NEW: '待上线', ONLINE: '已上线', PROCESSING: '在制', SEMI_STORED: '半成品入库', DONE: '完工', SCRAPPED: '报废' }
const pieceStatusText = (s) => pieceStatusMap[s] || '—'
const stationText = (n) => (n !== 0 ? '工位' + n : '-')
const stationText = (n) => (n === undefined || n === null || n === '' || Number(n) === 0 ? '-' : '工位' + n)
const snModeText = (m) => (m === 1 ? '序列号=是' : m === 2 ? '序列号=否' : '-')
// 状态流转:给出当前状态可执行的下一个动作(按钮文案随当前状态变化,方案 A)
@@ -703,22 +702,25 @@ async function openDetail(row) {
}
}
// ---------- 工艺路线(详情抽屉,2026-10-19):按 flowCombination 去重、按工位号升序 ----------
// 展示工艺名+步骤数,可展开步骤列表;不显示工位列(工位号仅作为排序口径)。
// ---------- 工艺路线(详情抽屉,2026-10-19):按 flowCombination 的工序聚合、按工位号升序 ----------
// 展示工艺名+候选工位号+步骤明细,可展开步骤列表(同工序多工位=并行候选,全部列出)。
const detailRoutes = ref([])
function buildDetailRoutes(row) {
const combo = Array.isArray(row?.flowCombination) ? row.flowCombination : []
const minStation = new Map()
const stationsOf = new Map()
for (const c of combo) {
if (!c || !c.flowId) continue
const cur = minStation.get(c.flowId)
if (cur === undefined || c.stationNo < cur) minStation.set(c.flowId, c.stationNo)
const arr = stationsOf.get(c.flowId) || []
if (Number(c.stationNo) > 0 && !arr.includes(c.stationNo)) arr.push(c.stationNo)
stationsOf.set(c.flowId, arr)
}
const ids = [...minStation.keys()].sort((a, b) => minStation.get(a) - minStation.get(b))
const minOf = (fid) => Math.min(...(stationsOf.get(fid) || [0]))
const ids = [...stationsOf.keys()].sort((a, b) => minOf(a) - minOf(b))
detailRoutes.value = ids.map((fid) => {
const f = flows.value.find((x) => x.id === fid)
return {
flowId: fid,
stationNos: (stationsOf.get(fid) || []).slice().sort((a, b) => a - b),
flowName: f ? f.name : `工艺${fid}`,
steps: (f?.steps || []).slice().sort((a, b) => (a.seq || 0) - (b.seq || 0))
.map((s) => ({ name: s.name, needCheck: !!s.needCheck, needOperatorSign: !!s.needOperatorSign, needInspectorSign: !!s.needInspectorSign })),