refactor: 重构工艺工序相关命名与数据模型
1. 全局替换"工序"为"工艺"统一术语,包括页面文案、枚举、注释
2. 重构工单与工件工艺数据模型:
- 新增工艺组合表flow_material作为备料/齐套唯一源头
- 新增工位状态表station_state支持自主停单/恢复接单
- 移除station_process派工表,改用工单工艺组合作为路线唯一源头
- 替换processCode为flowId作为工艺关联标识
- 重构工件当前进度字段为currentStationNo
3. 删除冗余的静态备份资源文件
4. 调整物料选择组件默认启用仅显示激活物料
5. 优化工单创建/编辑逻辑,新增工艺组合校验与保存
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
// 工位终端全局状态(模块级单例)
|
||||
// 终端一个工位一个进程:工位号由服务端配置固定,前端不可修改。
|
||||
// 状态集中在这里,作业/物料/移料/工艺各面板共享,避免多份轮询与状态不一致。
|
||||
import { computed, reactive } from 'vue'
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
import {
|
||||
getBindPanel,
|
||||
getConfig,
|
||||
getLineMoves,
|
||||
getLinePoints,
|
||||
getStationState,
|
||||
getSyncStats,
|
||||
getTaskCurrent,
|
||||
getTighteningList,
|
||||
getWip,
|
||||
issueLineMove,
|
||||
occupyLinePoint,
|
||||
pauseStation,
|
||||
submitTorque
|
||||
} from '../api'
|
||||
import { getUser } from '../utils/request'
|
||||
@@ -32,6 +34,8 @@ export const state = reactive({
|
||||
stepChecks: {},
|
||||
bindInputs: {},
|
||||
startedAt: '',
|
||||
paused: false,
|
||||
pauseReason: '',
|
||||
lastError: ''
|
||||
})
|
||||
|
||||
@@ -54,6 +58,9 @@ export const tightRows = computed(() => state.tightRows)
|
||||
export const wip = computed(() => state.wip)
|
||||
// 进工位(上料)时刻——作业时长起点(P0-3),报工时随载荷上传 MES
|
||||
export const startedAt = computed(() => state.startedAt)
|
||||
// 停单状态(当天):工人可停止/恢复接单,停单期间阻止新的报工提交
|
||||
export const paused = computed(() => state.paused)
|
||||
export const pauseReason = computed(() => state.pauseReason)
|
||||
|
||||
// 当前步骤(5.1 工艺文件高亮):第一个尚未录入的手填步骤;全部录入后回退到首个步骤
|
||||
export const currentStep = computed(() => {
|
||||
@@ -85,6 +92,8 @@ export const missingTorqueSteps = computed(
|
||||
export const orderNos = computed(() => (Array.isArray(state.task?.orderNos) ? state.task.orderNos : []))
|
||||
export const flowName = computed(() => state.task?.flow?.name || '-')
|
||||
export const flowActive = computed(() => !!state.task?.flowActive)
|
||||
// 本工位绑定的工艺 ID(station.flowId,随任务下发):装机绑定/报工一律按 flowId 查询与上报
|
||||
export const flowId = computed(() => Number(state.task?.flowId || 0))
|
||||
|
||||
// 本工位的产线点位台账(唯一事实源:本工位当前是否有工件)
|
||||
export const myPoint = computed(() =>
|
||||
@@ -133,7 +142,7 @@ export const missingSteps = computed(() =>
|
||||
return v === null || v === undefined || v === ''
|
||||
})
|
||||
)
|
||||
// 绑定是否齐套(本工序未配置需绑物料时不拦截)
|
||||
// 绑定是否齐套(本工艺未配置需绑物料时不拦截)
|
||||
export const bindBlocking = computed(
|
||||
() => !!(state.bindPanel && state.bindPanel.enabled && !state.bindPanel.complete)
|
||||
)
|
||||
@@ -141,6 +150,8 @@ export const canReport = computed(
|
||||
() =>
|
||||
!!state.currentSn &&
|
||||
!!state.orderNo &&
|
||||
flowId.value > 0 &&
|
||||
!state.paused &&
|
||||
!bindBlocking.value &&
|
||||
missingSteps.value.length === 0 &&
|
||||
missingChecks.value.length === 0 &&
|
||||
@@ -259,13 +270,13 @@ export async function submitTorqueStep(step, torque, angle) {
|
||||
}
|
||||
|
||||
export async function loadBind() {
|
||||
const code = Number(state.stationNo)
|
||||
if (!state.currentSn || !code) {
|
||||
const fid = flowId.value
|
||||
if (!state.currentSn || !fid) {
|
||||
state.bindPanel = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const p = await getBindPanel({ sn: state.currentSn, processCode: code })
|
||||
const p = await getBindPanel({ sn: state.currentSn, flowId: fid })
|
||||
state.bindPanel = p
|
||||
;(p?.required || []).forEach((r) => {
|
||||
if (state.bindInputs[r.materialCode] === undefined) state.bindInputs[r.materialCode] = ''
|
||||
@@ -294,7 +305,35 @@ export async function loadWip(atStation) {
|
||||
}
|
||||
|
||||
export function refreshAll() {
|
||||
return Promise.all([loadTask(), loadTight(), loadStats(), loadPoints(), loadWip()])
|
||||
return Promise.all([loadTask(), loadTight(), loadStats(), loadPoints(), loadWip(), loadStationState()])
|
||||
}
|
||||
|
||||
// loadStationState 拉取本工位当天的停单状态(MES /api/internal/station/state),刷新横幅与按钮。
|
||||
// 拉取失败保持现状,避免网络抖动误清停单横幅。
|
||||
export async function loadStationState() {
|
||||
if (!state.stationNo) return
|
||||
try {
|
||||
const list = await getStationState()
|
||||
const rows = Array.isArray(list) ? list : (list?.list || [])
|
||||
const mine = rows.find((s) => Number(s.stationNo) === Number(state.stationNo))
|
||||
if (mine) {
|
||||
state.paused = !!mine.paused
|
||||
state.pauseReason = mine.reason || ''
|
||||
}
|
||||
} catch { /* 静默 */ }
|
||||
}
|
||||
|
||||
// setPaused 停止接单/恢复接单:调 MES /api/internal/station/pause,成功后同步本地状态。
|
||||
// 恢复不要求原因(物料是否齐套由工人自行判断,系统不拦截恢复)。
|
||||
export async function setPaused(next, reason) {
|
||||
await pauseStation({
|
||||
stationNo: Number(state.stationNo),
|
||||
paused: !!next,
|
||||
reason: next ? (reason || '') : '',
|
||||
operator: operatorName()
|
||||
})
|
||||
state.paused = !!next
|
||||
state.pauseReason = next ? (reason || '') : ''
|
||||
}
|
||||
|
||||
// 切换工件:清空步骤录入与绑定缓存,重新加载拧紧/绑定
|
||||
@@ -347,6 +386,11 @@ export async function moveOut(sn, toPoint) {
|
||||
|
||||
export const operatorName = () => user.name || user.username || ''
|
||||
|
||||
// flowId 随任务到达后再触发一次绑定加载(上线位/首次拉到任务时 flowId 才有值)
|
||||
watch(flowId, (v) => {
|
||||
if (v > 0 && state.currentSn && !state.bindPanel) loadBind()
|
||||
})
|
||||
|
||||
// markStationArrival 记录「进工位 / 上料到本工位」时刻(作业时长起点,P0-3)。
|
||||
// 仅在尚未记录时写入,同一工件重复扫码/确认不会重置起点。
|
||||
export function markStationArrival() {
|
||||
|
||||
Reference in New Issue
Block a user