feat: 新增产品工艺管理与工序审核功能
- 新增产品工艺(product_process)及明细(product_process_item)数据模型 - 新增工序审核开关(need_audit)与审核角色(audit_role)字段 - 新增待审核签字页面与路由 - 优化 WMS/MES 接口交互,增加业务错误处理与友好提示 - 补充库存过滤逻辑,避免返回已出库 SN 数据 - 调整默认查询时间范围为近一个月,优化用户体验
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
Name: bj_power_wms
|
||||
Host: 0.0.0.0
|
||||
Port: 8890
|
||||
Timeout: 10000
|
||||
# 请求体上限:go-zero 默认仅 1MB,会拦住照片/PDF/Excel 上传;取各文件类型上限的最大值(50MB)
|
||||
MaxBytes: 52428800
|
||||
|
||||
# PostgreSQL
|
||||
Postgres:
|
||||
Host: 127.0.0.1
|
||||
Port: 5432
|
||||
User: postgres
|
||||
Password: postgres
|
||||
DBName: bj_power_wms
|
||||
SSLMode: disable
|
||||
|
||||
# JWT(短有效期 + 滑动续签)
|
||||
Auth:
|
||||
AccessSecret: Hardman_2026
|
||||
AccessExpire: 3600
|
||||
|
||||
# 项目间内部 API 写死 token
|
||||
Internal:
|
||||
Token: Hardman_2026
|
||||
|
||||
# MES 服务对接(备料单拉取/状态回写,AGV 配送用)
|
||||
Mes:
|
||||
BaseURL: http://127.0.0.1:8888
|
||||
Token: Hardman_2026
|
||||
|
||||
Log:
|
||||
Mode: file
|
||||
Path: logs
|
||||
Level: info
|
||||
|
||||
Redis:
|
||||
Host: 127.0.0.1:6379
|
||||
Type: node
|
||||
|
||||
# 海康 AGV(RCS-2000) 对接:未接真实 RCS 前保持 mock(模拟下发成功/到位)
|
||||
# 现场对接时填 EnableMock: false + RCS 服务地址 + appKey/appSecret
|
||||
Agv:
|
||||
EnableMock: true
|
||||
BaseURL: ""
|
||||
AppKey: ""
|
||||
AppSecret: ""
|
||||
|
||||
# 前端页面托管(原库房客户端 8891 已合并进主服务)
|
||||
Web:
|
||||
OpenBrowser: false
|
||||
|
||||
# 命令行敏感操作门禁密码(migrate/reset-all/seed 需输入,独立于后台登录账号密码)
|
||||
Cli:
|
||||
AdminPassword: "Hardman_2026"
|
||||
|
||||
# 附件存储(年/月/日/文件类型/uuid.ext,库内只存相对路径,不存绝对路径)
|
||||
# 生产环境改 RootDir: /data/bj_power/attachments
|
||||
Attachment:
|
||||
RootDir: "D:/hardman/bj_power/attachments"
|
||||
DefaultMaxSize: 20971520 # 默认单文件 20MB
|
||||
MaxSize:
|
||||
PROCESS_PDF: 52428800 # 工艺流程作业指导书 50MB
|
||||
INSPECTION_PHOTO: 20971520 # 检验照片 20MB
|
||||
EXCEL_IMPORT: 10485760 # Excel 导入 10MB
|
||||
LocalRetentionYears: 1 # 本地保留最近 1 年
|
||||
DiskWarnPercent: 20 # 剩余空间 <20% 告警
|
||||
DiskCriticalPercent: 10 # 剩余空间 <10% 提示清理/归档
|
||||
DiskCheckHour: 7 # 每天 07:00 检测
|
||||
ArchiveDir: "" # 外部备份目录(NAS/移动硬盘),留空则归档仅标记
|
||||
@@ -241,7 +241,7 @@ onMounted(() => { loadDocks(); loadTasks(); loadMode() })
|
||||
<!-- ③ 下发 AGV(仓管操作) -->
|
||||
<el-tab-pane label="下发AGV" name="dispatch" lazy>
|
||||
<div class="toolbar">
|
||||
<el-select v-model="mrQuery.status" style="width: 130px" @change="mrPage.current = 1; loadMrs()">
|
||||
<el-select v-model="mrQuery.status" style="width: 130px" placeholder="请选择状态" @change="mrPage.current = 1; loadMrs()">
|
||||
<el-option label="待发料(PENDING)" value="PENDING" />
|
||||
<el-option label="已备料(已出库)" value="LOCKED" />
|
||||
<el-option label="配送中(DELIVERING)" value="DELIVERING" />
|
||||
@@ -251,7 +251,7 @@ onMounted(() => { loadDocks(); loadTasks(); loadMode() })
|
||||
<span class="tip">勾选待发料行 → 行内可改目标接驳台 → 下发</span>
|
||||
</div>
|
||||
<div class="toolbar">
|
||||
<el-select v-model="sourceDock" style="width: 130px">
|
||||
<el-select v-model="sourceDock" style="width: 130px" placeholder="请选择接驳台">
|
||||
<el-option v-for="d in dockOptions" :key="d" :label="d" :value="d" />
|
||||
</el-select>
|
||||
<el-button @click="batchSetDock('DOCK01')">批量设 DOCK01</el-button>
|
||||
|
||||
@@ -792,7 +792,7 @@ async function onMaterialFile(e) {
|
||||
<el-input v-model="nodeForm.remark" type="textarea" :rows="2" placeholder="备注(可空)" />
|
||||
</el-form-item>
|
||||
<el-form-item v-if="nodeEditing" label="状态">
|
||||
<el-select v-model="nodeForm.status" style="width:130px">
|
||||
<el-select v-model="nodeForm.status" style="width:130px" placeholder="请选择状态">
|
||||
<el-option label="启用" value="启用" />
|
||||
<el-option label="停用" value="停用" />
|
||||
</el-select>
|
||||
|
||||
@@ -279,7 +279,7 @@ onActivated(() => {
|
||||
<div>
|
||||
<div style="font-weight:600;margin-bottom:6px">批次件导入(序列号=否 的物料)</div>
|
||||
<div style="margin-bottom:8px;color:#909399;font-size:12px">
|
||||
列头顺序(首行忽略)<b>图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 备注</b>
|
||||
列头顺序(首行忽略)<b>图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 架 | 层 | 位 | 备注 | 检测单号 | 产品工号 | 归属类型 | 归属编号</b>(架/层/位/备注/检测单号/产品工号/归属 可缺列,缺则留空)
|
||||
</div>
|
||||
<el-upload ref="batchUploadRef" :auto-upload="false" accept=".xlsx" :limit="1" drag
|
||||
:on-exceed="(f) => onExceed(f, 'batch')">
|
||||
@@ -293,7 +293,7 @@ onActivated(() => {
|
||||
<div>
|
||||
<div style="font-weight:600;margin-bottom:6px">SN 件导入(序列号=是 的物料)</div>
|
||||
<div style="margin-bottom:8px;color:#909399;font-size:12px">
|
||||
列头顺序(首行忽略)<b>图号 | SN | 区域 | 生产日期 | 供应商</b>
|
||||
列头顺序(首行忽略)<b>图号 | SN | 区域 | 生产日期 | 供应商 | 架 | 层 | 位 | 备注 | 检测单号 | 产品工号 | 归属类型 | 归属编号</b>(架/层/位/备注/检测单号/产品工号/归属 可缺列,缺则留空)
|
||||
</div>
|
||||
<el-upload ref="snUploadRef" :auto-upload="false" accept=".xlsx" :limit="1" drag
|
||||
:on-exceed="(f) => onExceed(f, 'sn')">
|
||||
|
||||
@@ -334,7 +334,14 @@ const inboundTypeLabel = (t) => {
|
||||
const m = { purchase: '采购入库', semi: '半成品入库', finished: '成品入库', return: '退库入库', other: '其他入库' }
|
||||
return m[t] || t || '-'
|
||||
}
|
||||
const pendingTargetLabel = (d) => (d.matManageMode === 3 ? '其他' : d.snMode === 1 ? '序列号件' : '批次件')
|
||||
// 与物料档案字段口径一致:类型(1结构件/2电气件/3其他) / 序列号(1是/2否/0未选择)
|
||||
const matTypeText = (m) => (m === 3 ? '其他' : m === 2 ? '电气件' : '结构件')
|
||||
const snModeText = (v) => (Number(v) === 1 ? '是' : Number(v) === 2 ? '否' : '未选择')
|
||||
// 抽屉明细行 snMode 取首行(同一物料编码所有行一致,抽屉打开即加载)
|
||||
const headSnMode = computed(() => {
|
||||
const first = detailDrawer.list && detailDrawer.list[0]
|
||||
return first ? first.snMode : null
|
||||
})
|
||||
|
||||
function loadPending() {
|
||||
pendingLoading.value = true
|
||||
@@ -548,7 +555,7 @@ onMounted(() => {
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
<el-card shadow="never" header="待检清单(quality_status=未检,按入库单分组;点「查看明细」右侧抽屉)">
|
||||
<el-card shadow="never" header="待检清单">
|
||||
<el-table :data="pendingRows" border size="small" v-loading="pendingLoading" empty-text="暂无待检(全部已检)">
|
||||
<el-table-column prop="inboundNo" label="入库单号" min-width="160" />
|
||||
<el-table-column label="入库类型" width="110" align="center">
|
||||
@@ -622,7 +629,7 @@ onMounted(() => {
|
||||
</el-form-item>
|
||||
<el-form-item label="归属">
|
||||
<div style="display:flex;gap:8px;width:100%;max-width:560px">
|
||||
<el-select v-model="ownershipType" style="width:150px" :disabled="!!sourceInboundNo">
|
||||
<el-select v-model="ownershipType" style="width:150px" placeholder="请选择归属" :disabled="!!sourceInboundNo">
|
||||
<el-option label="合同号" value="workorder" />
|
||||
<el-option label="科技项目号" value="project" />
|
||||
<el-option label="其他" value="other" />
|
||||
@@ -894,10 +901,13 @@ onMounted(() => {
|
||||
<el-drawer v-model="detailDrawer.visible"
|
||||
:title="`待检明细:${detailDrawer.row?.inboundNo} · ${detailDrawer.row?.materialCode}`"
|
||||
size="640px" destroy-on-close>
|
||||
<div v-if="detailDrawer.row" style="margin-bottom:10px">
|
||||
<el-tag type="info" size="small">{{ inboundTypeLabel(detailDrawer.row.inboundType) }}</el-tag>
|
||||
<el-tag size="small" style="margin-left:6px">{{ detailDrawer.row.materialName || '-' }}</el-tag>
|
||||
<el-tag size="small" style="margin-left:6px">{{ ownershipTypeLabel(detailDrawer.row.ownershipType) }}:{{ detailDrawer.row.ownershipNo || '-' }}</el-tag>
|
||||
<div v-if="detailDrawer.row" class="insp-head">
|
||||
<span class="ih-item"><b>入库类型</b>{{ inboundTypeLabel(detailDrawer.row.inboundType) }}</span>
|
||||
<span class="ih-item"><b>图号</b>{{ detailDrawer.row.materialCode || '-' }}</span>
|
||||
<span class="ih-item"><b>名称</b>{{ detailDrawer.row.materialName || '-' }}</span>
|
||||
<span class="ih-item"><b>类型</b>{{ matTypeText(detailDrawer.row.matManageMode) }}</span>
|
||||
<span class="ih-item"><b>序列号</b>{{ snModeText(headSnMode) }}</span>
|
||||
<span class="ih-item"><b>归属</b>{{ ownershipTypeLabel(detailDrawer.row.ownershipType) }}:{{ detailDrawer.row.ownershipNo || '-' }}</span>
|
||||
</div>
|
||||
<el-table :data="detailDrawer.list" border size="small" v-loading="detailDrawer.loading" empty-text="暂无明细">
|
||||
<el-table-column width="50" align="center">
|
||||
@@ -907,9 +917,6 @@ onMounted(() => {
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编号" prop="targetId" min-width="170" />
|
||||
<el-table-column label="类型" width="80" align="center">
|
||||
<template #default="{ row }">{{ pendingTargetLabel(row) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="70" align="center">
|
||||
<template #default="{ row }">{{ row.quantity }}</template>
|
||||
</el-table-column>
|
||||
@@ -981,4 +988,6 @@ onMounted(() => {
|
||||
.mb12 { margin-bottom: 12px; }
|
||||
.pager { display: flex; justify-content: flex-end; margin-top: 12px; }
|
||||
.tip { margin-left: 10px; color: #909399; font-size: 12px; }
|
||||
.insp-head { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; font-size: 13px; color: #606266; align-items: center; }
|
||||
.insp-head .ih-item b { color: #303133; margin-right: 4px; font-weight: 600; }
|
||||
</style>
|
||||
|
||||
@@ -496,7 +496,7 @@ onMounted(loadDicts)
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="出库类别" required>
|
||||
<el-select v-model="genForm.outboundCategory" style="width:100%">
|
||||
<el-select v-model="genForm.outboundCategory" style="width:100%" placeholder="请选择出库类别">
|
||||
<el-option v-for="c in CATEGORY_OPTIONS" :key="c.value" :value="c.value" :label="c.label" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
@@ -504,7 +504,7 @@ onMounted(loadDicts)
|
||||
<el-input v-model="genForm.inspectionNo" placeholder="退货/报废需溯源检验单据时填写(选填)" clearable style="width:100%" />
|
||||
</el-form-item>
|
||||
<el-form-item label="归属">
|
||||
<el-select v-model="genForm.ownershipType" style="width:160px;margin-right:8px">
|
||||
<el-select v-model="genForm.ownershipType" style="width:160px;margin-right:8px" placeholder="请选择归属">
|
||||
<el-option v-for="o in OWNERSHIP_OPTIONS" :key="o.value" :value="o.value" :label="o.label" />
|
||||
</el-select>
|
||||
<el-input v-if="genForm.ownershipType !== 'none'" v-model="genForm.ownershipNo"
|
||||
|
||||
@@ -252,7 +252,7 @@ onMounted(() => {
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" required>
|
||||
<el-select v-model="form.isActive" style="width:100%">
|
||||
<el-select v-model="form.isActive" style="width:100%" placeholder="请选择状态">
|
||||
<el-option label="启用" :value="true" />
|
||||
<el-option label="停用" :value="false" />
|
||||
</el-select>
|
||||
|
||||
@@ -5,6 +5,18 @@ import { getToken } from './auth'
|
||||
// 统一请求实例:baseURL /api,响应为 { code, message, data }
|
||||
const request = axios.create({ baseURL: '/api', timeout: 30000 })
|
||||
|
||||
// 业务化报错:把底层网络/连接/服务不可达等技术错误翻译成业务人员能看懂的提示
|
||||
function friendlyMsg(raw) {
|
||||
if (!raw || typeof raw !== 'string') return '操作失败,请稍后重试'
|
||||
if (/dial tcp|connectex|connection could be made|refused|ECONNREFUSED|ETIMEDOUT|127\.0\.0\.1|Post "http|Get "http|WMS 未配置|拉取 WMS|无法获取 WMS|MES 未配置|拉取 MES/i.test(raw)) {
|
||||
return '无法连接服务(服务未启动或网络不可达),相关功能暂不可用;请检查服务状态或联系管理员'
|
||||
}
|
||||
if (/Network Error|Failed to fetch|ERR_NETWORK|ERR_CONNECTION|网络异常|网络连接/i.test(raw)) {
|
||||
return '网络连接异常,请检查网络后重试或联系管理员'
|
||||
}
|
||||
return raw
|
||||
}
|
||||
|
||||
request.interceptors.request.use((config) => {
|
||||
const token = getToken()
|
||||
if (token) config.headers.Authorization = `Bearer ${token}`
|
||||
@@ -20,7 +32,7 @@ request.interceptors.response.use(
|
||||
const body = resp.data
|
||||
if (body && typeof body === 'object' && 'code' in body) {
|
||||
if (body.code !== 0) {
|
||||
const msg = body.message || '操作失败'
|
||||
const msg = friendlyMsg(body.message || '操作失败')
|
||||
ElMessage.error(msg)
|
||||
return Promise.reject(new Error(msg))
|
||||
}
|
||||
@@ -37,7 +49,7 @@ request.interceptors.response.use(
|
||||
window.location.href = '/login'
|
||||
}
|
||||
} else {
|
||||
const msg = error.response?.data?.message || error.message || '网络错误'
|
||||
const msg = friendlyMsg(error.response?.data?.message || error.message || '网络错误')
|
||||
ElMessage.error(msg)
|
||||
}
|
||||
return Promise.reject(error)
|
||||
|
||||
@@ -231,11 +231,19 @@ type importErr struct {
|
||||
}
|
||||
|
||||
// excelInboundHandler Excel 批量导入入库
|
||||
// mode=batch(批次件):列头(首行忽略) 图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 备注
|
||||
// mode=sn(序列号件): 列头(首行忽略) 图号 | SN | 区域 | 生产日期 | 供应商
|
||||
// mode=batch(批次件) 列头(首行忽略):
|
||||
//
|
||||
// 图号 | 批次号(可空自动生成) | 数量 | 生产日期 | 供应商 | 区域 | 架 | 层 | 位 | 备注 | 检测单号 | 产品工号 | 归属类型 | 归属编号
|
||||
//
|
||||
// mode=sn(序列号件) 列头(首行忽略):
|
||||
//
|
||||
// 图号 | SN | 区域 | 生产日期 | 供应商 | 架 | 层 | 位 | 备注 | 检测单号 | 产品工号 | 归属类型 | 归属编号
|
||||
//
|
||||
// 新增列(架/层/位/备注/检测单号/产品工号/归属) 均为【可选、追加在末尾】,老模板文件缺这些列仍可导入(对应字段留空)。
|
||||
// 归属类型填 workorder/project/other(其他值按 other 处理);workorder/project 必须同时填归属编号,other 可不填。
|
||||
//
|
||||
// 强约束:全成功或全失败(一次性全导入 or 全失败,禁止部分成功)。
|
||||
// 流程:阶段1 逐行解析+校验(物料存在/数量>0/SN不重复/区域必填) → 任一错则整体拒绝并列出错误行(一行不写);
|
||||
// 流程:阶段1 逐行解析+校验(物料存在/数量>0/SN不重复/区域必填/归属编号规则) → 任一错则整体拒绝并列出错误行(一行不写);
|
||||
// 阶段2 全部通过 → 开启单事务,整体提交,任一步失败整体回滚。
|
||||
func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -272,15 +280,22 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
|
||||
type planRow struct {
|
||||
row int
|
||||
code string
|
||||
batchNo string
|
||||
sn string
|
||||
qty int
|
||||
prodDate string
|
||||
supplier string
|
||||
zone string
|
||||
remark string
|
||||
row int
|
||||
code string
|
||||
batchNo string
|
||||
sn string
|
||||
qty int
|
||||
prodDate string
|
||||
supplier string
|
||||
zone string
|
||||
remark string
|
||||
shelfNo string
|
||||
layerNo string
|
||||
positionNo string
|
||||
inspectionNo string
|
||||
productWorkNo string
|
||||
ownershipType string
|
||||
ownershipNo string
|
||||
}
|
||||
plans := make([]planRow, 0, len(rows)-1)
|
||||
errs := make([]importErr, 0)
|
||||
@@ -300,18 +315,34 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
pr := planRow{row: i + 1}
|
||||
pr.code = cell(0)
|
||||
if mode == "sn" {
|
||||
// 图号|SN|区域|生产日期|供应商|架|层|位|备注|检测单号|产品工号|归属类型|归属编号
|
||||
pr.sn = cell(1)
|
||||
pr.zone = cell(2) // 序列号件模板: 图号|SN|区域|生产日期|供应商
|
||||
pr.zone = cell(2)
|
||||
pr.prodDate = cell(3)
|
||||
pr.supplier = cell(4)
|
||||
pr.remark = cell(4)
|
||||
pr.shelfNo = cell(5)
|
||||
pr.layerNo = cell(6)
|
||||
pr.positionNo = cell(7)
|
||||
pr.remark = cell(8)
|
||||
pr.inspectionNo = cell(9)
|
||||
pr.productWorkNo = cell(10)
|
||||
pr.ownershipType = cell(11)
|
||||
pr.ownershipNo = cell(12)
|
||||
} else {
|
||||
// 图号|批次号|数量|生产日期|供应商|区域|架|层|位|备注|检测单号|产品工号|归属类型|归属编号
|
||||
pr.batchNo = cell(1)
|
||||
pr.qty = atoi(cell(2), 0)
|
||||
pr.prodDate = cell(3)
|
||||
pr.supplier = cell(4)
|
||||
pr.zone = cell(5) // 批次件模板: 图号|批次号|数量|生产日期|供应商|区域|备注
|
||||
pr.remark = cell(6)
|
||||
pr.zone = cell(5)
|
||||
pr.shelfNo = cell(6)
|
||||
pr.layerNo = cell(7)
|
||||
pr.positionNo = cell(8)
|
||||
pr.remark = cell(9)
|
||||
pr.inspectionNo = cell(10)
|
||||
pr.productWorkNo = cell(11)
|
||||
pr.ownershipType = cell(12)
|
||||
pr.ownershipNo = cell(13)
|
||||
}
|
||||
|
||||
if pr.code == "" {
|
||||
@@ -357,6 +388,14 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
errs = append(errs, importErr{pr.row, pr.code, "区域为空(必填)"})
|
||||
continue
|
||||
}
|
||||
// 归属校验(与手动录入口径一致:workorder/project 必填编号;other/空 不需要)
|
||||
pr.ownershipType = ownershipTypeOrNone(pr.ownershipType)
|
||||
if pr.ownershipType == "workorder" || pr.ownershipType == "project" {
|
||||
if pr.ownershipNo == "" {
|
||||
errs = append(errs, importErr{pr.row, pr.code, "归属类型为" + pr.ownershipType + "时归属编号必填"})
|
||||
continue
|
||||
}
|
||||
}
|
||||
plans = append(plans, pr)
|
||||
}
|
||||
|
||||
@@ -396,6 +435,12 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetNillableProductionDate(strPtr(pr.prodDate)).
|
||||
SetNillableSupplier(strPtr(pr.supplier)).
|
||||
SetNillableZoneCode(strPtr(pr.zone)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableOwnershipType(strPtr(pr.ownershipType)).
|
||||
SetNillableOwnershipNo(strPtr(pr.ownershipNo)).
|
||||
SetStatus("在库").
|
||||
SetInboundNo(inboundNo).
|
||||
Save(ctx0()); e != nil {
|
||||
@@ -420,6 +465,10 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
if _, e = tx.Inventory.UpdateOneID(existing.ID).
|
||||
AddQuantity(pr.qty).
|
||||
SetNillableSupplier(strPtr(pr.supplier)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
Save(ctx0()); e != nil {
|
||||
fail(w, http.StatusInternalServerError, "追加批次失败: "+e.Error())
|
||||
return
|
||||
@@ -436,6 +485,12 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetNillableSupplier(strPtr(pr.supplier)).
|
||||
SetQualityStatus("未检").
|
||||
SetNillableZoneCode(strPtr(pr.zone)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableOwnershipType(strPtr(pr.ownershipType)).
|
||||
SetNillableOwnershipNo(strPtr(pr.ownershipNo)).
|
||||
SetStatus("在库").
|
||||
SetInboundNo(inboundNo).
|
||||
Save(ctx0()); e != nil {
|
||||
@@ -458,8 +513,16 @@ func excelInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
SetManageMode(m.ManageMode).
|
||||
SetSnMode(m.SnMode).
|
||||
SetNillableZoneCode(strPtr(pr.zone)).
|
||||
SetNillableShelfNo(strPtr(pr.shelfNo)).
|
||||
SetNillableLayerNo(strPtr(pr.layerNo)).
|
||||
SetNillablePositionNo(strPtr(pr.positionNo)).
|
||||
SetQuantity(ternary(mode == "sn", 1, pr.qty)).
|
||||
SetNillableRemark(strPtr(pr.remark)).
|
||||
SetInspectionNo(pr.inspectionNo).
|
||||
SetOwnershipType(ownershipTypeOrNone(pr.ownershipType)).
|
||||
SetNillableOwnershipNo(strPtr(pr.ownershipNo)).
|
||||
SetNillableProductWorkNo(strPtr(pr.productWorkNo)).
|
||||
SetNillableQualityStatus(strPtr("未检")).
|
||||
SetOperator("excel-import").
|
||||
Save(ctx0()); e != nil {
|
||||
fail(w, http.StatusInternalServerError, "创建入库单失败: "+e.Error())
|
||||
|
||||
@@ -456,6 +456,46 @@ func materialTypesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// materialManageModesHandler 内部接口:批量查询物料「类型」(manage_mode: 1结构件/2电气件/3其他)。
|
||||
// 与 materialTypesHandler(品类 item_type)相互独立:品类=成品/组件类,类型=结构件/电气件/其他。
|
||||
// body: {"codes":["A","B"]} → data: {"manageModes": {"A":1}}(不存在的编码不返回)。
|
||||
func materialManageModesHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req struct {
|
||||
Codes []string `json:"codes"`
|
||||
}
|
||||
if err := parseJSON(r, &req); err != nil {
|
||||
fail(w, http.StatusBadRequest, "参数错误")
|
||||
return
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
codes := []string{}
|
||||
for _, c := range req.Codes {
|
||||
c = strings.TrimSpace(c)
|
||||
if c == "" || seen[c] {
|
||||
continue
|
||||
}
|
||||
seen[c] = true
|
||||
codes = append(codes, c)
|
||||
}
|
||||
mm := map[string]int{}
|
||||
if len(codes) > 0 {
|
||||
list, err := ctx.EntClient.Material.Query().
|
||||
Where(material.CodeIn(codes...)).
|
||||
Select(material.FieldCode, material.FieldManageMode).
|
||||
All(ctx0())
|
||||
if err != nil {
|
||||
fail(w, http.StatusInternalServerError, "查询物料类型失败: "+err.Error())
|
||||
return
|
||||
}
|
||||
for _, m := range list {
|
||||
mm[m.Code] = m.ManageMode
|
||||
}
|
||||
}
|
||||
ok(w, map[string]any{"manageModes": mm})
|
||||
}
|
||||
}
|
||||
|
||||
// materialExistsHandler 内部接口:批量校验物料编码是否存在于物料档案。
|
||||
// body: {"codes":["A","B"]} → data: {"missing":["B"]}(不存在于档案的编码列表)。
|
||||
// 供 MES 备料单生成前防呆使用(wrapInternal + X-API-TOKEN 保护)。
|
||||
|
||||
@@ -262,6 +262,7 @@ func RegisterHandlers(server *rest.Server, ctx *svc.ServiceContext) {
|
||||
{Method: http.MethodPost, Path: "/api/internal/materials/upsert", Handler: wrapInternal(ctx)(upsertMaterialInternalHandler(ctx))},
|
||||
{Method: http.MethodPost, Path: "/api/internal/material/exists", Handler: wrapInternal(ctx)(materialExistsHandler(ctx))},
|
||||
{Method: http.MethodPost, Path: "/api/internal/material/types", Handler: wrapInternal(ctx)(materialTypesHandler(ctx))},
|
||||
{Method: http.MethodPost, Path: "/api/internal/material/manage-modes", Handler: wrapInternal(ctx)(materialManageModesHandler(ctx))},
|
||||
// 物料分页查询(需求一 M7:MES 冷启动全量拉取用;MES 推送走上方 /upsert)
|
||||
{Method: http.MethodGet, Path: "/api/internal/materials", Handler: wrapInternal(ctx)(queryMaterialsHandler(ctx))},
|
||||
{Method: http.MethodGet, Path: "/api/internal/material/list-all", Handler: wrapInternal(ctx)(listMaterialsHandler(ctx))},
|
||||
|
||||
@@ -1406,6 +1406,10 @@ func listStockBatchesInternalHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
||||
inventory.MaterialCodeEQ(materialCode),
|
||||
inventory.QuantityGT(0),
|
||||
inventory.QualityStatusIn(QStatusPass, QStatusConcession),
|
||||
// 仅「在库」可出库:SN 行出库走状态机(status 置「出库」)而 quantity 仍为 1,
|
||||
// 缺此过滤会把已出库 SN 误返回,MES 自动备料逐颗尝试时第一颗即失败(AITEST 闭环实测缺陷)。
|
||||
// 盘点冻结(锁定)行也不返回:与 stock/deduct 的冻结守卫口径一致,避免 MES 撞拦截。
|
||||
inventory.StatusEQ("在库"),
|
||||
)
|
||||
if zc := strings.TrimSpace(r.URL.Query().Get("zoneCode")); zc != "" {
|
||||
q = q.Where(inventory.ZoneCodeEQ(zc))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<title>WMS库房管理</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'/><path d='M16 7l9 4.5v9L16 25l-9-4.5v-9L16 7z' fill='none' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/><path d='M7 11.5L16 16l9-4.5M16 16v9' fill='none' stroke='%23fff' stroke-width='2' stroke-linejoin='round'/></svg>">
|
||||
<script type="module" crossorigin src="/assets/index-v_K88Qc0.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-gfboWrpP.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-D1r21H_d.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user