feat: 重构入库流程,支持序列号与类型解耦,新增通用入库组件

- 重构物料档案字段:将"序列号件"改为"序列号",描述是否有序列号,与类型独立
- 调整入库页逻辑:按物料"序列号"决定记账方式,类型仅用于页签归属
- 新增通用入库组件 InboundEntry,复用三个类型页签的表单逻辑
- 优化成品入库页面,提交后自动切换到入库列表页签
- 修正物料校验提示文案,统一表述为"是否有序列号"
This commit is contained in:
SunYF
2026-10-07 20:00:06 +08:00
parent 756d978900
commit 7c7c16ee6d
20 changed files with 621 additions and 759 deletions
+1 -1
View File
@@ -489,7 +489,7 @@ export const helpWip = {
export const helpAlertCenter = {
title: '预警中心(系统自动触发)',
overview:
'预警中心汇集全系统自动产生的异常/提醒消息,人工无需配置规则——全部由内置触发源自动落库并推送。顶部铃铛角标显示未读数,点击进入本页处理。\n\n八类内置触发源:\n· 扭紧不合格(torque_ng):拧紧扭矩/角度超考核标准时自动告警;\n· 检验不合格(inspection_ng):质量检验判定 NG 时告警;\n· 备料未齐套(material_shortage):工单装机绑定物料未齐套时告警;\n· 库存偏低(inventory_low):可用量低于安全库存时告警;\n· 工单超时(task_overdue):工单超过完成日期未完工时告警;\n· 缓存位满(cache_full):产线缓存/接驳台占满时告警;\n· 数量不符(qty_diff):工位收料实收≠应发时告警(MES 仅预警,明细由 WMS 处理);\n· 应急呼叫(emergency_call):工位终端现场发起的紧急呼叫。\n\n应急呼叫闭环:操作工在工位终端点「应急呼叫」(设备故障/质量异常/缺料/安全等紧急情形)→ 系统即时落一条 type=emergency_call 的未读预警并通过 SSE 推到大屏/看板 → 线长、维修、仓库等相关人员在本页看到未读告警并到场处置 → 处置完点「标记已读」闭环。\n\n处理流程:按 状态(全部/未读/已读)、预警类型、开始时间(默认当天)、结束时间(默认不限)筛选并分页浏览,核实后点行末「标记已读」;已读记录留存备查。',
'预警中心汇集全系统自动产生的异常/提醒消息,人工无需配置规则——全部由内置触发源自动落库并推送。顶部铃铛角标显示未读数,点击进入本页处理。\n\n八类内置触发源:\n· 扭紧不合格(torque_ng):拧紧扭矩/角度超考核标准时自动告警。触发点=拧紧枪完成拧紧后由工位终端自动上报拧紧结果时(拧紧采集落库后约15秒内自动上报;终端离线时缓存在终端、恢复后补报),不依赖操作工点「保存/完成报工」;\n· 检验不合格(inspection_ng):质量检验判定 NG 时告警;\n· 备料未齐套(material_shortage):工单装机绑定物料未齐套时告警;\n· 库存偏低(inventory_low):可用量低于安全库存时告警;\n· 工单超时(task_overdue):工单超过完成日期未完工时告警;\n· 缓存位满(cache_full):产线缓存/接驳台占满时告警;\n· 数量不符(qty_diff):工位收料实收≠应发时告警(MES 仅预警,明细由 WMS 处理);\n· 应急呼叫(emergency_call):工位终端现场发起的紧急呼叫。\n\n应急呼叫闭环:操作工在工位终端点「应急呼叫」(设备故障/质量异常/缺料/安全等紧急情形)→ 系统即时落一条 type=emergency_call 的未读预警并通过 SSE 推到大屏/看板 → 线长、维修、仓库等相关人员在本页看到未读告警并到场处置 → 处置完点「标记已读」闭环。\n\n处理流程:按 状态(全部/未读/已读)、预警类型、开始时间(默认当天)、结束时间(默认不限)筛选并分页浏览,核实后点行末「标记已读」;已读记录留存备查。',
fields: [
{ name: '状态', source: '系统维护(未读/已读)。', purpose: '区分待处理与已处理预警', fill: '筛选项单选:全部/未读/已读' },
{ name: '预警类型', source: '内置触发源自动写入。', purpose: '只关注某一类异常', fill: '下拉选择八类之一,留空=全部' },
+27 -1
View File
@@ -38,8 +38,9 @@
<el-table-column label="创建时间" width="160" align="center">
<template #default="{ row }">{{ fmtTime(row.createdAt) }}</template>
</el-table-column>
<el-table-column label="操作" width="150" align="center" fixed="right">
<el-table-column label="操作" width="200" align="center" fixed="right">
<template #default="{ row }">
<el-button link type="primary" size="small" @click="openDetail(row)">详情</el-button>
<el-button v-if="can('sys.role:edit')" link type="primary" size="small"
:disabled="row.code === 'SUPER_ADMIN'" @click="openEdit(row)">编辑权限</el-button>
<el-button v-if="can('sys.role:delete')" link type="danger" size="small"
@@ -77,6 +78,7 @@
<el-button type="primary" :loading="saving" @click="save">保存</el-button>
</template>
</el-dialog>
<DetailDrawer :visible="detail.show" :title="detail.title" :fields="detail.fields" :data="detail.row" @update:visible="detail.show = $event" />
</div>
<PageHelp :data="helpRole" page="RoleManage" />
</template>
@@ -89,6 +91,7 @@ import request from '../utils/request'
import { fmtTime } from '../utils/format'
import { can } from '../utils/perm'
import PageHelp from '../components/PageHelp.vue'
import DetailDrawer from '../components/DetailDrawer.vue'
import { helpRole } from '../help'
const loading = ref(false)
@@ -96,6 +99,29 @@ const roles = ref([])
const perms = ref([]) // 全部权限定义(MENU + BUTTON)
const treeRef = ref()
/* ---------- 详情抽屉 ---------- */
const detail = reactive({ show: false, title: '角色详情', fields: [], row: null })
function openDetail(row) {
detail.fields = [
{ key: 'id', label: 'ID' },
{ key: 'code', label: '角色编码' },
{ key: 'name', label: '角色名称' },
{ key: 'builtin', label: '内置角色' },
{ key: 'permCount', label: '权限数' },
{ key: 'perms', label: '权限明细' },
{ key: 'remark', label: '备注' },
{ key: 'createdAt', label: '创建时间', type: 'time' }
]
detail.row = {
...row,
builtin: ['SUPER_ADMIN', 'OPERATOR', 'INSPECTOR'].includes(row.code) ? '是' : '否',
permCount: permCount(row),
perms: permSummary(row),
remark: row.remark || '-'
}
detail.show = true
}
const codeName = computed(() => {
const m = {}
for (const p of perms.value) m[p.code] = p.name
+24 -4
View File
@@ -27,12 +27,12 @@
</el-table-column>
<el-table-column label="接驳台(实体)" width="100" align="center">
<template #default="{ row }">
<el-tag size="small" :type="row.hasDock ? 'success' : 'info'">{{ row.hasDock ? '有' : '无' }}</el-tag>
<el-tag size="small" :type="hasDockOf(row.stationNo) ? 'success' : 'info'">{{ hasDockOf(row.stationNo) ? '有' : '无' }}</el-tag>
</template>
</el-table-column>
<el-table-column label="接驳台编码" min-width="150">
<el-table-column label="接驳台编码" min-width="170">
<template #default="{ row }">
<span v-if="row.dockCode">{{ row.dockCode }}</span>
<span v-if="dockCodesOf(row.stationNo)">{{ dockCodesOf(row.stationNo) }}</span>
<span v-else style="color:#909399">未绑定</span>
</template>
</el-table-column>
@@ -121,6 +121,26 @@ import { helpStation } from '../help'
const stations = ref([])
const flows = ref([])
// 接驳台主数据(真源在 dock 表):一工位可绑多个接驳台(R1/R2),展示按 dock.station_no 聚合
const dockByStation = ref({})
async function loadDocks() {
const data = await request.get('/docks', { params: { page: 1, size: 200 } })
const map = {}
for (const d of data?.list || []) {
const no = Number(d.stationNo) || 0
if (no <= 0) continue
;(map[no] = map[no] || []).push(d.dockCode)
}
dockByStation.value = map
}
function dockCodesOf(no) {
const codes = dockByStation.value[Number(no)] || []
return codes.length ? codes.join(' / ') : ''
}
function hasDockOf(no) {
return (dockByStation.value[Number(no)] || []).length > 0
}
// 终端页签固定集合(与工位终端 Main.vue 页签一一对应)
const TAB_OPTIONS = [
@@ -217,7 +237,7 @@ async function remove(row) {
// ---------- 工位派工已删除:路线由工单「工艺组合」决定,绑定关系即本页下拉选择 ----------
onMounted(async () => {
await load()
await Promise.all([load(), loadDocks()])
flows.value = (await request.get('/process-flows', { params: { pageSize: 1000, page: 1 } }))?.list || []
})
</script>
@@ -175,7 +175,9 @@ function stepDisplay(step) {
}
async function load() {
stations.value = (await request.get('/stations')) || []
const list = (await request.get('/stations')) || []
// 虚拟工位作业只允许选择虚拟工位(0/13/14/15),过滤掉实体工位,防止误选
stations.value = list.filter((s) => s.stationType === 'OFFLINE')
}
async function loadTask() {
+4
View File
@@ -189,6 +189,10 @@ var schemaPatchSQL = []string{
// 工位↔接驳台 1:1:部分唯一索引只约束已绑定工位(station_no>0)的行,库房/其他接驳台不参与。
`CREATE UNIQUE INDEX IF NOT EXISTS ux_dock_station_no ON dock (station_no) WHERE station_no > 0`,
// ---- 接驳台布局修正(2026-10-06):按产线布局,工位1~10 各配 R1/R2 两个接驳台(对应1号/2号AGV),----
// ---- 一个工位可绑多个接驳台,撤销 1:1 唯一索引;对应关系以 dock 表内置数据为准 ----
`DROP INDEX IF EXISTS ux_dock_station_no`,
// ---- 生产模型重构(2026-09-22 定稿):删除「工序编号/工位派工」旧模型遗留 ----
// 路线唯一源头 = 工单工艺组合 flow_combination([{flowId,stationNo}],工位号即顺序号);
// 装配绑定/备料/齐套全部改走工艺物料清单 flow_material,bom_item/material_request/process_code 退役。
@@ -89,7 +89,7 @@ func ListDocksMaintHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
size = 20
}
list, err := query.
Order(ent.Desc("createdAt"), ent.Desc("id")).
Order(ent.Desc(dock.FieldCreatedAt), ent.Desc(dock.FieldID)).
Offset((page - 1) * size).Limit(size).All(r.Context())
if err != nil {
httpx.Fail(w, 3113, "查询接驳台失败:"+err.Error())
+14 -10
View File
@@ -8,7 +8,7 @@ import (
"bj_power_mes/ent"
"bj_power_mes/ent/dailyplan"
"bj_power_mes/ent/station"
"bj_power_mes/ent/dock"
"bj_power_mes/ent/workorder"
"bj_power_mes/ent/workpiece"
)
@@ -206,8 +206,9 @@ func (s *Service) saveDailyPlanBatch(ctx context.Context, req DailyPlanReq, oper
return nil
}
// SuggestedDockCodes 查工单工艺组合覆盖工位的接驳台编码(DOCKxx),供排产/备料默认推荐。
// 路线唯一源头 = 工单 flow_combination(按工位号升序),接驳台取 station.dock_code。
// SuggestedDockCodes 查工单工艺组合覆盖工位的接驳台编码,供排产/备料默认推荐。
// 路线唯一源头 = 工单 flow_combination(按工位号升序);接驳台真源 = dock 表(按 station_no 聚合,
// 一个工位可配 R1/R2 多个接驳台),station.dock_code 仅默认兜底,故统一从 dock 表取全集。
func (s *Service) SuggestedDockCodes(ctx context.Context, orderNo string) []string {
wo, err := s.ctx.EntClient.WorkOrder.Query().Where(workorder.WorkOrderNo(orderNo)).First(ctx)
if err != nil {
@@ -217,16 +218,19 @@ func (s *Service) SuggestedDockCodes(ctx context.Context, orderNo string) []stri
if len(items) == 0 {
return nil
}
sts, err := s.ctx.EntClient.Station.Query().Where(station.StationNoIn(RouteStationsOfWO(items)...)).All(ctx)
docks, err := s.ctx.EntClient.Dock.Query().
Where(dock.StationNoIn(RouteStationsOfWO(items)...), dock.DockTypeEQ("line")).
Order(ent.Asc(dock.FieldStationNo), ent.Asc(dock.FieldDockCode)).
All(ctx)
if err != nil {
return nil
}
seen := map[string]bool{}
out := []string{}
for _, st := range sts {
if st.DockCode != "" && !seen[st.DockCode] {
seen[st.DockCode] = true
out = append(out, st.DockCode)
for _, d := range docks {
if d.DockCode != "" && !seen[d.DockCode] {
seen[d.DockCode] = true
out = append(out, d.DockCode)
}
}
return out
@@ -357,8 +361,8 @@ func (s *Service) ListDailyPlansPaged(ctx context.Context, planDateStart, planDa
// UnplannedWorkOrder 未排产工单(供日排产页「未排产」入口展示)
type UnplannedWorkOrder struct {
OrderNo string `json:"orderNo"`
ProductTypeId int `json:"productTypeId"`
OrderNo string `json:"orderNo"`
ProductTypeId int `json:"productTypeId"`
Quantity int `json:"quantity"`
DueDate string `json:"dueDate"`
Status string `json:"status"`
+10 -6
View File
@@ -11,9 +11,9 @@ import (
"time"
"bj_power_mes/ent"
"bj_power_mes/ent/dock"
"bj_power_mes/ent/flowmaterial"
"bj_power_mes/ent/materialrequest"
"bj_power_mes/ent/station"
"bj_power_mes/ent/workorder"
"bj_power_mes/internal/wmsclient"
)
@@ -114,12 +114,16 @@ func (s *Service) GenerateMaterialRequest(ctx context.Context, planDate string,
for _, it := range g.items {
stationsByFlow[it.FlowId] = append(stationsByFlow[it.FlowId], it.StationNo)
}
// 工位号 → 接驳台编码
// 工位号 → 默认接驳台编码:真源 = dock 表(一工位可绑 R1/R2 多个接驳台,按编码升序取第一个为默认)
dockByStation := map[int]string{}
if sts, e := s.ctx.EntClient.Station.Query().
Where(station.StationNoIn(RouteStationsOfWO(g.items)...)).All(ctx); e == nil {
for _, st := range sts {
dockByStation[st.StationNo] = st.DockCode
if dks, e := s.ctx.EntClient.Dock.Query().
Where(dock.StationNoIn(RouteStationsOfWO(g.items)...), dock.DockTypeEQ("line")).
Order(ent.Asc(dock.FieldStationNo), ent.Asc(dock.FieldDockCode)).
All(ctx); e == nil {
for _, d := range dks {
if _, ok := dockByStation[d.StationNo]; !ok && d.DockCode != "" {
dockByStation[d.StationNo] = d.DockCode
}
}
}
for flowId, stations := range stationsByFlow {
+13 -12
View File
@@ -30,17 +30,17 @@ func (s *Service) Seed(ctx context.Context) error {
"produce.processflow", "produce.station", "produce.performance", "produce.processcard",
// 按钮级权限(块2)
"produce.workorder:add", "produce.workorder:edit", "produce.workorder:delete",
"produce.workorder:dailyplan", "produce.material:generate", "produce.material:outbound",
"produce.plc:send", "produce.product:add", "produce.product:edit", "produce.product:delete",
"produce.workorder:dailyplan", "produce.material:generate", "produce.material:outbound",
"produce.plc:send", "produce.product:add", "produce.product:edit", "produce.product:delete",
"produce.processflow:add", "produce.processflow:edit", "produce.processflow:delete",
"produce.processflow:upload", "produce.station:edit", "produce.station:add", "produce.station:delete",
// 预警中心 / 附件中心(含归档清理按钮)
"sys.alert", "sys.attachment", "sys.attachment:manage",
// 数量不符处理(上报在工位终端,处理在本页)
"produce.qty", "produce.qty:handle",
// 质量检验:过程检操作工自检(process);完工检(final)由质检员专属(见下方 dropCodes,补1 权限粒度拆分)
"produce.quality", "produce.quality:process",
}
// 数量不符处理(上报在工位终端,处理在本页)
"produce.qty", "produce.qty:handle",
// 质量检验:过程检操作工自检(process);完工检(final)由质检员专属(见下方 dropCodes,补1 权限粒度拆分)
"produce.quality", "produce.quality:process",
}
} else if r.code == "INSPECTOR" {
codes = []string{"produce.trace", "produce.wip", "produce.performance", "sys.eventlog",
"sys.inspect", "sys.inspect:checkin", "sys.inspect:point", "sys.inspect:process",
@@ -203,7 +203,7 @@ func (s *Service) Seed(ctx context.Context) error {
seedStations(ctx, s)
// 5. 接驳台主数据(真源在 MES,2026-09-21 自 WMS 迁入);系统预置只读
seedDocks(ctx, s)
// 6. 接驳台↔工位 1:1 绑定(系统预置只读主数据,页面不可更改,由种子初始化)
// 6. 接驳台↔工位默认绑定(系统预置只读主数据;一工位可绑多接驳台,station.dock_code 仅存默认接驳台兜底)
bindStationDocks(ctx, s)
return nil
}
@@ -266,9 +266,10 @@ func seedStations(ctx context.Context, s *Service) {
}
}
// bindStationDocks 接驳台↔工位 1:1 绑定:接驳台为系统预置只读主数据,绑定关系由种子初始化、页面不可更改。
// 内置且带接驳台的工位(station_no 1~10)各绑定一个产线接驳台(DOCK01~DOCK10);以 dock.station_no 为对照真源,
// 若当前绑定不一致则回填,幂等可重复执行。库房/虚拟接驳台(station_no=0)及无接驳台工位不参与绑定。
// bindStationDocks 接驳台↔工位默认绑定:按产线布局(2026-10-06),工位1~10 各配 R1/R2 两个接驳台,
// 一个工位可对应多个接驳台,对应关系以 dock 表内置数据(用户内置/种子数据)为准,页面展示也按 dock 表聚合。
// station.dock_code 仅作为「默认接驳台」兜底字段:仅在该工位尚未绑定时按 dock.station_no 回填一次,
// 不覆盖既有值(避免一工位多接驳台时来回翻转);库房/虚拟接驳台(station_no=0)及无接驳台工位不参与。
func bindStationDocks(ctx context.Context, s *Service) {
docks, err := s.ctx.EntClient.Dock.Query().
Where(dock.StationNoGT(0), dock.DockTypeEQ("line")).
@@ -282,7 +283,7 @@ func bindStationDocks(ctx context.Context, s *Service) {
if err != nil || st == nil {
continue
}
if !st.HasDock || !st.IsBuiltin || st.DockCode == d.DockCode {
if st.DockCode != "" || !st.HasDock || !st.IsBuiltin {
continue
}
_, _ = s.ctx.EntClient.Station.UpdateOneID(st.ID).SetDockCode(d.DockCode).Save(ctx)
+1 -1
View File
@@ -6,7 +6,7 @@
<title>MES 产线控制</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'/><circle cx='16' cy='16' r='4.2' fill='none' stroke='%23fff' stroke-width='2'/><path d='M16 5v3M16 24v3M5 16h3M24 16h3M8.2 8.2l2.1 2.1M21.7 21.7l2.1 2.1M23.8 8.2l-2.1 2.1M10.3 21.7l-2.1 2.1' stroke='%23fff' stroke-width='2' stroke-linecap='round'/></svg>">
<script type="module" crossorigin src="./assets/index-DgFOd_Xf.js"></script>
<script type="module" crossorigin src="./assets/index-CoNOFoBM.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-9DhFmzXa.css">
</head>
<body>