feat: AGV点位锁与缓存迁移 + 工位终端去离线队列 + WMS出入库增强
【MES】 - AGV点位/线路点位/AGV任务/工单 ent schema 重构(全量重生成 ent 代码) - 新增派车锁 agv_point_lock.go:目标点位占用即拒车,JBT21 库房接驳台卸货后保持锁定待库管手动解锁 - 新增进程内 TTL 缓存 cache.go,由 Redis 看板缓存迁移至内存(singleflight 防击穿,去除外部依赖) - AGV 三段链安全机制、车辆状态/接驳台左右互换、补料损耗闭环完善 - 来料检/工序卡/工单/质检/日排产/AGV 前端与帮助文档更新 - 新增 migrations/、sql/ 目录 【WMS】 - 出库、Excel 导出、物料、路由处理增强 - 配置与 DB 初始化调整;基础数据/成品入库/入库前端调整 【工位终端】 - 移除离线同步队列(syncer 包、sync.go、SyncQueueDialog.vue),改为实时直连上报 MES(断网即失败报错),以本人身份操作 - 本地 SQLite 仅保留操作日志 + 内置账号 + 登录态;保留空闲自动登出 【文档】 - 删除 AGV海康litev1.5.md;案例.md 更新
This commit is contained in:
@@ -600,13 +600,35 @@ async function onMaterialFile(e) {
|
||||
const file = e.target.files?.[0]
|
||||
e.target.value = '' // 允许重复选择同一文件
|
||||
if (!file) return
|
||||
const go = await confirmAction(`确认导入物料文件「${file.name}」?导入将批量写入物料档案(任一行错误则整体回退)。`, '批量导入确认')
|
||||
if (!go) return
|
||||
matImporting.value = true
|
||||
try {
|
||||
const fd = new FormData()
|
||||
fd.append('file', file)
|
||||
// 注意:token 是纯文本存储,不能用 JSON.parse(会对 JWT 抛 SyntaxError 误报"导入异常")
|
||||
// 阶段1 预检(只读,不写任何数据):与写入端点同一套校验规则
|
||||
const pres = await fetch('/api/material/import/preview', {
|
||||
method: 'POST',
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
body: fd
|
||||
})
|
||||
const pbody = await pres.json().catch(() => null)
|
||||
if (!pres.ok || pbody?.code !== 0) {
|
||||
const httpText = pres.status === 401 ? '登录已过期,请重新登录' : `服务器错误(${pres.status})`
|
||||
ElMessage.error('预检失败:' + (pbody?.message || httpText))
|
||||
return
|
||||
}
|
||||
const p = pbody?.data || {}
|
||||
const perrs = p.errors || []
|
||||
if (perrs.length) {
|
||||
const lines = perrs.slice(0, 10)
|
||||
.map((x) => `第${x.row}行 ${x.materialCode || ''}:${x.message}`).join(';')
|
||||
ElMessage.error(`预检未通过:共 ${p.total || 0} 行,失败 ${perrs.length} 行(未写入任何数据):` + lines + (perrs.length > 10 ? ' …' : ''))
|
||||
return
|
||||
}
|
||||
// 阶段2 确认
|
||||
const go = await confirmAction(`预检通过:共 ${p.total || 0} 行,将成功导入 ${p.success || 0} 行。正式写入为整批事务(全成功或全失败),确认导入「${file.name}」?`, '预检通过,确认导入')
|
||||
if (!go) return
|
||||
// 阶段3 正式写入
|
||||
const res = await fetch('/api/material/import', {
|
||||
method: 'POST',
|
||||
headers: { Authorization: 'Bearer ' + getToken() },
|
||||
@@ -623,7 +645,7 @@ async function onMaterialFile(e) {
|
||||
if (d.errors && d.errors.length) {
|
||||
const lines = d.errors.slice(0, 10)
|
||||
.map((x) => `第${x.row}行 ${x.materialCode || ''}:${x.message}`).join(';')
|
||||
ElMessage.error('导入失败:' + lines + (d.errors.length > 10 ? ' …' : ''))
|
||||
ElMessage.error('导入被拒绝(未写入任何数据):' + lines + (d.errors.length > 10 ? ' …' : ''))
|
||||
return
|
||||
}
|
||||
ElMessage.success(`导入成功 ${d.success || 0} 条`)
|
||||
|
||||
@@ -30,7 +30,7 @@ const form = reactive(newForm())
|
||||
const staged = ref([]) // 暂存附件(提交成功后随 SN 上传,bizType=finished)
|
||||
const submitting = ref(false)
|
||||
|
||||
// 选产品序号(物料档案远程搜索)自动带出名称,可手改
|
||||
// 选图号(物料档案远程搜索)自动带出名称,可手改
|
||||
function onMaterialChange(m) {
|
||||
form.productName = m?.name || ''
|
||||
}
|
||||
@@ -55,7 +55,7 @@ async function uploadStaged(sn) {
|
||||
async function submit() {
|
||||
const sn = form.sn.trim()
|
||||
if (!sn) { ElMessage.warning('请扫描或输入 SN'); return }
|
||||
if (!form.productCode) { ElMessage.warning('请选择产品序号(物料档案)'); return }
|
||||
if (!form.productCode) { ElMessage.warning('请选择图号(物料档案)'); return }
|
||||
if (!form.productStatus) { ElMessage.warning('请选择产品状态(已通过/部分通过/返修)'); return }
|
||||
if (!form.recordedBy.trim()) { ElMessage.warning('请填写记录员'); return }
|
||||
if ((form.ownershipType === 'workorder' || form.ownershipType === 'project') && !form.ownershipNo.trim()) {
|
||||
@@ -148,12 +148,12 @@ onMounted(loadList)
|
||||
<el-input v-model="form.sn" autofocus clearable
|
||||
placeholder="扫描或输入成品 SN(扫码枪回车即填),全局唯一" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品序号">
|
||||
<el-form-item label="图号">
|
||||
<MaterialSelect v-model="form.productCode" :item-type="3" placeholder="远程搜索成品档案(编码/名称)"
|
||||
@item-change="onMaterialChange" />
|
||||
</el-form-item>
|
||||
<el-form-item label="产品名称">
|
||||
<el-input v-model="form.productName" placeholder="选产品序号后自动带出,可修改" clearable />
|
||||
<el-input v-model="form.productName" placeholder="选图号后自动带出,可修改" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="归属">
|
||||
<div style="display:flex;gap:8px;width:100%">
|
||||
@@ -213,7 +213,7 @@ onMounted(loadList)
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="sn" label="SN" min-width="160" />
|
||||
<el-table-column prop="materialCode" label="产品序号" min-width="120" />
|
||||
<el-table-column prop="materialCode" label="图号" min-width="120" />
|
||||
<el-table-column prop="materialName" label="产品名称" min-width="110">
|
||||
<template #default="{ row }">{{ row.materialName || '-' }}</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -44,12 +44,28 @@ function onExceed(files, which) {
|
||||
async function importExcel(mode, which) {
|
||||
const raw = pickRaw(which)
|
||||
if (!raw) { ElMessage.warning('请先选择 .xlsx 文件'); return }
|
||||
const fd = new FormData()
|
||||
fd.append('file', raw)
|
||||
fd.append('mode', mode)
|
||||
importing.value = true
|
||||
excelResult.value = null
|
||||
try {
|
||||
// 阶段1 预检(只读,不写任何数据):与写入端点同一套校验规则
|
||||
const pfd = new FormData()
|
||||
pfd.append('file', raw)
|
||||
pfd.append('mode', mode)
|
||||
const p = (await request.post('/inbound/batch-excel/preview', pfd)) || {}
|
||||
const perrs = p.errors || []
|
||||
if (perrs.length) {
|
||||
const lines = perrs.slice(0, 10).map((x) => `第${x.row}行 ${x.materialCode || ''}:${x.message}`).join(';')
|
||||
ElMessage.error(`预检未通过:共 ${p.total || 0} 行,失败 ${perrs.length} 行(未写入任何数据):` + lines + (perrs.length > 10 ? ' …' : ''))
|
||||
return
|
||||
}
|
||||
// 阶段2 确认
|
||||
await ElMessageBox.confirm(
|
||||
`预检通过:共 ${p.total || 0} 行,将全部成功入库 ${p.success || 0} 行。正式写入为整批事务(全成功或全失败)。`,
|
||||
'预检通过,确认导入', { type: 'info', confirmButtonText: '正式导入', cancelButtonText: '取消' })
|
||||
// 阶段3 正式写入
|
||||
const fd = new FormData()
|
||||
fd.append('file', raw)
|
||||
fd.append('mode', mode)
|
||||
const data = await request.post('/inbound/batch-excel', fd)
|
||||
excelResult.value = data || {}
|
||||
if (data?.failed > 0) {
|
||||
@@ -58,6 +74,9 @@ async function importExcel(mode, which) {
|
||||
ElMessage.success(`批量导入成功:共 ${data?.success ?? 0} 行`)
|
||||
await loadRecords()
|
||||
}
|
||||
} catch (err) {
|
||||
if (err === 'cancel' || err === 'close') return // 用户取消确认弹窗
|
||||
ElMessage.error('导入失败:网络异常或登录已过期,请重试')
|
||||
} finally {
|
||||
importing.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user