feat: AGV三段链安全机制、补料/损耗/下班闭环、接驳台左右互换
AGV 调度: - 任务重构为 GO_LOAD/TRANSPORT/EMPTY_RETURN/FREE 三段链,到位即停(ARRIVED)需人工确认装卸 - 自由调度单点步进,每段强制弹"请确保路径畅通无杂物";托盘回收独立工作台 - 接驳台 PLC 传感器检测到托盘即自动卸货放行,传感器故障由人工按钮兜底(无轮询) - 车辆状态只读展示(海康3.1.7 queryAgvStatus),调度仍由 RCS 负责 物料闭环: - 补料管理(SHORTAGE):工位申请 + 主管审批调增叫料池额度,与借料/差异补发三轨并行 - 损耗台账(loss_ledger):退料实际 < 理论必填原因、后审核,工单不记损耗 - 退料强制指定左/右接驳台,WMS 库管可代工位退料 下班闭环: - 工位终端自检接驳台剩余物料后下班;库管收货 + 托盘拉走后事件驱动自动结班 - 退出登录未下班仅作安全提示(不强制拦截、不新增责任审批) 接驳台左右按操作员朝向建模(dock.side 字段),废除"奇左偶右"隐式约定; 看板标签 / seed / 迁移补丁 / 布局文档统一为中文左/右。 产线布局说明:C1 前线头 AGV 点、C15 后线尾 AGV 点、外部 O1/O2/O3 散点, 清理修订痕迹为最终态描述。
This commit is contained in:
@@ -12,6 +12,9 @@ export const refreshToken = () => request.post('/api/auth/refresh-token')
|
||||
// 工位配置(固定工位号)
|
||||
export const getConfig = () => request.get('/api/config')
|
||||
|
||||
// MES 公开配置快照(拧紧手填开关/缓存策略/AGV 超时等,2026-11-03 拍板),供终端按配置显隐交互
|
||||
export const getMesConfig = () => request.get('/api/mes-config')
|
||||
|
||||
// 当前工单任务(代理 MES)
|
||||
export const getTaskCurrent = (stationNo) =>
|
||||
request.get('/api/task/current', { params: { stationNo } })
|
||||
@@ -41,6 +44,9 @@ export const reportProcessDone = (data) => request.post('/api/report/process-don
|
||||
// 暂存退库上报
|
||||
export const reportTempStore = (data) => request.post('/api/report/temp-store', data)
|
||||
|
||||
// 工件报废/人工取走登记(与暂存退库语义互斥:报废=永久退出,退库=可重上线)
|
||||
export const reportScrap = (data) => request.post('/api/report/scrap', data)
|
||||
|
||||
// 手动触发一轮同步
|
||||
export const syncFlush = () => request.post('/api/sync/flush')
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ export const helpWorkstation = {
|
||||
fields: [
|
||||
{ name: '报工完成', source: '按钮操作 + 确认框。数据上报到 MES。', purpose: '本工位这道工艺做完,通知 MES 流转到下一工位', fill: '点「报工完成」二次确认;联网失败自动离线缓存' },
|
||||
{ name: '暂存退库', source: '按钮操作 + 确认框。数据上报到 MES(记录已完成工艺)。', purpose: '工件本工艺不做完,退回库房暂存', fill: '点击并二次确认;系统记录已完成工艺,重上线从下一工位继续' },
|
||||
{ name: '报废/取走', source: '按钮操作 + 原因必填弹窗。数据上报到 MES(工件状态置「已报废」)。', purpose: '工件被人工从产线取走(报废/丢失/磕碰损伤/人工处理)时的现场登记入口:永久退出产线且不可恢复、不计入在制,工单由计划员强制完工收尾', fill: '扫 SN → 点「报废/取走」→ 按提示填原因(必填)→ 确认登记。注意与「暂存退库」互斥:暂存=合法暂停可重上线,报废=永久退出;MES 不可达时提示稍后重试,不做离线排队(防重复误报)' },
|
||||
{ name: '待同步(顶部按钮)', source: '按钮操作。打开「重传处理」。', purpose: '查看/处理未上报数据:立即同步一轮、或对 MES 拒绝的记录重选点位后再次提交', fill: '看到「待同步」或「待处理」非 0 时点开处理' }
|
||||
]
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
</el-button>
|
||||
<span class="user-name">{{ user.name || user.username || '-' }}</span>
|
||||
<span class="clock">{{ clock }}</span>
|
||||
<el-button size="large" type="warning" :loading="offDutyBusy" @click="offDuty">下班/结束作业</el-button>
|
||||
<el-button size="large" type="danger" plain @click="logout">退出</el-button>
|
||||
</header>
|
||||
|
||||
@@ -74,7 +75,7 @@
|
||||
<script setup>
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ElMessage, ElNotification } from 'element-plus'
|
||||
import { ElMessage, ElMessageBox, ElNotification } from 'element-plus'
|
||||
import WorkPanel from './panels/WorkPanel.vue'
|
||||
import MaterialPanel from './panels/MaterialPanel.vue'
|
||||
import PdfPanel from './panels/PdfPanel.vue'
|
||||
@@ -92,9 +93,9 @@ import {
|
||||
helpPdf,
|
||||
helpWorkstation
|
||||
} from '../help'
|
||||
import { stationLogout, getStationAlerts } from '../api'
|
||||
import { stationLogout, getStationAlerts, listDocks } from '../api'
|
||||
import { speak, setSpeechMuted } from '../utils/speech'
|
||||
import { clearAuth } from '../utils/request'
|
||||
import request, { clearAuth } from '../utils/request'
|
||||
import {
|
||||
hasNg,
|
||||
hasTab,
|
||||
@@ -243,6 +244,19 @@ function tickClock() {
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
// 未下班退出提示(2026-11-03 下班闭环):查班次状态,ON_DUTY/CLOSING 弹安全警示(不强制拦截,留痕)
|
||||
try {
|
||||
const s = await request.get('/api/shift')
|
||||
const st = s?.shift?.status
|
||||
if (st === 'ON_DUTY' || st === 'CLOSING') {
|
||||
const tip = st === 'ON_DUTY'
|
||||
? '您尚未结束本班次作业。\n\n下班前请目视检查左右两个接驳台托盘:\n· 确认无剩余物料 → 请先点「下班/结束作业」完成下班;\n· 如有剩余物料 → 请先走退料流程退回库房。\n\n物料遗留在接驳台存在丢失、混料与安全风险。'
|
||||
: '您已申请下班,但接驳台剩余物料尚待库管收货+空托盘拉走(班次待收尾)。物料请勿自行带走。'
|
||||
try {
|
||||
await ElMessageBox.confirm(tip, '下班提醒', { type: 'warning', confirmButtonText: '仍要退出', cancelButtonText: '返回' })
|
||||
} catch { return }
|
||||
}
|
||||
} catch { /* MES 不可达不拦截退出 */ }
|
||||
// 退出前先本地退出(服务端登出失败也照样退),再按响应提醒本人未发送成功的条数
|
||||
let data = null
|
||||
try {
|
||||
@@ -265,6 +279,47 @@ async function logout() {
|
||||
}
|
||||
}
|
||||
|
||||
/* ===================== 下班/结束作业(2026-11-03 拍板闭环) ===================== */
|
||||
// 工人自己目视左右接驳台:确认无剩余 → 直接下班;有剩余 → 提交退料(指定接驳台)后即可离场,
|
||||
// 班次由库管收货+托盘拉走后自动结班。
|
||||
const offDutyBusy = ref(false)
|
||||
const docks = ref([])
|
||||
async function offDuty() {
|
||||
// 退料默认接驳台:本工位接驳台(api /api/docks)
|
||||
if (!docks.value.length) {
|
||||
try { docks.value = (await listDocks({ stationNo: stationNo.value }))?.list || [] } catch { /* 忽略 */ }
|
||||
}
|
||||
let hasLeftover = false
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
'下班前请目视检查左右两个接驳台托盘:是否有剩余物料?\n\n· 选「无剩余物料」= 直接下班;\n· 选「有剩余物料」= 需先指定接驳台/物料/数量走退料,提交后即可离开(库管收货+托盘拉走后自动结班)。',
|
||||
'下班 / 结束作业',
|
||||
{ distinguishCancelAndClose: true, type: 'warning',
|
||||
confirmButtonText: '确认无剩余,直接下班', cancelButtonText: '有剩余物料,走退料' })
|
||||
} catch (action) {
|
||||
if (action === 'cancel') hasLeftover = true
|
||||
else return // close = 放弃
|
||||
}
|
||||
const items = []
|
||||
if (hasLeftover) {
|
||||
try {
|
||||
const { value } = await ElMessageBox.prompt(
|
||||
'请按「工单号,图号,数量」逐行填写退料(每行一条,接驳台取默认),如:\nWO-20261103-002,断路器,2\n(若实际退回少于理论应退,请在 MES 转产退料页补损耗原因)',
|
||||
'剩余物料退料', { inputType: 'textarea', inputPlaceholder: '工单号,图号,数量', type: 'warning' })
|
||||
for (const line of String(value || '').split('\n')) {
|
||||
const [orderNo, code, qty] = line.split(',').map((x) => (x || '').trim())
|
||||
if (orderNo && code && Number(qty) > 0) items.push({ orderNo, materialCode: code, actualQty: Number(qty), dock: docks.value[0]?.dockCode || '', theoryQty: Number(qty) })
|
||||
}
|
||||
if (!items.length) { ElMessage.warning('未解析到有效退料行,已取消下班'); return }
|
||||
} catch { return }
|
||||
}
|
||||
offDutyBusy.value = true
|
||||
try {
|
||||
await request.post('/api/off-duty', { hasLeftover, items })
|
||||
ElMessage.success(hasLeftover ? '退料申请已提交,您可下班离开;班次待库管收货后自动结班' : '已下班,辛苦了')
|
||||
} catch { /* 拦截器已提示 */ } finally { offDutyBusy.value = false }
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
tickClock()
|
||||
await loadConfig()
|
||||
|
||||
@@ -141,7 +141,9 @@
|
||||
<el-table-column prop="requestNo" label="叫料单号" min-width="175" />
|
||||
<el-table-column prop="materialCode" label="图号" min-width="110" />
|
||||
<el-table-column prop="materialName" label="物料名称" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column prop="targetDock" label="接驳台" width="100" align="center" />
|
||||
<el-table-column label="接驳台" width="140" align="center">
|
||||
<template #default="{row}">{{ dockCn(row.targetDock) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="请求/实发" width="120" align="center">
|
||||
<template #default="{row}">{{ fmtQty(row.reqQty) }} / {{ row.sentQty > 0 ? fmtQty(row.sentQty) : '—' }}</template>
|
||||
</el-table-column>
|
||||
@@ -203,6 +205,16 @@ function fmtQty(v) {
|
||||
return Number.isInteger(n) ? String(n) : n.toFixed(2)
|
||||
}
|
||||
|
||||
// 接驳台显示(2026-11-03 左右互换拍板):按 side 显示「工位X左/右」,库房接驳台显示「库房接驳台」
|
||||
function dockCn(code) {
|
||||
if (!code) return '—'
|
||||
if (String(code) === 'DOCK21') return '库房接驳台'
|
||||
const d = dockOptions.value.find((x) => x.value === code)
|
||||
if (d && d.cn) return d.cn
|
||||
const m = /DOCK(\d+)/.exec(String(code))
|
||||
return m ? ('接驳台' + code) : code
|
||||
}
|
||||
|
||||
// 借料辅助:借料分配合计(来自各候选工位的手动分配量)
|
||||
function borrowSum(row) {
|
||||
const b = row.borrow || {}
|
||||
@@ -232,7 +244,11 @@ async function loadDocks() {
|
||||
try {
|
||||
const data = await listDocks()
|
||||
const list = (Array.isArray(data) ? data : data?.list || []).filter((d) => Number(d.stationNo) === Number(stationNo.value))
|
||||
dockOptions.value = list.map((d) => ({ value: d.dockCode, label: d.dockCode + (d.name ? '(' + d.name + ')' : '') }))
|
||||
dockOptions.value = list.map((d) => {
|
||||
const side = d.side === 'left' ? '左' : d.side === 'right' ? '右' : ''
|
||||
const cn = String(d.dockCode) === 'DOCK21' ? '库房接驳台' : `工位${d.stationNo || ''}${side}`
|
||||
return { value: d.dockCode, label: cn, cn }
|
||||
})
|
||||
// 本工位配置接驳台不在列表时也保留为可选(兜底)
|
||||
if (stationDock.value && !dockOptions.value.some((d) => d.value === stationDock.value)) {
|
||||
dockOptions.value.unshift({ value: stationDock.value, label: stationDock.value + '(本工位配置)' })
|
||||
|
||||
@@ -163,19 +163,23 @@
|
||||
{{ torqueRowOfStep(s.id).result === 'OK' ? '合格' : '不合格' }}
|
||||
</span>
|
||||
</div>
|
||||
<!-- 未录入:拧紧输入框,工件到位后自动聚焦;拧紧枪采集值打入此处回车录入 -->
|
||||
<!-- 未录入:拧紧输入框,工件到位后自动聚焦;拧紧枪采集值打入此处回车录入。
|
||||
拧紧手填开关(MES 基础设置「拧紧枪数据输入」):禁止手填(forbid)时输入框置灰,
|
||||
只能由拧紧枪自动打入(符合客户质量追溯要求);允许手填(allow)时开放人工录入。 -->
|
||||
<div v-else class="tight-input-row">
|
||||
<el-input
|
||||
:ref="(el) => setTorqueRef(s.id, el)"
|
||||
v-model="torqueInputs[s.id]"
|
||||
size="large"
|
||||
class="torque-input"
|
||||
placeholder="拧紧枪采集扭矩值打入此处,回车录入"
|
||||
:disabled="torqueManualForbidden"
|
||||
:placeholder="torqueManualForbidden ? '当前禁止手填,须由拧紧枪采集扭矩' : '拧紧枪采集扭矩值打入此处,回车录入'"
|
||||
@keyup.enter="onTorqueEnter(s)"
|
||||
>
|
||||
<template #append>N·m</template>
|
||||
</el-input>
|
||||
<el-button type="primary" size="large" :loading="torqueBusy" @click="onTorqueEnter(s)">录入</el-button>
|
||||
<el-button type="primary" size="large" :loading="torqueBusy" :disabled="torqueManualForbidden" @click="onTorqueEnter(s)">录入</el-button>
|
||||
<el-tag v-if="torqueManualForbidden" type="info" effect="plain">禁止手填(基础设置)</el-tag>
|
||||
</div>
|
||||
<div v-if="(s.attachment || []).length" class="step-files">
|
||||
<el-button size="large" type="primary" plain @click="openStepFiles(s)">
|
||||
@@ -191,6 +195,7 @@
|
||||
报工完成
|
||||
</el-button>
|
||||
<el-button type="warning" size="large" class="big-btn" :disabled="!sn" @click="onTempStore">暂存退库</el-button>
|
||||
<el-button type="danger" size="large" class="big-btn" :disabled="!sn" @click="onScrap">报废/取走</el-button>
|
||||
<div class="block-tip" v-if="blockTip">{{ blockTip }}</div>
|
||||
</footer>
|
||||
|
||||
@@ -233,9 +238,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { computed, nextTick, reactive, ref, watch } from 'vue'
|
||||
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { fileNameFromUrl, getTrace, mismatchCheck, pdfOpenUrl, reportProcessDone, reportTempStore } from '../../api'
|
||||
import { fileNameFromUrl, getTrace, getMesConfig, mismatchCheck, pdfOpenUrl, reportProcessDone, reportScrap, reportTempStore } from '../../api'
|
||||
import {
|
||||
autoTorqueState,
|
||||
bindBlocking,
|
||||
@@ -283,6 +288,21 @@ import {
|
||||
|
||||
const emit = defineEmits(['call-material'])
|
||||
|
||||
// 拧紧手填开关(MES 基础设置「拧紧枪数据输入」,2026-11-03 拍板):
|
||||
// forbid=禁止手填(默认,扭矩必须真实采集,符合客户质量追溯);allow=允许手填。
|
||||
// 加载失败时退回 forbid(最严),保证质量底线。
|
||||
const mesConfig = reactive({ torqueManualInput: 'forbid' })
|
||||
const torqueManualForbidden = computed(() => mesManualInputSafe() !== 'allow')
|
||||
function mesManualInputSafe() {
|
||||
return mesConfig.torqueManualInput === 'allow' ? 'allow' : 'forbid'
|
||||
}
|
||||
onMounted(async () => {
|
||||
try {
|
||||
const r = await getMesConfig()
|
||||
if (r && r.torqueManualInput) mesConfig.torqueManualInput = r.torqueManualInput
|
||||
} catch { /* MES 不可达:保持 forbid 默认 */ }
|
||||
})
|
||||
|
||||
const scanRef = ref()
|
||||
const scanInput = ref('')
|
||||
const taking = ref(false)
|
||||
@@ -682,6 +702,39 @@ async function onTempStore() {
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
// 报废/人工取走(2026-11-03 闭环补全):工件被人工从产线取走(报废/丢失/磕碰损伤/人工处理)时
|
||||
// 的现场收口入口。原因必填、MES 留痕;工件永久退出(SCRAPPED),不计入在制,工单需强制完工收尾。
|
||||
// 与「暂存退库」互斥:退库=合法暂停可重上线,报废=永久退出不可恢复。不做离线排队(防重复误报)。
|
||||
async function onScrap() {
|
||||
if (!sn.value) {
|
||||
ElMessage.warning('请先扫描工件 SN')
|
||||
return
|
||||
}
|
||||
let reason
|
||||
try {
|
||||
reason = await ElMessageBox.prompt(
|
||||
`将把工件「${sn.value}」登记为报废/人工取走,永久退出产线且不可恢复(若属"暂存后续回用"请用左侧「暂存退库」)。原因必填:`,
|
||||
'报废/取走登记', {
|
||||
confirmButtonText: '确认登记',
|
||||
cancelButtonText: '取消',
|
||||
type: 'error',
|
||||
inputPlaceholder: '如:磕碰损伤报废 / 人工取走维修 / 现场丢失',
|
||||
inputValidator: (v) => (v && v.trim() ? true : '原因必填')
|
||||
}
|
||||
)
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await reportScrap({ sn: sn.value, reason: reason.value.trim(), operator: operatorName() })
|
||||
ElMessage.success('已登记报废/取走')
|
||||
setCurrentSn('')
|
||||
loadTask()
|
||||
loadStats()
|
||||
loadPoints()
|
||||
} catch (e) { /* 统一错误提示 */ }
|
||||
}
|
||||
|
||||
/* ---------- 5.2 在制品:点击某工件 → 继续该工件的工艺步骤填报 ---------- */
|
||||
function wipStatusText(s) {
|
||||
return { ONLINE: '已上线', PROCESSING: '在制' }[s] || s || '-'
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"bj_power_workstation/internal/mes"
|
||||
"bj_power_workstation/internal/svc"
|
||||
@@ -242,3 +243,73 @@ func tempStoreHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
ok(w, map[string]any{"queued": false})
|
||||
}
|
||||
}
|
||||
|
||||
// scrapHandler POST /api/report/scrap
|
||||
// {sn, reason, operator} → 调 MES /api/internal/workpiece/scrap(工件报废/人工取走,2026-11-03 补全)。
|
||||
// 与「暂存退库」语义互斥:报废=永久退出产线(SCRAPPED),退库=合法暂停(SEMI_STORED)可重上线。
|
||||
// 故意不做离线排队:报废是一次性状态变更,MES 端按当前状态强校验(已报废再报会被拒),
|
||||
// 离线重发必然失败徒增噪声——MES 不可达时直接提示现场重试。
|
||||
func scrapHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Sn string `json:"sn"`
|
||||
Reason string `json:"reason"`
|
||||
Operator string `json:"operator"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
if req.Sn == "" {
|
||||
fail(w, http.StatusBadRequest, "缺少 sn")
|
||||
return
|
||||
}
|
||||
if req.Reason == "" {
|
||||
fail(w, http.StatusBadRequest, "报废/取走原因必填")
|
||||
return
|
||||
}
|
||||
// 操作人取工位登录态可信身份(防冒名),与暂存退库同口径
|
||||
op := req.Operator
|
||||
if ss, sErr := ctx.Store.GetStationSession(); sErr == nil && ss != nil && ss.Name != "" {
|
||||
op = ss.Name
|
||||
}
|
||||
body := map[string]any{"sn": req.Sn, "reason": req.Reason}
|
||||
payloadBytes, _ := json.Marshal(body)
|
||||
respBody, _, err := ctx.Mes.Post("/api/internal/workpiece/scrap?operator="+url.QueryEscape(op), json.RawMessage(payloadBytes))
|
||||
if err != nil {
|
||||
var bizErr *mes.BizError
|
||||
if errors.As(err, &bizErr) {
|
||||
msg := mesRespCode(bizErr.Body)
|
||||
if msg == "" {
|
||||
msg = bizErr.Error()
|
||||
}
|
||||
fail(w, http.StatusConflict, msg)
|
||||
return
|
||||
}
|
||||
ctx.Store.AddEventLog("", op, "scrap_failed",
|
||||
"报废登记失败(MES不可达) sn="+req.Sn)
|
||||
fail(w, http.StatusBadGateway, "MES 不可达,报废未登记,请稍后重试(不要重复提交)")
|
||||
return
|
||||
}
|
||||
if msg := mesRespCode(respBody); msg != "" {
|
||||
fail(w, http.StatusConflict, msg)
|
||||
return
|
||||
}
|
||||
ctx.Store.AddEventLog("", op, "workpiece_scrap",
|
||||
"工件报废/人工取走 sn="+req.Sn+" 原因="+req.Reason)
|
||||
ok(w, map[string]any{"ok": true})
|
||||
}
|
||||
}
|
||||
|
||||
// mesConfigHandler GET /api/mes-config 代理 MES 公开配置快照(拧紧手填开关 / 缓存策略 / AGV 超时等),
|
||||
// 供工位终端前端按配置显隐或约束交互(2026-11-03 拍板:拧紧禁止手填时输入框置灰,只能由枪自动采集)。
|
||||
func mesConfigHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
b, _, err := ctx.Mes.Get("/api/internal/public-config", nil)
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadGateway, "MES 不可达,配置获取失败")
|
||||
return
|
||||
}
|
||||
ok(w, json.RawMessage(b))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodPost, Path: "/api/tightening/consume", Handler: tighteningConsumeHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/report/process-done", Handler: processDoneHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/report/temp-store", Handler: tempStoreHandler(ctx)},
|
||||
// 工件报废/人工取走(2026-11-03 补全):与暂存退库语义互斥,原因必填,不做离线排队
|
||||
{Method: http.MethodPost, Path: "/api/report/scrap", Handler: scrapHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/station/logout", Handler: logoutHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/sync/flush", Handler: syncFlushHandler(ctx)},
|
||||
{Method: http.MethodGet, Path: "/api/sync/stats", Handler: syncStatsHandler(ctx)},
|
||||
@@ -74,6 +76,9 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodPost, Path: "/api/emergency/call", Handler: emergencyCallHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/qty-report", Handler: qtyReportHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/return-material", Handler: returnMaterialHandler(ctx)},
|
||||
// 下班/结束作业闭环(2026-11-03):查询班次(退出提示)+ 下班提交(自检接驳台剩余物料)
|
||||
{Method: http.MethodGet, Path: "/api/shift", Handler: shiftGetHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/off-duty", Handler: offDutyHandler(ctx)},
|
||||
{Method: http.MethodPost, Path: "/api/inspection/upload", Handler: inspectionUploadHandler(ctx)},
|
||||
|
||||
// 在制品 / 0-13 上下线建档完工 / 物料清单领料 / 追溯(代理 MES 内部 API)
|
||||
@@ -89,6 +94,9 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
|
||||
// PLC↔MES 对账(#8 T2/T3 终端事件驱动检查,不轮询):代理 MES 内部接口,MES 不可达静默跳过
|
||||
{Method: http.MethodPost, Path: "/api/plc/mismatch/check", Handler: plcMismatchCheckHandler(ctx)},
|
||||
},
|
||||
|
||||
// 2026-11-03 拍板:MES 公开配置快照(拧紧手填开关/缓存策略/AGV 超时),终端按配置显隐交互
|
||||
{Method: http.MethodGet, Path: "/api/mes-config", Handler: mesConfigHandler(ctx)},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"bj_power_workstation/internal/svc"
|
||||
)
|
||||
@@ -112,6 +113,42 @@ func returnMaterialHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// shiftGetHandler GET /api/shift —— 当前班次状态(退出登录前提示「未下班」用,2026-11-03 下班闭环)。
|
||||
func shiftGetHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
stationNo := stationNoFromRequest(ctx)
|
||||
resp, _, perr := ctx.Mes.Get("/api/internal/station/shift?stationNo="+strconv.Itoa(stationNo), nil)
|
||||
mesJSON(w, resp, perr)
|
||||
}
|
||||
}
|
||||
|
||||
// offDutyHandler POST /api/off-duty —— 下班/结束作业(工人自检接驳台剩余物料后提交)。
|
||||
// {hasLeftover, items[]}:确认无剩余直接下班;有剩余走退料流程(指定接驳台/实际量/损耗原因)后离场。
|
||||
func offDutyHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
payload, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体读取失败")
|
||||
return
|
||||
}
|
||||
var req map[string]any
|
||||
if err := json.Unmarshal(payload, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "请求体解析失败")
|
||||
return
|
||||
}
|
||||
req["stationNo"] = stationNoFromRequest(ctx)
|
||||
injectOperator(req, r)
|
||||
body, _ := json.Marshal(req)
|
||||
resp, _, perr := ctx.Mes.Post("/api/internal/station/off-duty", json.RawMessage(body))
|
||||
mesJSON(w, resp, perr)
|
||||
}
|
||||
}
|
||||
|
||||
// stationNoFromRequest 固定工位号(与 /api/config 同源:workstation 配置)。
|
||||
func stationNoFromRequest(ctx *svc.ServiceContext) int {
|
||||
return ctx.Config.Station.StationNo
|
||||
}
|
||||
|
||||
// inspectionUploadHandler POST /api/inspection/upload(巡检拍照 base64 上传,代理 MES 内部接口)
|
||||
// 请求体:{filename, data(base64)}
|
||||
func inspectionUploadHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
|
||||
@@ -89,6 +89,8 @@ func tighteningRecordHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if ss != nil {
|
||||
opID = ss.UserID
|
||||
}
|
||||
// 拧紧域工位标签载体(自洽闭环):写入 DOCK%02d、syncer 上报前同公式反推工位号——
|
||||
// 与接驳台 dock 表编码无关,接驳台左右互换(side 字段)不影响本数据流。
|
||||
dockCode := fmt.Sprintf("DOCK%02d", ctx.Config.Station.StationNo)
|
||||
id, err := ctx.Store.InsertTorqueResult(store.TorqueResult{
|
||||
WorkOrderNo: req.WorkOrderNo,
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>工位终端</title>
|
||||
<!-- 系统图标:工位终端屏(内联 SVG,避免依赖外部文件) -->
|
||||
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='6' fill='%231668dc'/><rect x='6' y='7' width='20' height='14' rx='2' fill='none' stroke='%23fff' stroke-width='2'/><path d='M12 25h8M16 21v4' stroke='%23fff' stroke-width='2' stroke-linecap='round'/></svg>">
|
||||
<script type="module" crossorigin src="/assets/index-Vu_k-26y.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-Cbzaohu_.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-Dz4RGjfJ.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user