feat: 来料检处置项实体与复检、日排产达成对比、PLC/WMS 传输日志
- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端 - MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流 - 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志 - MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整 - 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整 - 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
This commit is contained in:
@@ -120,19 +120,19 @@ const sensor = reactive({ pointNo: '', hasGoods: false, plcOk: false, checked: f
|
||||
const ORDER_PAGE_SIZE = 10
|
||||
const STATUS_TEXT = { CREATED: '已创建', RELEASED: '已下发', IN_PROGRESS: '生产中', PAUSED: '已暂停' }
|
||||
|
||||
// SN 口径按产品型号/物料档案「序列号(是/否)」分流(2026-09-30 解耦定稿,2026-10-19 术语统一):
|
||||
// 1=序列号=是:SN 输入必填,扫已在 WMS 入库登记的来料序列号,工件序列号=来料序列号(不自动发号);
|
||||
// SN 口径按成品档案「序列号(是/否)」分流(2026-09-30 解耦定稿;2026-11-16 术语统一为成品档案):
|
||||
// 1=序列号=是:SN 输入必填,扫已在 WMS 入库登记的序列号,工件序列号=所扫序列号(不自动发号);
|
||||
// 2=序列号=否:提交后系统自动发号(提交时若未填则本地自动生成);
|
||||
// 0=未选择:不可建档,提示先去产品型号/物料档案选择「序列号(是/否)」。
|
||||
// 0=未选择:不可建档,提示先去 MES 成品档案设置「序列号(是/否)」。
|
||||
const snPlaceholder = computed(() => {
|
||||
if (product.snMode === 1) return '请扫描来料序列号(已在WMS入库登记)'
|
||||
if (product.snMode === 1) return '请扫描产品序列号(已在WMS入库登记)'
|
||||
if (product.snMode === 2) return '提交后系统自动发号'
|
||||
return '请先在产品型号/物料档案选择「序列号(是/否)」'
|
||||
return '请先在成品档案设置「序列号(是/否)」'
|
||||
})
|
||||
const snTip = computed(() => {
|
||||
if (product.snMode === 1) return '该产品为「序列号=是」:请扫描来料序列号(需已在 WMS 入库登记),建档后工件序列号 = 来料序列号,不再自动发号。'
|
||||
if (product.snMode === 1) return '该产品为「序列号=是」:请扫描产品序列号(需已在 WMS 入库登记),建档后工件序列号 = 所扫序列号,不再自动发号。'
|
||||
if (product.snMode === 2) return '该产品为「序列号=否」:提交后系统自动发号,全程可追溯;成品 产品序号(SN) 与工件序列号 一致。'
|
||||
return '该产品未选择「序列号(是/否)」:请先在 MES 产品型号/物料档案设置,否则无法建档上线。'
|
||||
return '该产品未设置「序列号(是/否)」:请先在 MES 成品档案设置,否则无法建档上线。'
|
||||
})
|
||||
|
||||
// 15a:待流转在制品列表已删除;重复建档由 MES 唯一约束拦截 + PLC↔MES 对账弹窗提示
|
||||
@@ -236,18 +236,15 @@ async function onPointChange() {
|
||||
}
|
||||
}
|
||||
|
||||
// 15e 工单下拉:仅展示未完工的活跃工单(CREATED/RELEASED/IN_PROGRESS/PAUSED),
|
||||
// label 带中文状态,工人一眼看清哪张单能建档;默认最多 10 条(15d)。
|
||||
const ACTIVE_STATUS = ['CREATED', 'RELEASED', 'IN_PROGRESS', 'PAUSED']
|
||||
// 15e 工单下拉(2026-11-16 死结7 统一口径):仅进行中(IN_PROGRESS)工单,不限排产日期,
|
||||
// 状态过滤下推 MES 后端(不再前端 slice 后过滤);stationNo 下推按「第1道工序候选工位含本工位」
|
||||
// 过滤(与建档落点资格校验同口径),干不了的单不出现在下拉里。
|
||||
const orderOptions = computed(() =>
|
||||
orders.value
|
||||
.filter((o) => !o.status || ACTIVE_STATUS.includes(o.status))
|
||||
.slice(0, ORDER_PAGE_SIZE)
|
||||
.map((o) => ({
|
||||
value: o.workOrderNo,
|
||||
label: `${o.workOrderNo}${o.productName ? ' · ' + o.productName : ''} · ${STATUS_TEXT[o.status] || o.status || '活跃'}`,
|
||||
raw: o
|
||||
}))
|
||||
orders.value.slice(0, ORDER_PAGE_SIZE).map((o) => ({
|
||||
value: o.workOrderNo,
|
||||
label: `${o.workOrderNo}${o.productName ? ' · ' + o.productName : ''} · ${STATUS_TEXT[o.status] || o.status || '进行中'}`,
|
||||
raw: o
|
||||
}))
|
||||
)
|
||||
|
||||
const canSubmit = computed(
|
||||
@@ -260,8 +257,8 @@ const canSubmit = computed(
|
||||
const blockTip = computed(() => {
|
||||
if (!form.orderNo) return '请先选择工单号'
|
||||
if (!form.pointNo) return '请选择工件当前位置(无可选用点位时请联系班长协调)'
|
||||
if (product.snMode === 0) return '请先在产品型号/物料档案选择「序列号(是/否)」'
|
||||
if (product.snMode === 1 && !form.sn) return '请扫描来料序列号(已在WMS入库登记)'
|
||||
if (product.snMode === 0) return '请先在成品档案设置「序列号(是/否)」'
|
||||
if (product.snMode === 1 && !form.sn) return '请扫描产品序列号(已在WMS入库登记)'
|
||||
return ''
|
||||
})
|
||||
|
||||
@@ -269,7 +266,12 @@ const blockTip = computed(() => {
|
||||
async function loadOrders(keyword = '') {
|
||||
loadingOrder.value = true
|
||||
try {
|
||||
const list = await queryOrder({ keyword: String(keyword || '').trim(), limit: ORDER_PAGE_SIZE })
|
||||
const list = await queryOrder({
|
||||
keyword: String(keyword || '').trim(),
|
||||
limit: ORDER_PAGE_SIZE,
|
||||
status: 'IN_PROGRESS',
|
||||
stationNo: Number(state.stationNo) > 0 ? Number(state.stationNo) : undefined
|
||||
})
|
||||
orders.value = Array.isArray(list) ? list : (list && list.list ? list.list : [])
|
||||
// 业务口径(2026-11-06 条19 拍板):活跃工单只有一个时默认选中,工人少点一步
|
||||
if (!form.orderNo && orderOptions.value.length === 1 && !keyword) {
|
||||
|
||||
@@ -622,17 +622,39 @@ watch(
|
||||
() => { if (sn.value && torqueStepCount.value) focusNextTorque() }
|
||||
)
|
||||
|
||||
// W6 混产适配(2026-09-29):扫 SN 自动识别所属工单并切换选中。
|
||||
// 混产后多工单并行,工人拿了 B 单工件而终端还停在 A 单时,报工会因 SN 不属 A 被拒;
|
||||
// 扫码即查追溯(SN→工单号),属当日任务工单且与当前不同则自动切换,免人工找单。
|
||||
// 扫码错单确认(2026-11-16 工位物理互斥配套):扫 SN 查追溯(SN→工单号),属于其他工单时
|
||||
// 不再静默切换——弹窗让工人明确确认「切换工单」或「保持当前工单」,杜绝扫错件静默记错账。
|
||||
// 报工提交仍带当前 orderNo,后端会做第二道一致性强校验(不一致直接拒绝)。
|
||||
async function autoSwitchOrder(snVal) {
|
||||
let wo = ''
|
||||
try {
|
||||
const data = await getTrace({ sn: snVal })
|
||||
const wo = data?.workpiece?.orderNo || ''
|
||||
if (!wo || wo === orderNo.value || !orderNos.value.includes(wo)) return
|
||||
orderNo.value = wo
|
||||
ElMessage.info('已自动切换到该工件所属工单:' + wo)
|
||||
} catch { /* 产品序号(SN) 无追溯数据(尚未上线的新件)不打扰 */ }
|
||||
wo = data?.workpiece?.orderNo || ''
|
||||
} catch {
|
||||
return // 产品序号(SN) 无追溯数据(尚未上线的新件)不打扰
|
||||
}
|
||||
if (!wo || wo === orderNo.value) return
|
||||
if (!orderNos.value.includes(wo)) {
|
||||
ElMessage.warning(`扫码件 ${snVal} 属于工单 ${wo},不在本工位可选工单中;已保持当前工单 ${orderNo.value}`)
|
||||
return
|
||||
}
|
||||
let switched = false
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
`扫码件 ${snVal} 属于工单 ${wo},与当前作业工单 ${orderNo.value} 不一致。是否切换到工单 ${wo}?`,
|
||||
'工单不一致确认',
|
||||
{ confirmButtonText: '切换到 ' + wo, cancelButtonText: '保持当前工单', type: 'warning' }
|
||||
)
|
||||
switched = true
|
||||
} catch {
|
||||
/* 工人选择保持 */
|
||||
}
|
||||
if (!switched) {
|
||||
ElMessage.info(`已保持当前工单 ${orderNo.value},未切换`)
|
||||
return
|
||||
}
|
||||
orderNo.value = wo
|
||||
ElMessage.success('已切换到工单 ' + wo)
|
||||
}
|
||||
|
||||
// 扫码后:若 SN 已在本工位直接开干;否则提示去"上料/取料"
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
|
||||
// 后端端口单一真源:读后端 yaml 顶层 Port(改端口只改 etc/*.yaml 一处,开发态 proxy 自动联动)。
|
||||
// 仅 npm run dev 时生效;npm run build 产物与 Go 网关同源,proxy 不参与。读不到时回退 fallback(行为不变)。
|
||||
function backendPort(yamlRel, fallback) {
|
||||
try {
|
||||
const yamlPath = path.resolve(process.cwd(), yamlRel)
|
||||
const m = fs.readFileSync(yamlPath, 'utf-8').match(/^Port:\s*(\d+)\s*$/m)
|
||||
if (m) return Number(m[1])
|
||||
} catch (e) {
|
||||
console.warn(`[vite.config] 未读到 ${yamlRel} 的 Port,proxy 回退 ${fallback}`)
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
const apiTarget = `http://127.0.0.1:${backendPort('../etc/bj_power_workstation.yaml', 8892)}`
|
||||
|
||||
// 构建输出到 Go 服务内嵌目录 ../web/static(emptyOutDir=true 每次清空旧产物,避免残留旧文件被打进 exe)
|
||||
export default defineConfig({
|
||||
@@ -11,9 +28,9 @@ export default defineConfig({
|
||||
server: {
|
||||
port: 8893,
|
||||
proxy: {
|
||||
'/api': 'http://127.0.0.1:8892',
|
||||
'/pdfopen': 'http://127.0.0.1:8892',
|
||||
'/pdfview': 'http://127.0.0.1:8892'
|
||||
'/api': apiTarget,
|
||||
'/pdfopen': apiTarget,
|
||||
'/pdfview': apiTarget
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -62,13 +62,14 @@ func bomHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// orderQueryHandler GET /api/order/query?orderNo=&keyword=&status=&limit= —— 代理 MES /api/internal/order/query。
|
||||
// orderQueryHandler GET /api/order/query?orderNo=&keyword=&status=&limit=&stationNo= —— 代理 MES /api/internal/order/query。
|
||||
// 上线建档选工单后带出产品编码/名称(用于查物料清单应领料)。
|
||||
// 2026-11-10:透传远程搜索关键字与条数上限,工单下拉不再一次拉全量。
|
||||
// 2026-11-16:透传 stationNo(MES 侧按「第1道工序候选工位含本工位」过滤,与建档落点资格校验同口径)。
|
||||
func orderQueryHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
params := url.Values{}
|
||||
for _, k := range []string{"orderNo", "keyword", "status", "limit"} {
|
||||
for _, k := range []string{"orderNo", "keyword", "status", "limit", "stationNo"} {
|
||||
if v := strings.TrimSpace(r.URL.Query().Get(k)); v != "" {
|
||||
params.Set(k, v)
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
|
||||
"bj_power_workstation/internal/tightening"
|
||||
)
|
||||
|
||||
@@ -126,13 +128,16 @@ func (c *Client) GetStream(path string, query url.Values) (io.ReadCloser, error)
|
||||
req.Header.Set("Accept", "text/event-stream")
|
||||
resp, err := c.streamClient.Do(req)
|
||||
if err != nil {
|
||||
logx.Errorf("[终端→MES] <-- SSE connect error %s err=%v", u, err)
|
||||
return nil, err
|
||||
}
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
body, _ := io.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
logx.Errorf("[终端→MES] <-- SSE HTTP %d %s body=%s", resp.StatusCode, u, truncate(string(body), 200))
|
||||
return nil, fmt.Errorf("MES %s 返回 %d:%s", path, resp.StatusCode, truncate(string(body), 200))
|
||||
}
|
||||
logx.Infof("[终端→MES] <-- SSE connected %s", u)
|
||||
return resp.Body, nil
|
||||
}
|
||||
|
||||
@@ -153,9 +158,18 @@ func (c *Client) do(method, u string, body io.Reader, bearer string) ([]byte, ht
|
||||
c.Touch(bearer)
|
||||
}
|
||||
}
|
||||
// 2026-11-16 联调:请求行日志(body 截断 1000;method/u 齐全可定位每一次跨系统调用)
|
||||
var reqBodyForLog []byte
|
||||
if body != nil && method == http.MethodPost {
|
||||
reqBodyForLog, _ = io.ReadAll(body)
|
||||
req.Body = io.NopCloser(bytes.NewReader(reqBodyForLog))
|
||||
}
|
||||
logx.Infof("[终端→MES] --> %s %s body=%s", method, u, truncate(string(reqBodyForLog), 1000))
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
// 2026-11-16 联调:终端→MES 全量交互落日志(传输错误单独记录,grep "[终端→MES]")
|
||||
logx.WithContext(req.Context()).Errorf("[终端→MES] <-- transport error %s %s err=%v", method, u, err)
|
||||
return nil, nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
@@ -164,6 +178,8 @@ func (c *Client) do(method, u string, body io.Reader, bearer string) ([]byte, ht
|
||||
if err != nil {
|
||||
return nil, resp.Header, err
|
||||
}
|
||||
// 请求/响应全量日志(请求体在下面 marshal 后记录;这里记录响应)
|
||||
logx.WithContext(req.Context()).Infof("[终端→MES] <-- HTTP %d %s body=%s", resp.StatusCode, u, truncate(string(respBody), 1000))
|
||||
if resp.StatusCode == http.StatusUnauthorized {
|
||||
// 401 = 工位登录态过期/无效:调用方据此提示重新登录。
|
||||
return respBody, resp.Header, fmt.Errorf("MES %s %s: %w", method, u, ErrAuth)
|
||||
|
||||
@@ -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-BhbsAYk1.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DOqmD9pu.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D2ePuXyL.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user