feat(mes): 添加定时同步可生产数量到WMS及BOM项相关标准字段

- 在main.go中添加定时任务每10分钟同步可生产数量到WMS系统
- 为BomItem实体添加relatedStandard字段及相关CRUD方法
- 为InspectionRecord实体添加reportNo、materialCode、materialName等字段
- 更新ent schema确保新字段的验证和默认值设置
- 添加必要的数据库迁移和字段映射逻辑
This commit is contained in:
SunYF
2026-09-17 12:49:07 +08:00
parent b4b274301d
commit 1cc93795ce
191 changed files with 24504 additions and 1250 deletions
+128
View File
@@ -0,0 +1,128 @@
<template>
<el-card>
<el-form inline>
<el-form-item label="当前工位">
<el-select v-model="stationNo" clearable placeholder="全部工位" style="width:180px" @change="load">
<el-option label="上线位(虚拟)" :value="0" />
<el-option v-for="s in stations" :key="s.stationNo" :label="`${s.name || ('工位' + s.stationNo)}`" :value="s.stationNo" />
<el-option label="下线位(虚拟)" :value="13" />
</el-select>
</el-form-item>
<el-form-item label="状态">
<el-select v-model="statusFilter" clearable placeholder="全部状态" style="width:140px">
<el-option label="已上线" value="ONLINE" />
<el-option label="在制" value="PROCESSING" />
<el-option label="返修" value="REPAIR" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="load">查询</el-button>
</el-form-item>
</el-form>
<el-alert type="info" :closable="false" style="margin-bottom:12px"
title="在制品 = 已进线但尚未完工的工件(含跨天继续停留)。日排产仅排「未开工数量」,不会重复排产。" />
<el-row :gutter="16" style="margin-bottom:14px">
<el-col :span="6">
<el-card shadow="never" class="stat-card"><div class="stat-label">在制品总数</div><div class="stat-value">{{ filtered.length }}</div></el-card>
</el-col>
<el-col :span="6">
<el-card shadow="never" class="stat-card"><div class="stat-label">已上线</div><div class="stat-value">{{ countBy('ONLINE') }}</div></el-card>
</el-col>
<el-col :span="6">
<el-card shadow="never" class="stat-card"><div class="stat-label">在制</div><div class="stat-value ok">{{ countBy('PROCESSING') }}</div></el-card>
</el-col>
<el-col :span="6">
<el-card shadow="never" class="stat-card"><div class="stat-label">返修</div><div class="stat-value ng">{{ countBy('REPAIR') }}</div></el-card>
</el-col>
</el-row>
<el-table :data="filtered" border stripe size="small" v-loading="loading" :row-class-name="rowClass">
<el-table-column prop="sn" label="工件SN" min-width="150" show-overflow-tooltip />
<el-table-column prop="orderNo" label="工单号" min-width="140" show-overflow-tooltip />
<el-table-column prop="productCode" label="产品编号" min-width="120" show-overflow-tooltip />
<el-table-column prop="productName" label="产品名称" min-width="120" show-overflow-tooltip />
<el-table-column prop="currentStationName" label="当前工位" width="130" />
<el-table-column label="状态" width="90" align="center">
<template #default="{ row }">
<el-tag :type="statusTag(row.status)" effect="plain">{{ statusText(row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="进度" width="120" align="center">
<template #default="{ row }">{{ row.doneSteps }} / {{ row.totalSteps }}</template>
</el-table-column>
<el-table-column prop="onlineAt" label="上线时间" width="170" />
<el-table-column label="停留时长" width="130" align="right">
<template #default="{ row }">
<span :style="row.dwellSec > 86400 ? 'color:#f56c6c;font-weight:600' : ''">{{ fmtDur(row.dwellSec) }}</span>
<el-tag v-if="row.dwellSec > 86400" type="danger" size="small" effect="plain" style="margin-left:4px">超期</el-tag>
</template>
</el-table-column>
</el-table>
<el-empty v-if="!loading && !filtered.length" description="当前无在制品" />
</el-card>
<PageHelp :data="helpWip" page="Wip" />
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import request from '../utils/request'
import { loadStations } from '../utils/stations'
import PageHelp from '../components/PageHelp.vue'
import { helpWip } from '../help'
const stations = ref([])
const stationNo = ref('')
const statusFilter = ref('')
const list = ref([])
const loading = ref(false)
const filtered = computed(() =>
statusFilter.value ? list.value.filter((x) => x.status === statusFilter.value) : list.value
)
function countBy(st) { return list.value.filter((x) => x.status === st).length }
// 超期(停留 >1 天)高亮
function rowClass({ row }) { return row.dwellSec > 86400 ? 'wip-overdue' : '' }
function statusText(s) {
return { ONLINE: '已上线', PROCESSING: '在制', REPAIR: '返修' }[s] || s
}
function statusTag(s) {
return { ONLINE: 'info', PROCESSING: 'success', REPAIR: 'danger' }[s] || 'info'
}
function fmtDur(sec) {
const s = Number(sec) || 0
if (s <= 0) return '-'
if (s < 60) return s + '秒'
const m = Math.floor(s / 60)
if (m < 60) return `${m}分${s % 60}秒`
const h = Math.floor(m / 60)
return `${h}时${m % 60}分`
}
async function load() {
loading.value = true
try {
const params = {}
if (stationNo.value !== '' && stationNo.value !== null) params.stationNo = stationNo.value
list.value = (await request.get('/workpieces/in-process', { params })) || []
} finally {
loading.value = false
}
}
onMounted(async () => {
stations.value = await loadStations()
load()
})
</script>
<style scoped>
.stat-card { text-align: center; }
.stat-label { color: #909399; font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; color: #303133; }
.stat-value.ok { color: #67c23a; }
.stat-value.ng { color: #f56c6c; }
:deep(.wip-overdue) { background: #fef0f0; }
</style>