From d92ca803d5f2c6ab7aa6752e15cf46bec0620c01 Mon Sep 17 00:00:00 2001
From: SunYF <123@hard_man.com>
Date: Mon, 16 Nov 2026 16:42:44 +0800
Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9D=A5=E6=96=99=E6=A3=80=E5=A4=84?=
=?UTF-8?q?=E7=BD=AE=E9=A1=B9=E5=AE=9E=E4=BD=93=E4=B8=8E=E5=A4=8D=E6=A3=80?=
=?UTF-8?q?=E3=80=81=E6=97=A5=E6=8E=92=E4=BA=A7=E8=BE=BE=E6=88=90=E5=AF=B9?=
=?UTF-8?q?=E6=AF=94=E3=80=81PLC/WMS=20=E4=BC=A0=E8=BE=93=E6=97=A5?=
=?UTF-8?q?=E5=BF=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- WMS 新增「检验处置项」实体(schema + ent 生成码),配套检验记录实体调整与复检接口,完善来料检/不良退货/入库检验前端
- MES 日排产:新增达成率统计与计划对比逻辑,调整日排产前端与流程卡/工序流
- 日志与传输:MES 新增 PLC 日志与 WMS 客户端传输日志,WMS 新增 MES 客户端传输日志
- MES 其他:扫码、工单/工件、AGV 客户端与告警、产品导入等逻辑完善及前端调整
- 工位终端:上线面板/作业面板、工件 handler 与 MES 客户端调整
- 配置与文档:更新 mes-api.yaml、三端构建产物与问题记录文档
---
bj_power_mes/bj_power_mes.go | 25 +
bj_power_mes/etc/bj_power_mes-api.yaml | 4 +-
bj_power_mes/frontend/src/help.js | 18 +-
bj_power_mes/frontend/src/pages/DailyPlan.vue | 101 +-
.../frontend/src/pages/PlcMonitor.vue | 4 +-
.../frontend/src/pages/ProcessCard.vue | 6 +
.../frontend/src/pages/ProductType.vue | 92 +-
bj_power_mes/frontend/vite.config.js | 21 +-
bj_power_mes/internal/agv/client.go | 16 +-
.../handler/production/dailyplan_compare.go | 44 +
.../internal/handler/production/production.go | 7 +-
.../internal/handler/production/workorder.go | 2 +-
.../internal/handler/routes_production.go | 3 +
bj_power_mes/internal/logic/agv.go | 16 +
bj_power_mes/internal/logic/alert.go | 26 +
bj_power_mes/internal/logic/dailyplan.go | 13 +-
.../internal/logic/dailyplan_attainment.go | 95 ++
bj_power_mes/internal/logic/flow_chain.go | 44 +-
bj_power_mes/internal/logic/processflow.go | 33 +-
bj_power_mes/internal/logic/product_import.go | 76 +-
bj_power_mes/internal/logic/scan.go | 4 +-
bj_power_mes/internal/logic/workorder.go | 63 +-
bj_power_mes/internal/logic/workpiece.go | 18 +-
bj_power_mes/internal/plc/logging.go | 114 ++
bj_power_mes/internal/plc/plc.go | 19 +-
bj_power_mes/internal/wmsclient/client.go | 2 +-
.../internal/wmsclient/transport_logging.go | 78 ++
bj_power_mes/public/index.html | 2 +-
bj_power_wms/bj_power_wms.go | 27 +
bj_power_wms/ent/client.go | 291 ++++--
bj_power_wms/ent/ent.go | 56 +-
bj_power_wms/ent/hook/hook.go | 12 +
bj_power_wms/ent/inspectiondisposalitem.go | 158 +++
.../inspectiondisposalitem.go | 96 ++
.../ent/inspectiondisposalitem/where.go | 424 ++++++++
.../ent/inspectiondisposalitem_create.go | 839 +++++++++++++++
.../ent/inspectiondisposalitem_delete.go | 88 ++
.../ent/inspectiondisposalitem_query.go | 527 ++++++++++
.../ent/inspectiondisposalitem_update.go | 483 +++++++++
bj_power_wms/ent/inspectionrecord.go | 37 +-
.../ent/inspectionrecord/inspectionrecord.go | 26 -
bj_power_wms/ent/inspectionrecord/where.go | 230 ----
bj_power_wms/ent/inspectionrecord_create.go | 221 ----
bj_power_wms/ent/inspectionrecord_update.go | 138 ---
bj_power_wms/ent/migrate/schema.go | 33 +-
bj_power_wms/ent/mutation.go | 978 ++++++++++++++----
bj_power_wms/ent/predicate/predicate.go | 3 +
bj_power_wms/ent/runtime.go | 23 +-
bj_power_wms/ent/tx.go | 3 +
.../frontend/src/components/InboundEntry.vue | 2 +-
bj_power_wms/frontend/src/help.js | 6 +-
.../frontend/src/pages/DefectReturn.vue | 2 +-
.../frontend/src/pages/Inspection.vue | 155 +--
bj_power_wms/frontend/src/pages/Inventory.vue | 40 +-
.../frontend/src/utils/nextStepRules.js | 4 +-
bj_power_wms/frontend/vite.config.js | 24 +-
bj_power_wms/internal/db/db.go | 12 +-
bj_power_wms/internal/handler/inbound.go | 6 +-
bj_power_wms/internal/handler/inspection.go | 390 ++++---
bj_power_wms/internal/handler/reinspect.go | 81 +-
bj_power_wms/internal/mesclient/client.go | 4 +-
.../internal/mesclient/transport_logging.go | 65 ++
.../schema/inspection_disposal_item.go | 39 +
bj_power_wms/schema/inspection_record.go | 12 +-
bj_power_wms/web/static/index.html | 2 +-
.../frontend/src/views/panels/OnlinePanel.vue | 44 +-
.../frontend/src/views/panels/WorkPanel.vue | 38 +-
bj_power_workstation/frontend/vite.config.js | 25 +-
.../internal/handler/workpiece.go | 5 +-
bj_power_workstation/internal/mes/client.go | 16 +
bj_power_workstation/web/static/index.html | 2 +-
问题临时.md | 48 +-
72 files changed, 5135 insertions(+), 1526 deletions(-)
create mode 100644 bj_power_mes/internal/logic/dailyplan_attainment.go
create mode 100644 bj_power_mes/internal/plc/logging.go
create mode 100644 bj_power_mes/internal/wmsclient/transport_logging.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem/inspectiondisposalitem.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem/where.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem_create.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem_delete.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem_query.go
create mode 100644 bj_power_wms/ent/inspectiondisposalitem_update.go
create mode 100644 bj_power_wms/internal/mesclient/transport_logging.go
create mode 100644 bj_power_wms/schema/inspection_disposal_item.go
diff --git a/bj_power_mes/bj_power_mes.go b/bj_power_mes/bj_power_mes.go
index e594e4b..7b2fccf 100644
--- a/bj_power_mes/bj_power_mes.go
+++ b/bj_power_mes/bj_power_mes.go
@@ -33,6 +33,7 @@ import (
"bj_power_mes/internal/scanbridge"
"bj_power_mes/internal/svc"
"bj_power_mes/internal/tray"
+ "bj_power_mes/internal/wmsclient"
"golang.org/x/sys/windows"
winsvc "golang.org/x/sys/windows/svc"
@@ -713,6 +714,30 @@ func runServe(c config.Config, asService bool) {
}
})
+ // PLC 通讯失败预警(2026-11-16):连续失败首次沿触发(持续断连不重复触发),
+ // 预警侧 10 分钟窗口去重兜底防风暴;恢复后下次再断会重新触发。
+ ctx.PLC.SetOnFail(func(failCtx context.Context, failErr error) {
+ fc, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ _, aerr := logic.New(ctx).CreateAlertDedup(fc, "plc_offline", "严重", "PLC",
+ "PLC 通讯失败:产线控制信号读写异常,点位状态可能与台账不一致,请检查 PLC 网络与电源。详情:"+failErr.Error(), 10)
+ if aerr != nil {
+ gologx.Errorf("PLC 通讯失败落预警异常: %v", aerr)
+ }
+ })
+
+ // WMS 通讯失败预警(2026-11-16):MES→WMS 传输层失败(连不上/超时)触发,
+ // 10 分钟窗口去重;HTTP 业务错误(服务在但拒绝)不算通讯异常、不触发。
+ wmsclient.FailHook = func(hookCtx context.Context, method, url string, hookErr error) {
+ fc, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ _, aerr := logic.New(ctx).CreateAlertDedup(fc, "wms_unreachable", "警告", "WMS",
+ fmt.Sprintf("WMS 通讯失败:%s %s(%v),在制品/成品库存联动将失败,请检查 WMS 服务。", method, url, hookErr), 10)
+ if aerr != nil {
+ gologx.Errorf("WMS 通讯失败落预警异常: %v", aerr)
+ }
+ }
+
// 断电恢复启动对账(#8 T8,2026-11-03 补全):服务(含产线断电重启后)冷启动时,
// 若 PLC 首连即成功则没有"失败→成功沿",T6 不会触发——这里延迟 15 秒补一次全量对账,
// 比对 PLC 托盘位实读与 MES 在制工件记录,命中落预警中心(trigger=boot),不阻断启动。
diff --git a/bj_power_mes/etc/bj_power_mes-api.yaml b/bj_power_mes/etc/bj_power_mes-api.yaml
index c7593d0..52ffb25 100644
--- a/bj_power_mes/etc/bj_power_mes-api.yaml
+++ b/bj_power_mes/etc/bj_power_mes-api.yaml
@@ -54,8 +54,8 @@ Plc:
# 海康 AGV(RCS-Lite V1.5) 对接(2026-10-17 由 RCS-2000 改为 RCS-Lite 1.5):无签名鉴权
# 未接真实 RCS-Lite 前保持 mock(EnableMock: true);现场对接时填 EnableMock: false + BaseURL(默认端口 8182,含 /rCMS/services/rest/hikRpcService)
Agv:
- EnableMock: true
- BaseURL: ""
+ EnableMock: false
+ BaseURL: "http://192.168.22.13:8182/rCMS/services/rest/hikRpcService"
CarrierCode: ""
MapCode: ""
Priority: "1"
diff --git a/bj_power_mes/frontend/src/help.js b/bj_power_mes/frontend/src/help.js
index ba7b93d..29739e3 100644
--- a/bj_power_mes/frontend/src/help.js
+++ b/bj_power_mes/frontend/src/help.js
@@ -14,7 +14,7 @@ export const helpProductType = P('成品档案', '这里是成品型号的源头
{ k: 'confuse', t: '三个编号别混', text: '产品工号是工单号(一批一个);产品编码是成品型号(多个工单可以是同一个型号);产品序号(SN) 是每台工件自己的号。MES 页面叫「成品档案」,不显示「图号」——成品没有图号,也没有物料编码;这两个字段属于原材料,是 WMS 物料档案的事。改产品编码会让已建工单找不到原来的型号,追溯也跟着断。' },
{ k: 'states', t: '停用不是删除', text: '停用后新建工单的下拉里选不到它,但已经建好的工单、库存、追溯记录都还在,也还能查。这是唯一的下架方式,系统不物理删型号。' },
{ k: 'confuse', t: '「序列号=是」决定什么', text: '它决定这台工件是按批次数量记账,还是一台一个号逐件扫。选「是」时,上线建档必须扫已在 WMS 入库登记过的来料 SN,不能让系统发号。产品分类只是个默认值,跟这件事没有绑定关系。新建成品时不需要选「类型」,表虽然和原材料共用,页面上不做这个选择。' },
- { k: 'complex', t: '同步失败时两种表现不一样', text: '单条建档或编辑即使 WMS 暂时不通,本系统也会先保存下来、标上待同步,之后点「重推」补上;Excel 批量导入则是整批一起成功或一起失败,不会出现半张表进去了的情况。导入模板和模板说明与 WMS 完全同款,改模板必须两端一起改。' },
+ { k: 'complex', t: '同步失败时两种表现不一样', text: '单条建档或编辑即使 WMS 暂时不通,本系统也会先保存下来、标上待同步,之后点「重推」补上;Excel 批量导入则是整批一起成功或一起失败,不会出现半张表进去了的情况。导入模板与 WMS 大体同款(MES 无「类型」列、列名一致,均按表头名识别),改模板必须两端一起改。' },
{ k: 'links', t: '上游下游', text: '上游是 WMS 物料档案(按编码互推);下游是产品工艺、工单管理、成品试验和工件追溯。' }
], [
{ name: '产品工艺', path: '/process-flow', hint: '给型号定工序' },
@@ -49,16 +49,20 @@ export const helpWorkOrder = P('工单管理', '一张工单从建单到收尾
export const helpDailyPlan = P('日排产', '排产是算料和叫料的开关,不是一张待办清单。', [
{ k: 'role', t: '这页解决什么', text: '把工单总台数摊到每一天,系统据此算「今天该领多少料」并生成叫料需求。没排产的工单不参与算料。' },
- { k: 'states', t: '排产状态与「已启用」', items: [
- 'PENDING 未确认 → CONFIRMED 已确认 → PROCESSING 执行中 → DONE 已完成;CANCELLED 是已取消。',
- '「已启用」是算料开关:只有已确认/执行中的排产会参与备料清单和叫料需求计算。未启用不等于已取消,只是暂时不算料。',
- '列表默认筛「未完成(排除已完成/已取消)」,是为了只看还要干活的日子,不是把历史数据删了。'
+ { k: 'states', t: '执行状态各值的意思', items: [
+ '全部:不过滤,所有排产都显示。',
+ '未完成:不是一种状态,是组合筛选——「已完成」和「已取消」以外的都算(未启用/已启用/执行中都会显示)。列表默认选它,是为了只看还要干活的日子。',
+ '未启用(PENDING):新建或批量排产后的初始状态,只是计划,不参与算料。',
+ '已启用(CONFIRMED):人工点「启用」且工单已在进行中才能到这一态;只有已启用的排产参与备料清单和叫料需求计算。',
+ '执行中(PROCESSING):工单开工或当天首台完工后自动进入;工位终端能看到这一天的活,但目前不参与叫料需求计算。',
+ '已完成(DONE):这一天计划量做满,或所属工单完工且足额。',
+ '已取消(CANCELLED):工单取消,或工单已完工但这天没排满。'
] },
{ k: 'confuse', t: '「显示历史」和状态筛选各管各的', text: '默认只看今天起 30 天。想看过去,勾「显示历史」并把日期范围清空;状态选「全部」才不会被「未完成」过滤掉。两个筛选互不影响,只改一个会以为没数据。' },
{ k: 'confuse', t: '送达接驳台为什么显示中文', text: '列里显示的是「左 / 右」这样的中文接驳台名称,不是 DOCK 编码。工位 2、4、6、8、10 的左右按操作员「背向主线」的视角统一,和图纸上顺向看是反的,这是现场约定。' },
{ k: 'irreversible', t: '停用 vs 删除', text: '停用只是让这一天不参与算料;删除会把这一天从计划里拿掉,已生成的备料与叫料需求会跟着变。调整前先看这一天的备料单是否已经发出。' },
{ k: 'confuse', t: '数量为什么加不上去', text: '同一张工单各天的计划数量加起来不能超过工单总台数,系统会按累计量卡住。要加量得先改工单数量或补料审批,不是在排产里硬填。排产量可以大于当前库存,系统只预警不拦截。' },
- { k: 'complex', t: '历史透视与对比', text: '历史排产也能透视、能导出,导出的规划可以和历史规划做对比;「逐日消耗模拟」和「各工单排产支撑」都带分页,逐日消耗按实时库存变化算,别拿一次导出当永久快照。' }
+ { k: 'complex', t: '透视与对比目前只覆盖未完成', text: '「按日期透视」和「按工单折叠」强制只显示未完成的工单,已完工/已取消的历史排产进不了透视;「对比/导出差异」算的是计划数与已完成数的差额账,不是两份规划快照的对比。想看历史完工情况,把日期范围调到过去、状态选「全部」看列表。历史排产的整体透视、规划导出与规划对比尚未实现,属待实现需求。「逐日消耗模拟」和「各工单排产支撑」都带分页,逐日消耗按实时库存变化算,别拿一次导出当永久快照。' }
], [
{ name: '工单管理', path: '/work-order' },
{ name: '叫料单', path: '/material-request', hint: '排产算出来的需求' },
@@ -322,7 +326,7 @@ export const helpPlc = P('工位下发', '把某张工单要经过的工位组
export const helpPlcMonitor = P('PLC管理', '本页手动写点位,按钮按下去就真下发给 PLC 了。', [
{ k: 'role', t: '这页解决什么', text: '设备联调、异常处置时给维护人员一个直接读写 PLC 点位、看在途指令的入口。日常生产不需要在这里操作。' },
{ k: 'states', t: '在途与模拟数据', text: '在途=MW 寄存器非 0,同一工位有在途指令时新的手动下发会被互斥挡掉。页面标了「模拟数据」时,看到的是 mock 点位状态,别拿它判断现场实物。本页不自动刷新,要看最新状态得手动刷新。' },
- { k: 'irreversible', t: '强制清零', text: '二次确认 + 勾选现场安全后才执行,只清 PLC 的在途标记,不回滚 MES 台账、不撤销已经报过的工。清零之前务必在实物上确认工件位置。' },
+ { k: 'irreversible', t: '强制清零到底动了什么', text: '它改的是 PLC 内存里的一条「搬运任务便签」:把约定好的在途指令寄存器(M 区一个字)写成 0,不是删 PLC 程序、不动 DB 块和传感器位,PLC 不会因此停机或损坏;MES 侧只留一条操作日志,不回滚台账、不撤销已报的工。真正的危险是清早了——托盘还在搬运中就把它清零,上位机会误判这趟搬运已完成,可能接着下发新指令,两个动作撞在一起。所以必须现场确认工件真卡住、PLC 已经不动作了再点。矫正对象是 PLC 本身,不是 MES 数据库;越界地址一律拒绝,只允许清约定范围内的在途指令字。' },
{ k: 'complex', t: '被拦下来时先分清是谁拦的', text: '「已有在途指令」和「多工单缓存策略=严格隔离」是两道不同的检查。前一种无论哪种策略都会先拦,看起来像策略问题其实不是。' },
{ k: 'complex', t: '多工单缓存策略在这页会看到什么', text: '这个策略除了管报工后的自动流转(详见「基础设置」帮助),也管本页手动下发:目标必须是 C 类主线位置、而且是可缓存位(C2/C3/C5/C6/C8/C9/C11/C12/C14),MES 台账显示被别的工单占着时,严格隔离会拒绝这次下发并报出占用的 SN 和工单号。切回物理优先就能下发,改完立刻生效。' }
], [
diff --git a/bj_power_mes/frontend/src/pages/DailyPlan.vue b/bj_power_mes/frontend/src/pages/DailyPlan.vue
index 8a8d0bc..df3fda6 100644
--- a/bj_power_mes/frontend/src/pages/DailyPlan.vue
+++ b/bj_power_mes/frontend/src/pages/DailyPlan.vue
@@ -22,7 +22,7 @@
-
+
@@ -58,6 +58,7 @@
查询
重置
对比
+ 计划vs实际
新建排产
@@ -303,6 +304,31 @@
计划合计:{{ compare.summary.planTotal ?? 0 }} 完成合计:{{ compare.summary.doneTotal ?? 0 }} 差异合计:{{ compare.summary.diffTotal ?? 0 }} 工单数:{{ compare.summary.orderCount ?? 0 }}
+
+
+
+
+ 查询
+ 导出
+ 实际完成=完工流水(与生产流程卡同源)按天聚合;负差异=欠产
+
+
+
+
+
+
+
+
+ {{ row.diff }}
+
+
+
+
+ 看流程卡
+
+
+
+
@@ -316,6 +342,7 @@
diff --git a/bj_power_mes/frontend/src/pages/ProductType.vue b/bj_power_mes/frontend/src/pages/ProductType.vue
index a871dc5..2ea6e3b 100644
--- a/bj_power_mes/frontend/src/pages/ProductType.vue
+++ b/bj_power_mes/frontend/src/pages/ProductType.vue
@@ -1,7 +1,6 @@
-
@@ -11,6 +10,7 @@
+
@@ -18,7 +18,9 @@
重置
新增成品档案
+ 说明走按钮旁 hover 悬浮气泡(WMS BaseData.vue 同款:字段说明 + 常见错误 + 下载模板)。
+ 2026-11-16 拍板:模板删除「图号」「物料编码」两列(编码自动生成/统一为空),
+ 本端导入仅限成品,原材料在 WMS 物料档案维护。 -->
导入
导出
@@ -26,28 +28,24 @@
-
一、字段说明(成品档案模板 9 列;Excel 首行表头按名称识别,请勿改动表头文字)
+
一、字段说明(成品档案模板 7 列;Excel 首行表头按名称识别,请勿改动表头文字)
| 列 | 字段 | 必填 | 格式 | 说明 |
- | 1 | 图号 | 是 | 字符串,唯一 | 物料唯一标识(两库同步业务键);成品可留空自动生成 PROD-YYYYMMDD-流水,原材料必填 |
- | 2 | 物料编码 | 否 | 字符串 | 普通档案字段(如 WL-0001),不参与业务与必填校验 |
- | 3 | 名称 | 是 | 字符串 | 物料名称 |
- | 4 | 规格 | 是 | 字符串 | 规格型号 |
- | 5 | 单位 | 是 | 字符串 | 如「个」「件」「套」 |
-
- | 6 | 类别 | 否 | 成品/原材料 | 默认成品(MES 口径;WMS 侧叫「物料类别」,留空默认原材料) |
- | 7 | 序列号 | 否 | 是/否 | 成品强制是,原材料可选(WMS 导入忽略本列,按类型自动派生) |
- | 8 | 启用 | 否 | 是/否 | 默认是(WMS 导入忽略本列,默认启用) |
- | 9 | 说明 | 否 | 字符串 | 备注 |
+ | 1 | 名称 | 是 | 字符串 | 物料名称 |
+ | 2 | 规格 | 是 | 字符串 | 规格型号 |
+ | 3 | 单位 | 是 | 字符串 | 如「个」「件」「套」 |
+ | 4 | 类别 | 否 | 成品 | 只能填「成品」;原材料请在 WMS 物料档案维护(不在本端导入) |
+ | 5 | 序列号 | 否 | — | 成品强制「是」,无需填写 |
+ | 6 | 启用 | 否 | 是/否 | 默认是 |
+ | 7 | 说明 | 否 | 字符串 | 备注 |
-
下载模板含 2 行示例数据(导入前请删除)与「填写说明」页逐列说明。
+
成品编码(图号)由系统自动生成(PROD-年月日-流水,递增且唯一),物料编码统一为空,均无需填写。下载模板含 1 行示例数据(导入前请删除)与「填写说明」页逐列说明。
二、常见错误
- · 图号重复:系统中已存在相同图号,该行被拒绝
+ · 类别填了「原材料」:MES 成品导入仅限成品,请在 WMS 物料档案维护原材料
· 物料类型不出现在模板中:系统一律按成品逻辑默认(类型=其他、序列号=是)
- · 类别不在枚举内:只能填「成品」或「原材料」
· 名称/规格/单位为空:必填列不可为空;任一行出错则整批回退,一行不写
· WMS 不可达:本端导入先逐行写 WMS,WMS 失败整批取消
@@ -60,8 +58,7 @@
-
-
+
{{ row.spec || '-' }}
@@ -103,32 +100,13 @@
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
- 是
- 否
-
- 是=逐件录序列号,否=按数量(不录序列号)
-
@@ -166,16 +144,13 @@ const list = ref([])
const total = ref(0)
const page = ref(1)
const pageSize = ref(20)
-const filters = reactive({ code: '', name: '', spec: '', isActive: '', manageMode: '', snMode: '', startDate: '', endDate: '' })
-// 类型(manageMode)与是否逐件SN管理(snMode)解耦(2026-09-30):
-// snMode 必选(0=未选择不可保存);选类型自动带默认(电气件→序列号=是,结构件/其他→序列号=否),可手改
-const dialog = reactive({ show: false, id: 0, name: '', code: '', materialCode: '', spec: '', unit: '', manageMode: 3, snMode: 1, description: '', isActive: true })
+const filters = reactive({ name: '', spec: '', isActive: '', startDate: '', endDate: '' })
+// 2026-11-16 用户定案:界面不再出现图号/物料编码/类型/序列号,全部由后端注入或自动生成
+//(类型=3 其他、序列号=是、编码留空由 genProductTypeCode 生成 PROD-YYYYMMDD-流水、物料编码强制空串)。
+// dialog.code 仅保留用于附件挂靠(biz-id=编码)。
+const dialog = reactive({ show: false, id: 0, name: '', code: '', spec: '', unit: '', description: '', isActive: true })
const attachDrawer = reactive({ visible: false, code: '', name: '' })
-function onTypeChange(v) {
- dialog.snMode = v === 2 ? 1 : 2
-}
-
function defaultRange() {
const d = new Date()
const p = (n) => String(n).padStart(2, '0')
@@ -186,18 +161,15 @@ function defaultRange() {
}
Object.assign(filters, defaultRange())
-// 2026-09-08 禁止关键字混搜:编码/名称各筛选框独立传参,后端各自模糊匹配
+// 禁止关键字混搜:名称/规格各筛选框独立传参,后端各自模糊匹配
function trim(s) { return (s || '').trim() }
async function load() {
const params = {
page: page.value,
pageSize: pageSize.value,
- code: trim(filters.code),
name: trim(filters.name),
spec: trim(filters.spec),
- manageMode: filters.manageMode,
- snMode: filters.snMode,
isActive: filters.isActive,
startDate: filters.startDate,
endDate: filters.endDate
@@ -224,34 +196,32 @@ async function retrySync(row) {
}
function resetFilters() {
- Object.assign(filters, { code: '', name: '', spec: '', isActive: '', manageMode: '', snMode: '' }, defaultRange())
+ Object.assign(filters, { name: '', spec: '', isActive: '' }, defaultRange())
page.value = 1
load()
}
async function openAdd() {
- Object.assign(dialog, { show: true, id: 0, name: '', code: '', materialCode: '', spec: '', unit: '', manageMode: 3, snMode: 1, description: '', isActive: true })
+ Object.assign(dialog, { show: true, id: 0, name: '', code: '', spec: '', unit: '', description: '', isActive: true })
}
function openEdit(row) {
Object.assign(dialog, {
- show: true, id: row.id, name: row.name, code: row.code, materialCode: row.materialCode || '', spec: row.spec || '', unit: row.unit || '',
- manageMode: row.manageMode ?? 0, snMode: row.snMode ?? 0, description: row.description || '', isActive: row.isActive
+ show: true, id: row.id, name: row.name, code: row.code, spec: row.spec || '', unit: row.unit || '',
+ description: row.description || '', isActive: row.isActive
})
}
async function save() {
- // 必填口径:名称/规格/单位/图号(图号仅新建必填、编辑不可改;MES 图号不允许为空,与 WMS 成品可空自动生成不同)+ 类型 + 序列号(序列号=是/否)
+ // 必填口径(2026-11-16 用户定案):仅名称/规格/单位必填;编码由后端留空自动生成(logic/product.go:117-123),
+ // 类型/序列号由后端按成品注入默认值(logic/product.go:108-113);物料编码强制空字符串(不参与两库互推,product_import.go:307)。
if (!trim(dialog.name)) return ElMessage.warning('名称为必填项')
if (!trim(dialog.spec)) return ElMessage.warning('规格型号为必填项')
if (!trim(dialog.unit)) return ElMessage.warning('单位为必填项')
- if (!dialog.id && !trim(dialog.code)) return ElMessage.warning('图号为必填项(创建后不可改)')
- if (![1, 2, 3].includes(dialog.manageMode)) return ElMessage.warning('请选择类型')
- if (dialog.snMode !== 1 && dialog.snMode !== 2) return ElMessage.warning('请选择序列号(是=逐件录序列号 / 否=按数量(不录序列号))')
const body = {
name: trim(dialog.name), spec: trim(dialog.spec), unit: trim(dialog.unit), description: dialog.description,
- materialCode: dialog.materialCode, manageMode: dialog.manageMode, snMode: dialog.snMode, isActive: dialog.isActive
+ materialCode: '', manageMode: 3, snMode: 1, isActive: dialog.isActive
}
if (dialog.id) await request.put('/product-types', { id: dialog.id, ...body })
- else await request.post('/product-types', { code: trim(dialog.code), ...body })
+ else await request.post('/product-types', body)
ElMessage.success('保存成功')
dialog.show = false
load()
@@ -346,7 +316,7 @@ async function exportXlsx() {
filters.endDate = r.end
}
const params = {
- code: trim(filters.code), name: trim(filters.name),
+ name: trim(filters.name),
spec: trim(filters.spec),
isActive: filters.isActive,
startDate: filters.startDate, endDate: filters.endDate
diff --git a/bj_power_mes/frontend/vite.config.js b/bj_power_mes/frontend/vite.config.js
index e654356..9f80da1 100644
--- a/bj_power_mes/frontend/vite.config.js
+++ b/bj_power_mes/frontend/vite.config.js
@@ -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://localhost:${backendPort('../etc/bj_power_mes-api.yaml', 8888)}`
// 构建产物直接写入 Go 嵌入静态目录(main.go go:embed public)
export default defineConfig({
@@ -17,9 +34,9 @@ export default defineConfig({
host: true,
proxy: {
'/api': {
- target: 'http://localhost:8888',
+ target: apiTarget,
changeOrigin: true
}
}
}
-})
\ No newline at end of file
+})
diff --git a/bj_power_mes/internal/agv/client.go b/bj_power_mes/internal/agv/client.go
index 3178a36..b946786 100644
--- a/bj_power_mes/internal/agv/client.go
+++ b/bj_power_mes/internal/agv/client.go
@@ -16,6 +16,7 @@ import (
"time"
"github.com/google/uuid"
+ "github.com/zeromicro/go-zero/core/logx"
"bj_power_mes/internal/config"
)
@@ -106,21 +107,29 @@ func (c *realClient) call(ctx context.Context, path string, payload map[string]a
if err != nil {
return err
}
- req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.url(path), bytes.NewReader(body))
+ reqURL := c.url(path)
+ // 2026-11-16 联调:AGV 全量 HTTP 交互落日志(请求 URL/报文 + 响应状态/响应体),grep "[AGV]" 可见。
+ logx.WithContext(ctx).Infof("[AGV] --> POST %s payload=%s", reqURL, string(body))
+
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, reqURL, bytes.NewReader(body))
if err != nil {
+ logx.WithContext(ctx).Errorf("[AGV] <-- build request error url=%s err=%v", reqURL, err)
return err
}
req.Header.Set("Content-Type", "application/json;charset=UTF-8")
resp, err := c.hc.Do(req)
if err != nil {
+ logx.WithContext(ctx).Errorf("[AGV] <-- transport error url=%s err=%v", reqURL, err)
return err
}
defer resp.Body.Close()
raw, err := io.ReadAll(resp.Body)
if err != nil {
+ logx.WithContext(ctx).Errorf("[AGV] <-- read body error url=%s httpStatus=%d err=%v", reqURL, resp.StatusCode, err)
return err
}
+ logx.WithContext(ctx).Infof("[AGV] <-- HTTP %d url=%s body=%s", resp.StatusCode, reqURL, string(raw))
if resp.StatusCode >= 400 {
return fmt.Errorf("agv http %d: %s", resp.StatusCode, string(raw))
}
@@ -130,6 +139,7 @@ func (c *realClient) call(ctx context.Context, path string, payload map[string]a
}
// 成功码固定字符串 "0"(§1.5 结果码定义)
if env.Code != "0" {
+ logx.WithContext(ctx).Errorf("[AGV] <-- biz error url=%s code=%s message=%s reqCode=%v", reqURL, env.Code, env.Message, payload["reqCode"])
return fmt.Errorf("agv code=%s message=%s", env.Code, env.Message)
}
if out != nil && len(env.Data) > 0 {
@@ -290,20 +300,24 @@ func newMockClient() *mockClient { return &mockClient{} }
func (m *mockClient) SubmitTask(ctx context.Context, taskCode, fromDock, toDock, carrierCode, templateType, agvCode string) (string, error) {
// 模拟立即成功下发,返回我方 taskCode(与真实客户端一致,HikTaskCode=taskNo)
+ logx.WithContext(ctx).Infof("[AGV][MOCK] SubmitTask taskCode=%s %s->%s template=%s agvCode=%s(模拟下发成功,未发真实 HTTP)", taskCode, fromDock, toDock, templateType, agvCode)
return taskCode, nil
}
func (m *mockClient) QueryTask(ctx context.Context, taskCode string) (string, string, error) {
// 模拟:MOCK 任务一律视为已结束,便于离线联调观察"待搬运→已到位";模拟模式无真实分车,agvCode 为空
+ logx.WithContext(ctx).Infof("[AGV][MOCK] QueryTask taskCode=%s(模拟返回已结束)", taskCode)
return "9", "", nil
}
func (m *mockClient) CancelTask(ctx context.Context, taskCode, reason string) error {
+ logx.WithContext(ctx).Infof("[AGV][MOCK] CancelTask taskCode=%s reason=%s(模拟取消成功)", taskCode, reason)
return nil
}
// QueryAgvStatus Mock:返回两台示例车(一台空闲、一台执行中),便于联调展示。
func (m *mockClient) QueryAgvStatus(ctx context.Context) ([]AgvVehicle, error) {
+ logx.WithContext(ctx).Infof("[AGV][MOCK] QueryAgvStatus(模拟返回样例车 9001/9002)")
return []AgvVehicle{
{RobotCode: "9001", Battery: 99, Status: "4", PodCode: "0", PosX: 20000, PosY: 20000, Stop: false},
{RobotCode: "9002", Battery: 78, Status: "2", PodCode: "100001", PosX: 35000, PosY: 12000, Stop: false},
diff --git a/bj_power_mes/internal/handler/production/dailyplan_compare.go b/bj_power_mes/internal/handler/production/dailyplan_compare.go
index 1a5bed0..4f6d6d8 100644
--- a/bj_power_mes/internal/handler/production/dailyplan_compare.go
+++ b/bj_power_mes/internal/handler/production/dailyplan_compare.go
@@ -59,3 +59,47 @@ func DailyPlanCompareExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
_, _ = w.Write(buf.Bytes())
}
}
+
+// DailyPlanAttainmentHandler GET /daily-plans/attainment?start=&end= 计划 vs 实际(完工流水汇聚,2026-11-16)。
+func DailyPlanAttainmentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ q := r.URL.Query()
+ res, err := logic.New(svcCtx).DailyPlanAttainment(r.Context(), q.Get("start"), q.Get("end"))
+ if err != nil {
+ httpx.Fail(w, 3603, err.Error())
+ return
+ }
+ httpx.Ok(w, res)
+ }
+}
+
+// DailyPlanAttainmentExportHandler GET /daily-plans/attainment/export?start=&end= 直出 xlsx。
+func DailyPlanAttainmentExportHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+ return func(w http.ResponseWriter, r *http.Request) {
+ q := r.URL.Query()
+ res, err := logic.New(svcCtx).DailyPlanAttainment(r.Context(), q.Get("start"), q.Get("end"))
+ if err != nil {
+ httpx.Fail(w, 3604, err.Error())
+ return
+ }
+ f := excelize.NewFile()
+ const sheet = "计划vs实际"
+ _ = f.SetSheetName("Sheet1", sheet)
+ headers := []interface{}{"日期", "工单号", "计划数量", "实际完成", "差异"}
+ _ = f.SetSheetRow(sheet, "A1", &headers)
+ for i, it := range res {
+ row := []interface{}{it.Date, it.OrderNo, it.PlanQty, it.DoneQty, it.Diff}
+ _ = f.SetSheetRow(sheet, "A"+strconv.Itoa(i+2), &row)
+ }
+ buf, e := f.WriteToBuffer()
+ _ = f.Close()
+ if e != nil {
+ httpx.Fail(w, 3604, "生成 Excel 失败:"+e.Error())
+ return
+ }
+ w.Header().Set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+ w.Header().Set("Content-Disposition",
+ "attachment; filename=\"daily_plan_attainment.xlsx\"; filename*=UTF-8''"+url.PathEscape("日排产计划vs实际.xlsx"))
+ _, _ = w.Write(buf.Bytes())
+ }
+}
diff --git a/bj_power_mes/internal/handler/production/production.go b/bj_power_mes/internal/handler/production/production.go
index a84d37e..2a6bc64 100644
--- a/bj_power_mes/internal/handler/production/production.go
+++ b/bj_power_mes/internal/handler/production/production.go
@@ -226,11 +226,16 @@ func OrderQueryInternalHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
orderNo := r.URL.Query().Get("orderNo")
keyword := r.URL.Query().Get("keyword")
status := r.URL.Query().Get("status")
+ // firstStation(2026-11-16 上线建档下拉专用):>0 时只返回第1道工序候选工位含该工位的工单
+ firstStation := 0
+ if n, e := strconv.Atoi(r.URL.Query().Get("stationNo")); e == nil && n > 0 {
+ firstStation = n
+ }
limit := 0
if n, e := strconv.Atoi(r.URL.Query().Get("limit")); e == nil && n > 0 {
limit = n
}
- list, err := logic.New(svcCtx).ListWorkOrders(r.Context(), orderNo, status, "", "", "", "", keyword, limit, 0)
+ list, err := logic.New(svcCtx).ListWorkOrders(r.Context(), orderNo, status, "", "", "", "", keyword, limit, 0, firstStation)
if err != nil {
httpx.Fail(w, 2004, err.Error())
return
diff --git a/bj_power_mes/internal/handler/production/workorder.go b/bj_power_mes/internal/handler/production/workorder.go
index 7ec5cb7..0275754 100644
--- a/bj_power_mes/internal/handler/production/workorder.go
+++ b/bj_power_mes/internal/handler/production/workorder.go
@@ -244,7 +244,7 @@ func ListWorkOrdersHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
data, err := logic.New(svcCtx).ListWorkOrders(r.Context(),
q.Get("orderNo"), q.Get("status"), q.Get("productCode"), q.Get("productName"),
q.Get("contractNo"), q.Get("ownershipType"),
- q.Get("keyword"), limit, offset)
+ q.Get("keyword"), limit, offset, 0)
if err != nil {
httpx.Fail(w, 3004, err.Error())
return
diff --git a/bj_power_mes/internal/handler/routes_production.go b/bj_power_mes/internal/handler/routes_production.go
index 245328e..97879ac 100644
--- a/bj_power_mes/internal/handler/routes_production.go
+++ b/bj_power_mes/internal/handler/routes_production.go
@@ -628,6 +628,9 @@ func RegisterProductionRoutes(server *rest.Server, serverCtx *svc.ServiceContext
// ---------- 日排产历史对比(问题4):查询 + xlsx 导出 ----------
{Method: http.MethodGet, Path: "/daily-plans/compare", Handler: production.DailyPlanCompareHandler(serverCtx)},
{Method: http.MethodGet, Path: "/daily-plans/compare/export", Handler: production.DailyPlanCompareExportHandler(serverCtx)},
+ // ---------- 计划 vs 实际(2026-11-16 死结6:完工流水汇聚,不建新表) ----------
+ {Method: http.MethodGet, Path: "/daily-plans/attainment", Handler: production.DailyPlanAttainmentHandler(serverCtx)},
+ {Method: http.MethodGet, Path: "/daily-plans/attainment/export", Handler: production.DailyPlanAttainmentExportHandler(serverCtx)},
// ---------- 工单 SN 前缀(问题5):仅 CREATED 可改,事务重生成全部 SN ----------
{Method: http.MethodPost, Path: "/work-orders/sn-prefix", Handler: production.SnPrefixHandler(serverCtx)},
// ---------- 待办统计快照(问题8):WebSocket 长连接见下方单独注册 ----------
diff --git a/bj_power_mes/internal/logic/agv.go b/bj_power_mes/internal/logic/agv.go
index a1f12f6..6b4f7b7 100644
--- a/bj_power_mes/internal/logic/agv.go
+++ b/bj_power_mes/internal/logic/agv.go
@@ -193,6 +193,7 @@ func (s *Service) SubmitAgv(ctx context.Context, req AgvSubmitRequest, operator
}
// 第一段不指定车(用户拍板):RCS 自由派车,到位后回写 agv_code 作为本链锁定车
if _, aerr := s.ctx.Agv.SubmitTask(ctx, taskNo, source, r.phys, "", submitTmpl, ""); aerr != nil {
+ s.agvRcsCommFail(ctx, "下发 "+source+"→"+r.phys, aerr)
s.ctx.EntClient.AgvTask.UpdateOneID(t.ID).
SetStatus("FAILED").SetRemark("RCS下发失败: " + aerr.Error()).Exec(ctx)
failed = append(failed, target)
@@ -282,6 +283,17 @@ func (s *Service) DispatchCallAgv(ctx context.Context, requestNo, operator strin
return s.DispatchAgvForCall(ctx, mr, operator)
}
+// agvRcsCommFail AGV↔RCS 通讯失败统一落预警(2026-11-16):
+// 下发/查询/取消任一环节传输失败都算通讯异常,落「agv_rcs_fail」预警(10 分钟窗口去重防轮询风暴)。
+// target 固定 "AGV"(预警中心按对象归集);best-effort,落预警失败仅打日志不阻断主流程。
+func (s *Service) agvRcsCommFail(ctx context.Context, where string, err error) {
+ _, aerr := s.CreateAlertDedup(ctx, "agv_rcs_fail", "警告", "AGV",
+ "AGV 调度系统(RCS)通讯失败【"+where+"】:"+err.Error()+",请检查 RCS 服务与网络。", 10)
+ if aerr != nil {
+ fmt.Println("AGV 通讯失败落预警异常:", aerr)
+ }
+}
+
// DispatchAgvForCall 业务配送单派车(2026-11-13 拍板:独立「手动派车/叫料派车」入口下线,
// 只由仓库备料完成等业务配送链路触发;前端不再有可直调的手动派车路由):
// 由库管在 WMS 叫料队列点「送货」(DispatchCallAgv)调用——生成「空车前往装货点(JBT21)」段
@@ -441,6 +453,8 @@ func (s *Service) RefreshAgvTasks(ctx context.Context) (int, error) {
for _, t := range list {
st, agvCode, qerr := s.ctx.Agv.QueryTask(ctx, t.TaskNo)
if qerr != nil {
+ // 2026-11-16:查询失败不再静默,落通讯预警(去重窗口防轮询风暴)
+ s.agvRcsCommFail(ctx, "查询任务 "+t.TaskNo, qerr)
continue
}
// 工位专用接驳台取货:GO_LOAD 到工位后直接装车并送回库房,工位侧零确认。
@@ -587,6 +601,7 @@ func (s *Service) RetryAgvTask(ctx context.Context, taskNo, operator string) err
// 指定车重试(同段同车):任务行已回写 agv_code 时沿用,未回写传空由 RCS 自由派
_, aerr := s.ctx.Agv.SubmitTask(ctx, taskNo, t.SourceDock, t.TargetDock, "", submitTmpl, t.AgvCode)
if aerr != nil {
+ s.agvRcsCommFail(ctx, "重试下发 "+t.SourceDock+"→"+t.TargetDock, aerr)
s.ctx.EntClient.AgvTask.UpdateOneID(t.ID).
SetStatus("FAILED").SetRemark("RCS重试下发失败: " + aerr.Error()).Exec(ctx)
return fmt.Errorf("RCS 重试下发失败: %w", aerr)
@@ -804,6 +819,7 @@ func (s *Service) dispatchAgvSegment(ctx context.Context, in agvSegInput) (strin
if tmpl == "LIFT" { submitTmpl = s.CfgStr(ctx, CfgAgvTaskTypLift, "B01") } else { submitTmpl = s.CfgStr(ctx, CfgAgvTaskTypPlain, "B02") }
_, aerr := s.ctx.Agv.SubmitTask(ctx, taskNo, in.Source, in.Target, "", submitTmpl, in.AgvCode)
if aerr != nil {
+ s.agvRcsCommFail(ctx, "下发 "+in.Source+"→"+in.Target, aerr)
s.ctx.EntClient.AgvTask.UpdateOneID(t.ID).
SetStatus("FAILED").SetRemark("RCS下发失败: " + aerr.Error()).Exec(ctx)
return "", aerr
diff --git a/bj_power_mes/internal/logic/alert.go b/bj_power_mes/internal/logic/alert.go
index 88e974f..3ba9513 100644
--- a/bj_power_mes/internal/logic/alert.go
+++ b/bj_power_mes/internal/logic/alert.go
@@ -141,6 +141,32 @@ func (s *Service) CreateAlert(ctx context.Context, typ, level, target, message s
return err
}
+// CreateAlertDedup 带时间窗去重的预警创建(2026-11-16 通信类预警专用):
+// 同 type+target 在 windowMin 分钟内已有 UNREAD 预警时跳过,防轮询场景刷爆预警中心。
+// 返回 (true, nil)=实际落库;(false, nil)=窗口内已有同款被去重。
+func (s *Service) CreateAlertDedup(ctx context.Context, typ, level, target, message string, windowMin int) (bool, error) {
+ if windowMin <= 0 {
+ windowMin = 10
+ }
+ if windowMin > 1440 {
+ windowMin = 1440 // 上限 1 天,防误传超长窗口永久吞预警
+ }
+ since := time.Now().Add(-time.Duration(windowMin) * time.Minute)
+ cnt, cerr := s.ctx.EntClient.Alert.Query().Where(
+ alert.TypeEQ(typ),
+ alert.StatusEQ("UNREAD"),
+ alert.TargetEQ(target),
+ alert.CreatedAtGTE(since),
+ ).Count(ctx)
+ if cerr == nil && cnt > 0 {
+ return false, nil
+ }
+ if err := s.CreateAlert(ctx, typ, level, target, message); err != nil {
+ return false, err
+ }
+ return true, nil
+}
+
// publishStationAlert 报警写入成功后经 SSE Hub 广播 station.alert 事件(载荷=报警 JSON)。
// 终端侧按「工位N」自行过滤(Hub 是广播语义,按工位点对点过滤交给唯一消费者=终端后端)。
func (s *Service) publishStationAlert(a *ent.Alert) {
diff --git a/bj_power_mes/internal/logic/dailyplan.go b/bj_power_mes/internal/logic/dailyplan.go
index 6af65cf..5c95b86 100644
--- a/bj_power_mes/internal/logic/dailyplan.go
+++ b/bj_power_mes/internal/logic/dailyplan.go
@@ -261,15 +261,15 @@ func (s *Service) SuggestedDockCodes(ctx context.Context, orderNo string) []stri
}
// syncPlansByOrderStatus 工单状态联动日排产:
-// - 工单 → IN_PROGRESS:该工单 PENDING 排产置 PROCESSING(开始执行)
-// - 工单 → DONE:已足额完工(completedQty>=planQty)的排产置 DONE;其余未完成排产置 CANCELLED
-// - 工单 → CANCELLED:该工单未完成(PENDING/PROCESSING)排产全部置 CANCELLED
+// - 工单 → IN_PROGRESS:该工单 PENDING 排产置 PROCESSING(开始执行);CONFIRMED 保持不变(算料开关语义,2026-11-16)
+// - 工单 → DONE:已足额完工(completedQty>=planQty)的排产置 DONE;其余未完成排产置 CANCELLED(含 CONFIRMED)
+// - 工单 → CANCELLED:该工单未完成(PENDING/CONFIRMED/PROCESSING)排产全部置 CANCELLED
func (s *Service) syncPlansByOrderStatus(ctx context.Context, orderNo, woStatus, operator string) {
if orderNo == "" {
return
}
plans, err := s.ctx.EntClient.DailyPlan.Query().
- Where(dailyplan.OrderNo(orderNo), dailyplan.StatusIn("PENDING", "PROCESSING")).All(ctx)
+ Where(dailyplan.OrderNo(orderNo), dailyplan.StatusIn("PENDING", "CONFIRMED", "PROCESSING")).All(ctx)
if err != nil {
return
}
@@ -278,6 +278,9 @@ func (s *Service) syncPlansByOrderStatus(ctx context.Context, orderNo, woStatus,
for _, p := range plans {
switch woStatus {
case "IN_PROGRESS":
+ if p.Status == "CONFIRMED" {
+ continue // 已启用排产不随工单开工转 PROCESSING,保持算料参与资格
+ }
to = "PROCESSING"
case "DONE":
if p.CompletedQty >= p.PlanQty {
@@ -435,7 +438,7 @@ type ForScheduleWorkOrder struct {
// ListWorkOrdersForSchedule 返回未排满(剩余可排 > 0)的工单,供日排产工单号下拉过滤。
// 与 /daily-plans/unplanned("完全未排产"横幅入口)区分:本接口包含"部分排产"的工单。
func (s *Service) ListWorkOrdersForSchedule(ctx context.Context, keyword string) ([]*ForScheduleWorkOrder, error) {
- wos, err := s.ListWorkOrders(ctx, "", "", "", "", "", "", keyword, 0, 0)
+ wos, err := s.ListWorkOrders(ctx, "", "", "", "", "", "", keyword, 0, 0, 0)
if err != nil {
return nil, err
}
diff --git a/bj_power_mes/internal/logic/dailyplan_attainment.go b/bj_power_mes/internal/logic/dailyplan_attainment.go
new file mode 100644
index 0000000..2f6046e
--- /dev/null
+++ b/bj_power_mes/internal/logic/dailyplan_attainment.go
@@ -0,0 +1,95 @@
+package logic
+
+import (
+ "context"
+ "errors"
+ "sort"
+ "time"
+
+ "bj_power_mes/ent/dailyplan"
+ "bj_power_mes/ent/workpiecelifecyclelog"
+)
+
+// DailyPlanAttainmentRow 计划 vs 实际对比行(2026-11-16 死结6 定案)。
+// 用户口径:不是历史排产对比,是「排了 10 个,那天实际做出了几个」的实际执行结果;
+// 维度=现有日排产字段(排产日期/工单/计划数/实际数/差异),要看明细跳生产流程卡。
+type DailyPlanAttainmentRow struct {
+ Date string `json:"date"` // 排产/完工日期
+ OrderNo string `json:"orderNo"` // 工单号(产品工号)
+ PlanQty int `json:"planQty"` // 该日期该工单排产计划合计
+ DoneQty int `json:"doneQty"` // 该日期该工单实际完工台数(完工流水聚合)
+ Diff int `json:"diff"` // 实际 - 计划(负=欠产,正=超产)
+}
+
+// DailyPlanAttainment 计划 vs 实际(不建新表,直接汇聚,2026-11-16):
+// - 计划 = daily_plan 各状态排产行按 (plan_date, order_no) 合计 plan_qty(含已完成/已取消,看的是历史全量);
+// - 实际 = workpiece_lifecycle_log(action=DONE) 完工流水按 (完工当天, work_order_no) 聚合计数。
+//
+// 实际口径取完工流水而非 daily_plan.completed_qty:流水与生产流程卡同源(真流水),
+// 不受「当天无排产行实绩漏记」影响(bumpDailyPlanCompleted 只往匹配到的排产行累加)。
+// 窗口上限 92 天,防全表扫描。
+func (s *Service) DailyPlanAttainment(ctx context.Context, start, end string) ([]DailyPlanAttainmentRow, error) {
+ if start == "" || end == "" {
+ return nil, errors.New("请选择日期范围")
+ }
+ st, e1 := time.Parse("2006-01-02", start)
+ en, e2 := time.Parse("2006-01-02", end)
+ if e1 != nil || e2 != nil {
+ return nil, errors.New("日期格式应为 YYYY-MM-DD")
+ }
+ if en.Before(st) {
+ return nil, errors.New("结束日期不能早于开始日期")
+ }
+ if en.Sub(st).Hours() > 92*24 {
+ return nil, errors.New("对比窗口最长 92 天,请缩小日期范围")
+ }
+
+ rows := map[string]*DailyPlanAttainmentRow{}
+ outOrder := make([]string, 0, 64)
+ touch := func(date, orderNo string) *DailyPlanAttainmentRow {
+ key := date + "|" + orderNo
+ r, ok := rows[key]
+ if !ok {
+ r = &DailyPlanAttainmentRow{Date: date, OrderNo: orderNo}
+ rows[key] = r
+ outOrder = append(outOrder, key)
+ }
+ return r
+ }
+
+ // 计划:排产行合计(全状态,历史全量)
+ plans, err := s.ctx.EntClient.DailyPlan.Query().
+ Where(dailyplan.PlanDateGTE(start), dailyplan.PlanDateLTE(end)).All(ctx)
+ if err != nil {
+ return nil, err
+ }
+ for _, p := range plans {
+ touch(p.PlanDate, p.OrderNo).PlanQty += p.PlanQty
+ }
+
+ // 实际:完工流水(action=DONE)按完工当天聚合
+ logs, err := s.ctx.EntClient.WorkpieceLifecycleLog.Query().
+ Where(workpiecelifecyclelog.ActionEQ("DONE"),
+ workpiecelifecyclelog.CreatedAtGTE(st),
+ workpiecelifecyclelog.CreatedAtLT(en.Add(24*time.Hour))).All(ctx)
+ if err != nil {
+ return nil, err
+ }
+ for _, l := range logs {
+ touch(l.CreatedAt.Format("2006-01-02"), l.WorkOrderNo).DoneQty++
+ }
+
+ out := make([]DailyPlanAttainmentRow, 0, len(rows))
+ for _, key := range outOrder {
+ r := rows[key]
+ r.Diff = r.DoneQty - r.PlanQty
+ out = append(out, *r)
+ }
+ sort.Slice(out, func(i, j int) bool {
+ if out[i].Date != out[j].Date {
+ return out[i].Date < out[j].Date
+ }
+ return out[i].OrderNo < out[j].OrderNo
+ })
+ return out, nil
+}
diff --git a/bj_power_mes/internal/logic/flow_chain.go b/bj_power_mes/internal/logic/flow_chain.go
index 62e6c81..7c62664 100644
--- a/bj_power_mes/internal/logic/flow_chain.go
+++ b/bj_power_mes/internal/logic/flow_chain.go
@@ -82,13 +82,26 @@ func (s *Service) flowStationPoint(ctx context.Context, stationNo int) (*ent.Lin
return pts[0], true
}
-// flowStationBusy 该工位/末端是否被其他在制工件占用(按工件台账 atStationNo 判定,
-// 口径与 plc_monitor 位置核对一致;DONE/SCRAPPED 不算占用)。
-func (s *Service) flowStationBusy(ctx context.Context, stationNo int) bool {
- exist, err := s.ctx.EntClient.Workpiece.Query().
+// flowStationBusyBy 工位台面占用判定(2026-11-16 工位物理互斥):
+// 滚筒线单件流,工位台面同一时间只能放一个工件。按工件台账 atStationNo 判定,
+// 口径与 plc_monitor 位置核对一致;DONE/SCRAPPED 不算占用。
+// 返回:台面是否被占、占用件所属工单号。占用件属于其他工单 → 本件不准流入,在缓存位排队。
+func (s *Service) flowStationBusyBy(ctx context.Context, stationNo int, orderNo string) (bool, string, error) {
+ wps, err := s.ctx.EntClient.Workpiece.Query().
Where(workpiece.AtStationNoEQ(stationNo), workpiece.StatusNotIn("DONE", "SCRAPPED")).
- Exist(ctx)
- return err == nil && exist
+ All(ctx)
+ if err != nil {
+ return false, "", err
+ }
+ for _, w := range wps {
+ if w.OrderNo != orderNo {
+ return true, w.OrderNo, nil
+ }
+ }
+ if len(wps) > 0 {
+ return true, "", nil // 台面被本工单在制件占用,同样放不进第二件
+ }
+ return false, "", nil
}
// flowSend 按 §4.4 路由表下发流转指令,返回执行方式:
@@ -191,8 +204,11 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
}
// 目标选择:真实候选工位优先(升序,首个「台账空闲 + 无其他在制工件」者);
// 无台账行=虚拟工位(负数前段工位)仅作兜底。
+ // 2026-11-16 工位物理互斥:滚筒线单件流,工位台面被其他工单在制件占用 → 不准流入,
+ // 件留在缓存位/原地排队(下游 flowToCacheOrStay / stay)。末端下料位(END)豁免互斥。
var virtualCand *int
occupiedHit := false
+ occupiedHint := ""
for _, cand := range cands {
pt, has := s.flowStationPoint(ctx, cand)
if !has {
@@ -200,10 +216,21 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
virtualCand = &c
continue
}
- if pt.Occupied || s.flowStationBusy(ctx, cand) {
+ if pt.Occupied {
occupiedHit = true
continue
}
+ if pt.PointType != "END" {
+ busy, otherOrder, err := s.flowStationBusyBy(ctx, cand, wp.OrderNo)
+ if err == nil && busy {
+ occupiedHit = true
+ if otherOrder != "" {
+ occupiedHint = "工位" + strconv.Itoa(cand) + "正在加工工单" + otherOrder +
+ "的工件,须等其流转走后本件才能进入,已在缓存位排队等待"
+ }
+ continue
+ }
+ }
return s.flowExecMove(ctx, src, wp, sn, srcType, srcNo, pt, operator, doneAll)
}
if virtualCand != nil {
@@ -213,6 +240,9 @@ func (s *Service) flowMoveOnce(ctx context.Context, sn, operator string) (*FlowM
if occupiedHit && srcType == plc.SrcStation && !doneAll {
return s.flowToCacheOrStay(ctx, src, wp, sn, operator, srcNo)
}
+ if occupiedHint != "" {
+ return stay(occupiedHint)
+ }
return stay("下一道工序候选工位均不可达/不可用,滞留原地")
}
diff --git a/bj_power_mes/internal/logic/processflow.go b/bj_power_mes/internal/logic/processflow.go
index 0fdfeb0..19cab01 100644
--- a/bj_power_mes/internal/logic/processflow.go
+++ b/bj_power_mes/internal/logic/processflow.go
@@ -9,7 +9,6 @@ import (
"time"
"bj_power_mes/ent"
- "bj_power_mes/ent/dailyplan"
"bj_power_mes/ent/flowmaterial"
"bj_power_mes/ent/inspectionrecord"
"bj_power_mes/ent/lossledger"
@@ -600,27 +599,19 @@ func (s *Service) StationTask(ctx context.Context, stationNo int) (map[string]an
if err != nil {
return nil, errors.New("工位不存在或未配置")
}
- // 工位终端可见工单 = 今日已启用排产(CONFIRMED/执行中)且工单已下发并开工(IN_PROGRESS)。
- // 与状态机对齐(方案 A):工单「下发并开工」=批准生产、排产启用=排进某一天;未开工或未排进今天的工单,终端一律不显示。
+ // 工位终端可见工单(2026-11-16 死结7 定案):不限排产日期,所有进行中(IN_PROGRESS)工单,
+ // 且工艺组合必须包含本工位——干不了的单不给选(此前整线单都可见,选了报工才被拒)。
+ // 「昨天没干完的、想提前干明天的」都能选;PAUSED 暂停单不显示(恢复后可见)。
orderNos := []string{}
- today := time.Now().Format("2006-01-02")
- plans, _ := s.ctx.EntClient.DailyPlan.Query().
- Where(dailyplan.PlanDate(today), dailyplan.StatusIn("CONFIRMED", "PROCESSING")).
- Order(ent.Asc(dailyplan.FieldID)).All(ctx)
- nos := make([]string, 0, len(plans))
- seen := map[string]bool{}
- for _, p := range plans {
- if !seen[p.OrderNo] {
- seen[p.OrderNo] = true
- nos = append(nos, p.OrderNo)
- }
- }
- if len(nos) > 0 {
- wos, _ := s.ctx.EntClient.WorkOrder.Query().
- Where(workorder.WorkOrderNoIn(nos...), workorder.StatusIn("IN_PROGRESS")).
- Order(ent.Asc(workorder.FieldID)).All(ctx)
- for _, w := range wos {
- orderNos = append(orderNos, w.WorkOrderNo)
+ wos, _ := s.ctx.EntClient.WorkOrder.Query().
+ Where(workorder.StatusIn("IN_PROGRESS")).
+ Order(ent.Asc(workorder.FieldID)).All(ctx)
+ for _, w := range wos {
+ for _, item := range w.FlowCombination {
+ if item["stationNo"] == stationNo {
+ orderNos = append(orderNos, w.WorkOrderNo)
+ break
+ }
}
}
// M4:工位终端按「本工位绑定的工艺流程」驱动。
diff --git a/bj_power_mes/internal/logic/product_import.go b/bj_power_mes/internal/logic/product_import.go
index c5de804..21cbf98 100644
--- a/bj_power_mes/internal/logic/product_import.go
+++ b/bj_power_mes/internal/logic/product_import.go
@@ -13,20 +13,19 @@ import (
"github.com/xuri/excelize/v2"
)
-// 物料档案 Excel 导入模板表头(2026-11-10 与 WMS 模板统一:同一组列、同一顺序、同一列名)。
-// 图号留空则系统按 PROD-YYYYMMDD-流水 自动生成;成品(类别=成品)序列号强制=是。
-// 「物料编码」为普通字段,选填、不参与业务与必填校验,导入后写 materials.material_code。
-// 解析一律按表头名匹配(列顺序可变、可含多余列),两端都用同一套列名,避免两库模板错位。
-// E5(2026-11-03 拍板):类别列——成品/原材料均可导入;原材料(图号必填、序列号是/否可选)
-// 两库同步,导入后可在 WMS 物料档案查看。
+// 物料档案 Excel 导入模板表头(MES 成品导入,仅限成品;2026-11-16 拍板删除「图号」「物料编码」两列)。
+// 成品编码由系统按 PROD-YYYYMMDD-流水 自动生成;物料编码统一为空字符串。
+// 原材料不在本端导入(原材料图号是两库同步业务键,须人工填写),统一在 WMS 物料档案维护。
+// 解析一律按表头名匹配(列顺序可变、可含多余列),避免两库模板错位。
// 2026-11-05 拍板修订:导入顺序改为「探测 WMS 可达 → 先推 WMS → WMS 成功后 MES 再落库」;
// WMS 不可达或任一行推送失败则整批取消,MES 不写任何数据(物料档案两库对等双向同步:
// 按 code 幂等互推;本流程先推 WMS 保证两侧一致,库存真源在 WMS)。
-// 统一列顺序(2026-11-10 与 WMS 模板完全一致,除业务差异列由各自说明页注明):
-// 图号 | 物料编码 | 名称 | 规格 | 单位 | 类型 | 类别 | 序列号 | 启用 | 说明
// 2026-11-13 拍板:成品档案导入模板不允许出现「物料类型」列,全部按成品逻辑默认
-// (类型=其他3、序列号=是1);模板 9 列。旧模板含「类型」列也仍可导入(按表头名识别,多余列忽略)。
-var productTypeTemplateHeaders = []string{"图号", "物料编码", "名称", "规格", "单位", "类别", "序列号", "启用", "说明"}
+// (类型=其他3、序列号=是1)。旧模板含「类型」列也仍可导入(按表头名识别,多余列忽略)。
+// 2026-11-16 拍板(用户):模板删除「图号」「物料编码」两列——成品编码由系统自动生成
+// (PROD-YYYYMMDD-流水递增)、物料编码统一为空字符串;MES 成品导入仅限成品,
+// 原材料统一在 WMS 物料档案维护(原材料图号是两库同步业务键,须人工填写,不在本端导入)。
+var productTypeTemplateHeaders = []string{"名称", "规格", "单位", "类别", "序列号", "启用", "说明"}
// ProductTypeImportResult 单行导入结果汇总。
type ProductTypeImportResult struct {
@@ -52,41 +51,37 @@ func (s *Service) BuildProductTypeTemplate() ([]byte, error) {
if err := f.SetSheetRow(sheet, "A1", &productTypeTemplateHeaders); err != nil {
return nil, err
}
- // 示例行与 WMS 完全一致(material.go:832-833)
- example := []interface{}{"DX100-001", "WL-0001", "示例成品", "300x200x150", "台", "结构件", "成品", "是", "是", "示例行,导入前请删除"}
+ // 示例行:仅成品(2026-11-16 起原材料不在本端导入)
+ example := []interface{}{"示例成品", "300x200x150", "台", "结构件", "是", "是", "示例行,导入前请删除"}
if err := f.SetSheetRow(sheet, "A2", &example); err != nil {
return nil, err
}
- exampleRaw := []interface{}{"M-BEARING-6204", "WL-0002", "示例原材料-轴承6204", "6204-RS", "个", "结构件", "原材料", "否", "是", "示例行,导入前请删除"}
- if err := f.SetSheetRow(sheet, "A3", &exampleRaw); err != nil {
- return nil, err
- }
- // 列宽
- widths := map[int]float64{1: 20, 2: 16, 3: 18, 4: 18, 5: 10, 6: 12, 7: 10, 8: 10, 9: 10, 10: 24}
+ // 列宽(7 列)
+ widths := map[int]float64{1: 18, 2: 18, 3: 10, 4: 12, 5: 10, 6: 10, 7: 24}
for col, w := range widths {
if cell, err := excelize.ColumnNumberToName(col); err == nil {
_ = f.SetColWidth(sheet, cell, cell, w)
}
}
- // 填写说明页(结构对齐 WMS:列顺序 + 逐条说明;2/6/7/8 按两端各自生效口径注明)
+ // 填写说明页
const guide = "填写说明"
if _, err := f.NewSheet(guide); err != nil {
return nil, err
}
guides := []string{
- "【列顺序】图号 | 物料编码 | 名称 | 规格 | 单位 | 类别 | 序列号 | 启用 | 说明(成品档案模板,按表头名识别,请勿改动表头文字)",
- "1. 仅保留第一个「Sheet1」数据页,「填写说明」页请勿删除或填入数据;第2/3行是示例,正式导入前请删除。",
- "2. 图号:必填且唯一,物料唯一标识(两库同步业务键);成品可留空(留空自动生成 PROD-YYYYMMDD-流水),原材料必填;已有相同图号的行会被拒绝。",
- "3. 物料编码:选填,普通档案字段(如 WL-0001),不参与业务与必填校验。",
+ "【列顺序】名称 | 规格 | 单位 | 类别 | 序列号 | 启用 | 说明(成品档案模板,按表头名识别,请勿改动表头文字)",
+ "1. 仅保留第一个「Sheet1」数据页,「填写说明」页请勿删除或填入数据;第2行是示例,正式导入前请删除。",
+ "2. 成品编码(图号)无需填写:系统自动生成(PROD-年月日-流水,递增且唯一)。",
+ "3. 物料编码无需填写:统一为空。",
"4. 名称 / 规格 / 单位:必填,不可为空。",
- "5. 物料类型:本模板不提供此列,系统一律按成品逻辑默认(类型=其他、序列号=是);原材料请在 WMS 物料档案维护。",
- "6. 类别:填「原材料」或「成品」,默认成品(MES 口径;WMS 侧叫「物料类别」,留空默认原材料)。",
- "7. 序列号:填「是」「否」或 1/2;成品强制为「是」,原材料可按实际选是/否(WMS 导入忽略本列,按类型自动派生)。",
- "8. 启用:填「是」「否」或 true/false,默认「是」(WMS 导入忽略本列,默认启用)。",
+ "5. 类别:只能填「成品」;原材料请在 WMS 物料档案维护(不在本端导入)。",
+ "6. 物料类型:本模板不提供此列,系统一律按成品逻辑默认(类型=其他、序列号=是)。",
+ "7. 序列号:本模板不提供此列,成品强制为「是」。",
+ "8. 启用:填「是」「否」或 true/false,默认「是」。",
"9. 说明:可空,备注信息。",
"10. 首行为表头,从第二行开始为数据;整批校验,任一行出错则一行不写(可在导入前点「预检」先看错误明细)。",
- "【MES 业务差异】本端导入会先探测 WMS 可达并逐行先写 WMS,WMS 失败则整批取消;「类别/序列号/启用」按 MES 口径生效。",
+ "【MES 业务差异】本端导入会先探测 WMS 可达并逐行先写 WMS,WMS 失败则整批取消。",
}
for i, g := range guides {
if err := f.SetSheetRow(guide, fmt.Sprintf("A%d", i+1), &[]interface{}{g}); err != nil {
@@ -153,16 +148,17 @@ func parseProductImportRows(data []byte) ([]productImportRow, []ProductTypeRowEr
errs = append(errs, ProductTypeRowErr{Row: line, Message: "名称/规格/单位 均为必填"})
continue
}
- // E5(2026-11-03 拍板):类别列——成品(默认)/原材料;原材料行落 materials(itemType=1) 并推 WMS
+ // E5 类别列:本端导入仅限成品(2026-11-16 拍板)——原材料行直接拒绝,统一在 WMS 物料档案维护
itemType := 3
if v := get(r, "类别"); v != "" {
switch v {
case "成品", "3":
itemType = 3
case "原材料", "1":
- itemType = 1
+ errs = append(errs, ProductTypeRowErr{Row: line, Message: "MES 成品导入仅限成品;原材料请在 WMS 物料档案维护"})
+ continue
default:
- errs = append(errs, ProductTypeRowErr{Row: line, Message: fmt.Sprintf("类别须为 成品/原材料,当前为「%s」", v)})
+ errs = append(errs, ProductTypeRowErr{Row: line, Message: fmt.Sprintf("类别须为 成品,当前为「%s」", v)})
continue
}
}
@@ -195,27 +191,17 @@ func parseProductImportRows(data []byte) ([]productImportRow, []ProductTypeRowEr
isActive = ia
}
}
- code := get(r, "图号")
- if itemType == 1 {
- if code == "" {
- errs = append(errs, ProductTypeRowErr{Row: line, Message: "原材料图号必填(原材料为两库同步业务键,不自动生成编码)"})
- continue
- }
- if e := validateTypeAndSnMode(mm, snMode); e != nil {
- errs = append(errs, ProductTypeRowErr{Row: line, Message: e.Error()})
- continue
- }
- }
+ // 2026-11-16 拍板:模板无「图号」「物料编码」列——成品编码写入阶段自动生成、物料编码统一为空
plans = append(plans, productImportRow{
line: line,
itemType: itemType,
req: ProductTypeReq{
- Code: code,
+ Code: "",
Name: name,
Spec: spec,
Unit: unit,
Description: get(r, "说明"),
- MaterialCode: get(r, "物料编码"),
+ MaterialCode: "",
ManageMode: mm,
SnMode: snMode,
IsActive: isActive,
@@ -361,7 +347,7 @@ func (s *Service) createProductImportRowTx(ctx context.Context, tx *ent.Tx, p pr
SetSpec(req.Spec).
SetUnit(req.Unit).
SetDescription(req.Description).
- SetMaterialCode(strings.TrimSpace(req.MaterialCode)).
+ SetMaterialCode("").
SetItemType(p.itemType).
SetManageMode(req.ManageMode).
SetSnMode(snMode).
diff --git a/bj_power_mes/internal/logic/scan.go b/bj_power_mes/internal/logic/scan.go
index cfc27c4..5404bdb 100644
--- a/bj_power_mes/internal/logic/scan.go
+++ b/bj_power_mes/internal/logic/scan.go
@@ -24,11 +24,13 @@ func (s *Service) bumpWorkOrderProgress(ctx context.Context, orderNo, sn string)
// bumpDailyPlanCompleted 工单完工联动当日排产:completedQty+1,达到 planQty 置 DONE。
// 当天没有匹配排产则跳过(不做自动建单)。仅由真正的完工事件调用。
+// 2026-11-16 修复:状态过滤补入 CONFIRMED——已启用排产此前完工不累计实绩(恒 0、diff 恒等于计划量)。
+// CONFIRMED 未足额时保持 CONFIRMED(算料开关语义不变,不转 PROCESSING),足额仍置 DONE。
func (s *Service) bumpDailyPlanCompleted(ctx context.Context, orderNo string, t time.Time) {
date := t.Format("2006-01-02")
plans, err := s.ctx.EntClient.DailyPlan.Query().
Where(dailyplan.OrderNo(orderNo), dailyplan.PlanDate(date)).
- Where(dailyplan.StatusIn("PENDING", "PROCESSING", "DONE")).All(ctx)
+ Where(dailyplan.StatusIn("PENDING", "CONFIRMED", "PROCESSING", "DONE")).All(ctx)
if err != nil || len(plans) == 0 {
return
}
diff --git a/bj_power_mes/internal/logic/workorder.go b/bj_power_mes/internal/logic/workorder.go
index 2f04429..c2c596d 100644
--- a/bj_power_mes/internal/logic/workorder.go
+++ b/bj_power_mes/internal/logic/workorder.go
@@ -47,25 +47,34 @@ func (s *Service) CreateWorkOrder(ctx context.Context, req WorkOrderReq, operato
// 2026-11-13 拍板:排产/建工单必须读取「当前产线在用的混产模板」并校验产品范围。
// 同模板内多工单(多成品)混产直接放行;模板外新产品必须先清线并切换当前模板,
// 不允许排产偷偷把新产品塞进不属于它的产线配置里。
+ // 2026-11-16 fail-close 收口:无在用模板 / 成品编码缺失一律拒绝,堵住"没配模板就跳过校验"的旁路。
tplName, products, tErr := s.ActiveMixProducts(ctx)
if tErr != nil {
return tErr
}
- if tplName != "" && strings.TrimSpace(req.ProductCode) != "" {
+ // 收集式校验(报错一次收全 + 每条带怎么办,2026-10-20):字段问题全部列出、一次性返回,不再串行 return
+ ve := verr.New()
+ if tplName == "" {
+ ve.Add("mixTemplate", "当前产线没有设置「在用」混产模板,无法创建工单",
+ "先到「工位管理」配置工位工艺绑定并保存为混产模板,再到混产模板页将其设为当前在用模板")
+ }
+ pc := strings.TrimSpace(req.ProductCode)
+ if pc == "" {
+ ve.Add("productCode", "工单缺少成品编码,无法校验混产范围",
+ "请先确认所选产品型号档案已生成成品编码,再创建工单")
+ } else if tplName != "" {
allowed := false
for _, c := range products {
- if c == strings.TrimSpace(req.ProductCode) {
+ if c == pc {
allowed = true
break
}
}
if !allowed {
- return fmt.Errorf("当前产线在用混产模板「%s」不含成品 %s;跨模板引入新产品需先清线,再到「工位管理 → 保存当前绑定为模板」切换当前模板",
- tplName, req.ProductCode)
+ ve.Add("productCode", fmt.Sprintf("当前产线在用混产模板「%s」不含成品 %s", tplName, pc),
+ "跨模板引入新产品需先清线,再到「工位管理 → 保存当前绑定为模板」切换当前模板")
}
}
- // 收集式校验(报错一次收全 + 每条带怎么办,2026-10-20):字段问题全部列出、一次性返回,不再串行 return
- ve := verr.New()
if req.ProductTypeId == 0 {
ve.Add("productTypeId", "请选择产品型号", "在「产品型号」下拉中选择本次要生产的产品")
}
@@ -374,8 +383,10 @@ func (s *Service) UpdateWorkOrder(ctx context.Context, req WorkOrderReq, operato
// 工程编号查询已随编号体系改造移除,字段保留仅防历史迁移)。
// keyword:跨字段模糊(工单号/产品编码/产品名称/合同号 任一命中),供下拉远程搜索用;
// limit:>0 时启用截断(封顶 200),仅下拉搜索场景传参,列表页不传=全量,行为向后兼容;
-// offset:>0 时跳过前 N 条,配合 limit 供下拉滚动分页(不传=0,行为向后兼容)。
-func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCode, productName, contractNo, ownershipType, keyword string, limit, offset int) ([]*ent.WorkOrder, error) {
+// offset:>0 时跳过前 N 条,配合 limit 供下拉滚动分页(不传=0,行为向后兼容);
+// firstStation:>0 时只返回「第1道工序候选工位含该工位」的工单(2026-11-16 上线建档下拉专用,
+// 与建档落点资格校验同口径),0=不过滤,行为向后兼容。
+func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCode, productName, contractNo, ownershipType, keyword string, limit, offset int, firstStation int) ([]*ent.WorkOrder, error) {
q := s.ctx.EntClient.WorkOrder.Query()
if orderNo != "" {
q = q.Where(workorder.WorkOrderNoContainsFold(orderNo))
@@ -409,14 +420,36 @@ func (s *Service) ListWorkOrders(ctx context.Context, orderNo, status, productCo
if offset > 0 {
q = q.Offset(offset)
}
- // limit 截断(封顶 200):仅下拉搜索场景启用,防数据炸弹
- if limit > 0 {
- if limit > 200 {
- limit = 200
- }
- q = q.Limit(limit)
+ q = q.Order(ent.Desc(workorder.FieldCreatedAt), ent.Desc(workorder.FieldID))
+ rows, err := q.All(ctx)
+ if err != nil {
+ return nil, err
}
- return q.Order(ent.Desc(workorder.FieldCreatedAt), ent.Desc(workorder.FieldID)).All(ctx)
+ if limit > 200 {
+ limit = 200
+ }
+ // 首道候选工位过滤:需取回后在内存按工艺组合计算(截断前过滤会漏),命中即收,达 limit 早停
+ if firstStation > 0 {
+ out := make([]*ent.WorkOrder, 0, len(rows))
+ for _, w := range rows {
+ items, _ := RouteStationsFromWO(ctx, s.ctx.EntClient, w)
+ if len(items) == 0 {
+ continue
+ }
+ route := groupFlowRoute(items)
+ if len(route) > 0 && intsContains(route[0].Stations, firstStation) {
+ out = append(out, w)
+ }
+ if limit > 0 && len(out) >= limit {
+ break
+ }
+ }
+ return out, nil
+ }
+ if limit > 0 && len(rows) > limit {
+ rows = rows[:limit]
+ }
+ return rows, nil
}
// ListProcessCards 流程卡列表(分页):每个工单=一张生产流程卡。
diff --git a/bj_power_mes/internal/logic/workpiece.go b/bj_power_mes/internal/logic/workpiece.go
index 7ccdaee..06a198e 100644
--- a/bj_power_mes/internal/logic/workpiece.go
+++ b/bj_power_mes/internal/logic/workpiece.go
@@ -213,7 +213,7 @@ func (s *Service) OnlineWorkpiece(ctx context.Context, req OnlineReq, operator s
return "", nil, errors.New("sn 不能为空")
}
default: // 0=未选择(档案缺失/未配置)
- return "", nil, errors.New("请先在产品型号/物料档案选择序列号管理方式(序列号=是/否)")
+ return "", nil, errors.New("请先在成品档案设置序列号管理方式(序列号=是/否)")
}
if err := s.ctx.EntClient.Workpiece.Create().
SetSn(req.Sn).SetOrderNo(req.OrderNo).SetWorkOrderId(req.WorkOrderId).
@@ -264,6 +264,13 @@ func (s *Service) onlineNewWorkpiece(ctx context.Context, wp *ent.Workpiece, req
return "", nil, fmt.Errorf("新件建档必须落在第1道工序的候选工位(%s)之一,当前落点工位%d不符合资格",
joinIntsLocal(firstStations), req.StationNo)
}
+ // 工位物理互斥(2026-11-16):滚筒线单件流,落点工位台面被其他工单在制件占用 → 拒绝建档,
+ // 该件须等占用件流转走(或改落其他空闲候选工位)。
+ busy, otherOrder, err := s.flowStationBusyBy(ctx, req.StationNo, wp.OrderNo)
+ if err == nil && busy && otherOrder != "" {
+ return "", nil, fmt.Errorf("建档落点工位%d正在加工工单%s的工件(工位互斥,一次只干一个工单),请等其流转走或改落其他空闲候选工位",
+ req.StationNo, otherOrder)
+ }
station := req.StationNo
if _, e := s.ctx.EntClient.Workpiece.UpdateOneID(wp.ID).
SetStatus("ONLINE").SetOnlineAt(time.Now()).SetAtStationNo(station).Save(ctx); e != nil {
@@ -409,6 +416,9 @@ func (s *Service) workpieceWorkOrder(ctx context.Context, wp *ent.Workpiece) *en
type ReportProcessReq struct {
Sn string `json:"sn"`
+ // OrderNo 终端当前作业工单(2026-11-16 错单强拦截):与扫码件归属工单不一致直接拒绝,
+ // 禁止把工单B的件静默记到工单A(工位互斥配套防呆)。
+ OrderNo string `json:"orderNo"`
FlowId int `json:"flowId"` // 报工工艺(缺省回退工位当前绑定的工艺)
StationNo int `json:"stationNo"`
Operator string `json:"operator"` // 操作工(工位终端登录人注入;内部接口无 JWT 时作为操作人来源,杜绝「system」伪造留痕)
@@ -477,6 +487,12 @@ func (s *Service) ReportProcess(ctx context.Context, req ReportProcessReq, opera
if err != nil || wo == nil {
return errors.New("工件所属工单不存在")
}
+ // 2026-11-16 错单强拦截(工位物理互斥配套):终端当前作业工单必须与扫码件归属工单一致,
+ // 不一致直接拒绝,杜绝"扫到工单B的件静默记到工单A"的错账。
+ if req.OrderNo != "" && req.OrderNo != wo.WorkOrderNo {
+ return fmt.Errorf("扫码件 %s 属于工单 %s,与当前作业工单 %s 不一致,已拒绝报工;请先在作业页切换到工单 %s,或核对手中工件",
+ req.Sn, wo.WorkOrderNo, req.OrderNo, wo.WorkOrderNo)
+ }
// 并行候选工位模型(2026-11-02):同工序可配置多个候选工位,工件在任一候选工位报工一次即完成该工序;
// 不可跳工序(须按工序顺序),同工序已报工则不可重复报工。
route, _ := FlowRouteOfWO(ctx, s.ctx.EntClient, wo)
diff --git a/bj_power_mes/internal/plc/logging.go b/bj_power_mes/internal/plc/logging.go
new file mode 100644
index 0000000..2c5467d
--- /dev/null
+++ b/bj_power_mes/internal/plc/logging.go
@@ -0,0 +1,114 @@
+// logging.go PLC 全量交互日志装饰器(2026-11-16 联调)。
+// 包装 Client 接口全部方法:调用参数、返回值、错误统一落 logx(前缀 [PLC])。
+// 在 NewManager 处包一层,mock / 真实 S7(tcp.go) / tcp 自定义协议全部覆盖;
+// tcp.go 为保护文件不做改动,日志在此层完成。
+package plc
+
+import (
+ "context"
+ "fmt"
+
+ "github.com/zeromicro/go-zero/core/logx"
+)
+
+// logClient 日志装饰器:inner 为真实实现(s7Real / tcpClient / mock)。
+type logClient struct{ inner Client }
+
+func newLogClient(inner Client) *logClient { return &logClient{inner: inner} }
+
+func (l *logClient) SendProcessCode(ctx context.Context, combination string) ([]int, error) {
+ logx.WithContext(ctx).Infof("[PLC] --> SendProcessCode combination=%s", combination)
+ codes, err := l.inner.SendProcessCode(ctx, combination)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- SendProcessCode err=%v", err)
+ } else {
+ logx.WithContext(ctx).Infof("[PLC] <-- SendProcessCode codes=%v", codes)
+ }
+ return codes, err
+}
+
+func (l *logClient) QueryDone(ctx context.Context) (bool, error) {
+ done, err := l.inner.QueryDone(ctx)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- QueryDone err=%v", err)
+ } else {
+ logx.WithContext(ctx).Infof("[PLC] <-- QueryDone done=%v", done)
+ }
+ return done, err
+}
+
+func (l *logClient) AckDone(ctx context.Context, ok bool) {
+ logx.WithContext(ctx).Infof("[PLC] AckDone ok=%v", ok)
+ l.inner.AckDone(ctx, ok)
+}
+
+func (l *logClient) QueryDockPallet(ctx context.Context, dockCode string) (bool, error) {
+ has, err := l.inner.QueryDockPallet(ctx, dockCode)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- QueryDockPallet dock=%s err=%v", dockCode, err)
+ } else {
+ logx.WithContext(ctx).Infof("[PLC] <-- QueryDockPallet dock=%s hasPallet=%v", dockCode, has)
+ }
+ return has, err
+}
+
+func (l *logClient) QueryStationPallet(ctx context.Context, stationNo int) (bool, error) {
+ has, err := l.inner.QueryStationPallet(ctx, stationNo)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- QueryStationPallet station=%d err=%v", stationNo, err)
+ } else {
+ logx.WithContext(ctx).Infof("[PLC] <-- QueryStationPallet station=%d hasPallet=%v", stationNo, has)
+ }
+ return has, err
+}
+
+func (l *logClient) ReadBits(ctx context.Context) ([]bool, error) {
+ bits, err := l.inner.ReadBits(ctx)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- ReadBits err=%v", err)
+ } else {
+ // 48 位压成 0/1 字符串,一行可读
+ s := make([]byte, len(bits))
+ for i, b := range bits {
+ if b {
+ s[i] = '1'
+ } else {
+ s[i] = '0'
+ }
+ }
+ logx.WithContext(ctx).Infof("[PLC] <-- ReadBits bits=%s", string(s))
+ }
+ return bits, err
+}
+
+func (l *logClient) ReadMW(ctx context.Context, addr int) (int, error) {
+ v, err := l.inner.ReadMW(ctx, addr)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- ReadMW MW%d err=%v", addr, err)
+ } else {
+ logx.WithContext(ctx).Infof("[PLC] <-- ReadMW MW%d=%d", addr, v)
+ }
+ return v, err
+}
+
+func (l *logClient) ReadMWBlock(ctx context.Context, start, count int) ([]int, error) {
+ vals, err := l.inner.ReadMWBlock(ctx, start, count)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- ReadMWBlock MW%d..MW%d err=%v", start, start+count-1, err)
+ } else {
+ logx.WithContext(ctx).Infof("[PLC] <-- ReadMWBlock MW%d..MW%d vals=%v", start, start+count-1, vals)
+ }
+ return vals, err
+}
+
+func (l *logClient) WriteMW(ctx context.Context, addr, value int) error {
+ logx.WithContext(ctx).Infof("[PLC] --> WriteMW MW%d=%d", addr, value)
+ err := l.inner.WriteMW(ctx, addr, value)
+ if err != nil {
+ logx.WithContext(ctx).Errorf("[PLC] <-- WriteMW MW%d=%d err=%v", addr, value, err)
+ }
+ return err
+}
+
+// String 满足调试打印。
+func (l *logClient) String() string { return fmt.Sprintf("logClient(%T)", l.inner) }
diff --git a/bj_power_mes/internal/plc/plc.go b/bj_power_mes/internal/plc/plc.go
index 78c0c2a..d8ee7df 100644
--- a/bj_power_mes/internal/plc/plc.go
+++ b/bj_power_mes/internal/plc/plc.go
@@ -51,6 +51,7 @@ type Manager struct {
client Client
mock bool
onRecover func(ctx context.Context)
+ onFail func(ctx context.Context, err error) // 2026-11-16:连续失败首次沿触发(通信异常预警),恢复后重置
mu sync.Mutex
consecFails int
mockOffline bool // mock 模式:模拟 PLC 离线(拍板2 联调/自测用,真实 PLC 忽略)
@@ -59,9 +60,9 @@ type Manager struct {
func NewManager(c config.PlcConf, mock bool) (*Manager, error) {
m := &Manager{mock: mock}
if mock {
- m.client = newMockClient()
+ m.client = newLogClient(newMockClient())
} else {
- m.client = newTcpClient(c)
+ m.client = newLogClient(newTcpClient(c))
}
return m, nil
}
@@ -78,6 +79,14 @@ func (m *Manager) SetOnRecover(f func(ctx context.Context)) {
m.mu.Unlock()
}
+// SetOnFail 设置 PLC 通讯失败回调(2026-11-16):连续失败首次沿触发一次(落预警中心),
+// 恢复成功后重置——下次再断再触发;持续断连期间不重复触发(防轮询风暴,预警侧另有窗口去重)。
+func (m *Manager) SetOnFail(f func(ctx context.Context, err error)) {
+ m.mu.Lock()
+ m.onFail = f
+ m.mu.Unlock()
+}
+
// QueryStationPallet 读工位托盘位(带恢复检测):查询成功且此前发生过失败 → 触发 OnRecover(T6)。
// mock 模式下可经 SetMockOffline 模拟离线(读失败),验证拍板2「PLC 离线提示+人工强行确认」链路。
func (m *Manager) QueryStationPallet(ctx context.Context, stationNo int) (bool, error) {
@@ -128,6 +137,12 @@ func (m *Manager) track(err error) {
defer m.mu.Unlock()
if err != nil {
m.consecFails++
+ // 2026-11-16:连续失败首次沿触发 onFail(通信异常落预警);持续断连不重复触发。
+ if m.consecFails == 1 && m.onFail != nil {
+ f := m.onFail
+ failErr := err
+ go f(context.Background(), failErr)
+ }
return
}
if m.consecFails > 0 {
diff --git a/bj_power_mes/internal/wmsclient/client.go b/bj_power_mes/internal/wmsclient/client.go
index 6033178..1bf4138 100644
--- a/bj_power_mes/internal/wmsclient/client.go
+++ b/bj_power_mes/internal/wmsclient/client.go
@@ -30,7 +30,7 @@ const defaultBaseURL = "http://127.0.0.1:9091"
func New(baseURL, token string) *Client {
c := &Client{
token: token,
- hc: &http.Client{Timeout: 5 * time.Second},
+ hc: &http.Client{Timeout: 5 * time.Second, Transport: newLoggingTransport()},
}
c.SetBaseURL(baseURL)
return c
diff --git a/bj_power_mes/internal/wmsclient/transport_logging.go b/bj_power_mes/internal/wmsclient/transport_logging.go
new file mode 100644
index 0000000..c48bbcf
--- /dev/null
+++ b/bj_power_mes/internal/wmsclient/transport_logging.go
@@ -0,0 +1,78 @@
+// transport_logging.go MES→WMS 全量 HTTP 交互日志(2026-11-16 联调)。
+// 用 http.RoundTripper 装饰器实现:挂在 Client.hc 上后,所有出口函数
+// (post/get/postSemi/ExportProductTypes 等)的每次请求自动落日志,无需逐点插桩。
+// 记录:请求方法/完整URL/请求体(截断 2000 字节)、响应状态码/响应体(截断 2000 字节)、传输错误。
+// 前缀 [MES→WMS],grep 即可定位;响应体读出后用 NopCloser 回填,不影响调用方解析。
+package wmsclient
+
+import (
+ "bytes"
+ "context"
+ "io"
+ "net/http"
+
+ "github.com/zeromicro/go-zero/core/logx"
+)
+
+// loggingTransport 日志装饰 transport。
+type loggingTransport struct{ base http.RoundTripper }
+
+// FailHook WMS 通讯失败钩子(2026-11-16):仅【传输层失败】(连不上/超时/断连)触发,
+// HTTP 非 2xx 与业务码非 0 属正常业务响应不触发。main 启动时装配(落预警中心),包外勿随意设置。
+// 去重由回调实现方负责(CreateAlertDedup 窗口去重),本层只负责在错误发生时通知。
+var FailHook func(ctx context.Context, method, url string, err error)
+
+func newLoggingTransport() *loggingTransport {
+ return &loggingTransport{base: http.DefaultTransport}
+}
+
+func (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ u := req.URL.String()
+ var reqBody []byte
+ if req.Body != nil {
+ reqBody, _ = io.ReadAll(req.Body)
+ _ = req.Body.Close()
+ req.Body = io.NopCloser(bytes.NewReader(reqBody))
+ }
+ logx.WithContext(req.Context()).Infof("[MES→WMS] --> %s %s body=%s", req.Method, u, truncateLogBytes(reqBody))
+
+ resp, err := t.base.RoundTrip(req)
+ if err != nil {
+ logx.WithContext(req.Context()).Errorf("[MES→WMS] <-- transport error %s err=%v", u, err)
+ if FailHook != nil {
+ FailHook(req.Context(), req.Method, u, err)
+ }
+ return resp, err
+ }
+ raw, rerr := io.ReadAll(resp.Body)
+ _ = resp.Body.Close()
+ if rerr != nil {
+ logx.WithContext(req.Context()).Errorf("[MES→WMS] <-- read body error %s status=%d err=%v", u, resp.StatusCode, rerr)
+ }
+ resp.Body = io.NopCloser(bytes.NewReader(raw))
+ logx.WithContext(req.Context()).Infof("[MES→WMS] <-- HTTP %d %s body=%s", resp.StatusCode, u, truncateLogBytes(raw))
+ return resp, nil
+}
+
+// truncateLogBytes 日志防刷爆:超 2000 字节截断(xlsx 导出等大响应只记头段)。
+func truncateLogBytes(b []byte) string {
+ const max = 2000
+ if len(b) <= max {
+ return string(b)
+ }
+ return string(b[:max]) + "...(截断,共" + itoaLen(len(b)) + "字节)"
+}
+
+func itoaLen(n int) string {
+ if n == 0 {
+ return "0"
+ }
+ var buf [20]byte
+ i := len(buf)
+ for n > 0 {
+ i--
+ buf[i] = byte('0' + n%10)
+ n /= 10
+ }
+ return string(buf[i:])
+}
diff --git a/bj_power_mes/public/index.html b/bj_power_mes/public/index.html
index 0708ba8..4c0ba30 100644
--- a/bj_power_mes/public/index.html
+++ b/bj_power_mes/public/index.html
@@ -6,7 +6,7 @@
MES 产线控制
-
+
diff --git a/bj_power_wms/bj_power_wms.go b/bj_power_wms/bj_power_wms.go
index 7140378..c572122 100644
--- a/bj_power_wms/bj_power_wms.go
+++ b/bj_power_wms/bj_power_wms.go
@@ -29,12 +29,14 @@ import (
"bj_power_wms/internal/eventlog"
"bj_power_wms/internal/handler"
"bj_power_wms/internal/logdaily"
+ "bj_power_wms/internal/mesclient"
"bj_power_wms/internal/scanbridge"
"bj_power_wms/internal/svc"
"bj_power_wms/internal/tray"
"golang.org/x/crypto/bcrypt"
"golang.org/x/sys/windows"
+ "bj_power_wms/ent/alert"
"bj_power_wms/ent/user"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/logx"
@@ -713,6 +715,31 @@ func runServeWMS(c config.Config) {
ctx := svc.NewServiceContext(c)
+ // MES 通讯失败预警(2026-11-16):WMS→MES 传输层失败(连不上/超时)触发,
+ // 10 分钟窗口去重防轮询风暴;HTTP 业务错误(服务在但拒绝)不算通讯异常、不触发。
+ mesclient.FailHook = func(hookCtx context.Context, method, url string, hookErr error) {
+ fc, cancel := context.WithTimeout(context.Background(), 10*time.Second)
+ defer cancel()
+ since := time.Now().Add(-10 * time.Minute)
+ cnt, cerr := ctx.EntClient.Alert.Query().Where(
+ alert.RuleCodeEQ("mes_unreachable"),
+ alert.StatusEQ("unread"),
+ alert.TargetEQ("MES"),
+ alert.CreatedAtGTE(since.Unix()),
+ ).Count(fc)
+ if cerr == nil && cnt > 0 {
+ return
+ }
+ _, aerr := ctx.EntClient.Alert.Create().
+ SetRuleCode("mes_unreachable").SetLevel("warning").SetTarget("MES").
+ SetTitle("MES 通讯失败:" + hookErr.Error()).
+ SetContent(fmt.Sprintf("WMS→MES %s %s(%v),备料回写/工单查询/成品反查将失败,请检查 MES 服务。", method, url, hookErr)).
+ SetStatus("unread").Save(fc)
+ if aerr != nil {
+ logx.Errorf("MES 通讯失败落预警异常: %v", aerr)
+ }
+ }
+
// 扫码中间件(键盘 HID 注入):Enable=true 时随 WMS 启动监听 7757,接收网络型扫码枪推送并模拟键盘注入当前光标窗口。
// 7757 被占用时仅记日志、不影响主程序(与 MES 同机同开时谁先启动谁监听,后到的只记日志)。
if c.Scanner.Enabled {
diff --git a/bj_power_wms/ent/client.go b/bj_power_wms/ent/client.go
index 13bc2a1..81b8b6a 100644
--- a/bj_power_wms/ent/client.go
+++ b/bj_power_wms/ent/client.go
@@ -20,6 +20,7 @@ import (
"bj_power_wms/ent/eventlog"
"bj_power_wms/ent/inbounddetail"
"bj_power_wms/ent/inboundorder"
+ "bj_power_wms/ent/inspectiondisposalitem"
"bj_power_wms/ent/inspectionrecord"
"bj_power_wms/ent/inventory"
"bj_power_wms/ent/inventorylock"
@@ -67,6 +68,8 @@ type Client struct {
InboundDetail *InboundDetailClient
// InboundOrder is the client for interacting with the InboundOrder builders.
InboundOrder *InboundOrderClient
+ // InspectionDisposalItem is the client for interacting with the InspectionDisposalItem builders.
+ InspectionDisposalItem *InspectionDisposalItemClient
// InspectionRecord is the client for interacting with the InspectionRecord builders.
InspectionRecord *InspectionRecordClient
// Inventory is the client for interacting with the Inventory builders.
@@ -123,6 +126,7 @@ func (c *Client) init() {
c.EventLog = NewEventLogClient(c.config)
c.InboundDetail = NewInboundDetailClient(c.config)
c.InboundOrder = NewInboundOrderClient(c.config)
+ c.InspectionDisposalItem = NewInspectionDisposalItemClient(c.config)
c.InspectionRecord = NewInspectionRecordClient(c.config)
c.Inventory = NewInventoryClient(c.config)
c.InventoryLock = NewInventoryLockClient(c.config)
@@ -231,35 +235,36 @@ func (c *Client) Tx(ctx context.Context) (*Tx, error) {
cfg := c.config
cfg.driver = tx
return &Tx{
- ctx: ctx,
- config: cfg,
- Alert: NewAlertClient(cfg),
- AlertRule: NewAlertRuleClient(cfg),
- Attachment: NewAttachmentClient(cfg),
- BackupRecord: NewBackupRecordClient(cfg),
- DeliveryOrder: NewDeliveryOrderClient(cfg),
- DeliveryOrderItem: NewDeliveryOrderItemClient(cfg),
- EventLog: NewEventLogClient(cfg),
- InboundDetail: NewInboundDetailClient(cfg),
- InboundOrder: NewInboundOrderClient(cfg),
- InspectionRecord: NewInspectionRecordClient(cfg),
- Inventory: NewInventoryClient(cfg),
- InventoryLock: NewInventoryLockClient(cfg),
- Material: NewMaterialClient(cfg),
- MaterialDemand: NewMaterialDemandClient(cfg),
- OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
- OutboundDetail: NewOutboundDetailClient(cfg),
- OutboundOrder: NewOutboundOrderClient(cfg),
- Permission: NewPermissionClient(cfg),
- ReturnOrder: NewReturnOrderClient(cfg),
- Role: NewRoleClient(cfg),
- SemiFinished: NewSemiFinishedClient(cfg),
- StocktakeItem: NewStocktakeItemClient(cfg),
- StocktakeOrder: NewStocktakeOrderClient(cfg),
- SyncFailure: NewSyncFailureClient(cfg),
- SysConfig: NewSysConfigClient(cfg),
- User: NewUserClient(cfg),
- Zone: NewZoneClient(cfg),
+ ctx: ctx,
+ config: cfg,
+ Alert: NewAlertClient(cfg),
+ AlertRule: NewAlertRuleClient(cfg),
+ Attachment: NewAttachmentClient(cfg),
+ BackupRecord: NewBackupRecordClient(cfg),
+ DeliveryOrder: NewDeliveryOrderClient(cfg),
+ DeliveryOrderItem: NewDeliveryOrderItemClient(cfg),
+ EventLog: NewEventLogClient(cfg),
+ InboundDetail: NewInboundDetailClient(cfg),
+ InboundOrder: NewInboundOrderClient(cfg),
+ InspectionDisposalItem: NewInspectionDisposalItemClient(cfg),
+ InspectionRecord: NewInspectionRecordClient(cfg),
+ Inventory: NewInventoryClient(cfg),
+ InventoryLock: NewInventoryLockClient(cfg),
+ Material: NewMaterialClient(cfg),
+ MaterialDemand: NewMaterialDemandClient(cfg),
+ OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
+ OutboundDetail: NewOutboundDetailClient(cfg),
+ OutboundOrder: NewOutboundOrderClient(cfg),
+ Permission: NewPermissionClient(cfg),
+ ReturnOrder: NewReturnOrderClient(cfg),
+ Role: NewRoleClient(cfg),
+ SemiFinished: NewSemiFinishedClient(cfg),
+ StocktakeItem: NewStocktakeItemClient(cfg),
+ StocktakeOrder: NewStocktakeOrderClient(cfg),
+ SyncFailure: NewSyncFailureClient(cfg),
+ SysConfig: NewSysConfigClient(cfg),
+ User: NewUserClient(cfg),
+ Zone: NewZoneClient(cfg),
}, nil
}
@@ -277,35 +282,36 @@ func (c *Client) BeginTx(ctx context.Context, opts *sql.TxOptions) (*Tx, error)
cfg := c.config
cfg.driver = &txDriver{tx: tx, drv: c.driver}
return &Tx{
- ctx: ctx,
- config: cfg,
- Alert: NewAlertClient(cfg),
- AlertRule: NewAlertRuleClient(cfg),
- Attachment: NewAttachmentClient(cfg),
- BackupRecord: NewBackupRecordClient(cfg),
- DeliveryOrder: NewDeliveryOrderClient(cfg),
- DeliveryOrderItem: NewDeliveryOrderItemClient(cfg),
- EventLog: NewEventLogClient(cfg),
- InboundDetail: NewInboundDetailClient(cfg),
- InboundOrder: NewInboundOrderClient(cfg),
- InspectionRecord: NewInspectionRecordClient(cfg),
- Inventory: NewInventoryClient(cfg),
- InventoryLock: NewInventoryLockClient(cfg),
- Material: NewMaterialClient(cfg),
- MaterialDemand: NewMaterialDemandClient(cfg),
- OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
- OutboundDetail: NewOutboundDetailClient(cfg),
- OutboundOrder: NewOutboundOrderClient(cfg),
- Permission: NewPermissionClient(cfg),
- ReturnOrder: NewReturnOrderClient(cfg),
- Role: NewRoleClient(cfg),
- SemiFinished: NewSemiFinishedClient(cfg),
- StocktakeItem: NewStocktakeItemClient(cfg),
- StocktakeOrder: NewStocktakeOrderClient(cfg),
- SyncFailure: NewSyncFailureClient(cfg),
- SysConfig: NewSysConfigClient(cfg),
- User: NewUserClient(cfg),
- Zone: NewZoneClient(cfg),
+ ctx: ctx,
+ config: cfg,
+ Alert: NewAlertClient(cfg),
+ AlertRule: NewAlertRuleClient(cfg),
+ Attachment: NewAttachmentClient(cfg),
+ BackupRecord: NewBackupRecordClient(cfg),
+ DeliveryOrder: NewDeliveryOrderClient(cfg),
+ DeliveryOrderItem: NewDeliveryOrderItemClient(cfg),
+ EventLog: NewEventLogClient(cfg),
+ InboundDetail: NewInboundDetailClient(cfg),
+ InboundOrder: NewInboundOrderClient(cfg),
+ InspectionDisposalItem: NewInspectionDisposalItemClient(cfg),
+ InspectionRecord: NewInspectionRecordClient(cfg),
+ Inventory: NewInventoryClient(cfg),
+ InventoryLock: NewInventoryLockClient(cfg),
+ Material: NewMaterialClient(cfg),
+ MaterialDemand: NewMaterialDemandClient(cfg),
+ OrderMaterialLedger: NewOrderMaterialLedgerClient(cfg),
+ OutboundDetail: NewOutboundDetailClient(cfg),
+ OutboundOrder: NewOutboundOrderClient(cfg),
+ Permission: NewPermissionClient(cfg),
+ ReturnOrder: NewReturnOrderClient(cfg),
+ Role: NewRoleClient(cfg),
+ SemiFinished: NewSemiFinishedClient(cfg),
+ StocktakeItem: NewStocktakeItemClient(cfg),
+ StocktakeOrder: NewStocktakeOrderClient(cfg),
+ SyncFailure: NewSyncFailureClient(cfg),
+ SysConfig: NewSysConfigClient(cfg),
+ User: NewUserClient(cfg),
+ Zone: NewZoneClient(cfg),
}, nil
}
@@ -337,10 +343,10 @@ func (c *Client) Use(hooks ...Hook) {
for _, n := range []interface{ Use(...Hook) }{
c.Alert, c.AlertRule, c.Attachment, c.BackupRecord, c.DeliveryOrder,
c.DeliveryOrderItem, c.EventLog, c.InboundDetail, c.InboundOrder,
- c.InspectionRecord, c.Inventory, c.InventoryLock, c.Material, c.MaterialDemand,
- c.OrderMaterialLedger, c.OutboundDetail, c.OutboundOrder, c.Permission,
- c.ReturnOrder, c.Role, c.SemiFinished, c.StocktakeItem, c.StocktakeOrder,
- c.SyncFailure, c.SysConfig, c.User, c.Zone,
+ c.InspectionDisposalItem, c.InspectionRecord, c.Inventory, c.InventoryLock,
+ c.Material, c.MaterialDemand, c.OrderMaterialLedger, c.OutboundDetail,
+ c.OutboundOrder, c.Permission, c.ReturnOrder, c.Role, c.SemiFinished,
+ c.StocktakeItem, c.StocktakeOrder, c.SyncFailure, c.SysConfig, c.User, c.Zone,
} {
n.Use(hooks...)
}
@@ -352,10 +358,10 @@ func (c *Client) Intercept(interceptors ...Interceptor) {
for _, n := range []interface{ Intercept(...Interceptor) }{
c.Alert, c.AlertRule, c.Attachment, c.BackupRecord, c.DeliveryOrder,
c.DeliveryOrderItem, c.EventLog, c.InboundDetail, c.InboundOrder,
- c.InspectionRecord, c.Inventory, c.InventoryLock, c.Material, c.MaterialDemand,
- c.OrderMaterialLedger, c.OutboundDetail, c.OutboundOrder, c.Permission,
- c.ReturnOrder, c.Role, c.SemiFinished, c.StocktakeItem, c.StocktakeOrder,
- c.SyncFailure, c.SysConfig, c.User, c.Zone,
+ c.InspectionDisposalItem, c.InspectionRecord, c.Inventory, c.InventoryLock,
+ c.Material, c.MaterialDemand, c.OrderMaterialLedger, c.OutboundDetail,
+ c.OutboundOrder, c.Permission, c.ReturnOrder, c.Role, c.SemiFinished,
+ c.StocktakeItem, c.StocktakeOrder, c.SyncFailure, c.SysConfig, c.User, c.Zone,
} {
n.Intercept(interceptors...)
}
@@ -382,6 +388,8 @@ func (c *Client) Mutate(ctx context.Context, m Mutation) (Value, error) {
return c.InboundDetail.mutate(ctx, m)
case *InboundOrderMutation:
return c.InboundOrder.mutate(ctx, m)
+ case *InspectionDisposalItemMutation:
+ return c.InspectionDisposalItem.mutate(ctx, m)
case *InspectionRecordMutation:
return c.InspectionRecord.mutate(ctx, m)
case *InventoryMutation:
@@ -1620,6 +1628,139 @@ func (c *InboundOrderClient) mutate(ctx context.Context, m *InboundOrderMutation
}
}
+// InspectionDisposalItemClient is a client for the InspectionDisposalItem schema.
+type InspectionDisposalItemClient struct {
+ config
+}
+
+// NewInspectionDisposalItemClient returns a client for the InspectionDisposalItem from the given config.
+func NewInspectionDisposalItemClient(c config) *InspectionDisposalItemClient {
+ return &InspectionDisposalItemClient{config: c}
+}
+
+// Use adds a list of mutation hooks to the hooks stack.
+// A call to `Use(f, g, h)` equals to `inspectiondisposalitem.Hooks(f(g(h())))`.
+func (c *InspectionDisposalItemClient) Use(hooks ...Hook) {
+ c.hooks.InspectionDisposalItem = append(c.hooks.InspectionDisposalItem, hooks...)
+}
+
+// Intercept adds a list of query interceptors to the interceptors stack.
+// A call to `Intercept(f, g, h)` equals to `inspectiondisposalitem.Intercept(f(g(h())))`.
+func (c *InspectionDisposalItemClient) Intercept(interceptors ...Interceptor) {
+ c.inters.InspectionDisposalItem = append(c.inters.InspectionDisposalItem, interceptors...)
+}
+
+// Create returns a builder for creating a InspectionDisposalItem entity.
+func (c *InspectionDisposalItemClient) Create() *InspectionDisposalItemCreate {
+ mutation := newInspectionDisposalItemMutation(c.config, OpCreate)
+ return &InspectionDisposalItemCreate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// CreateBulk returns a builder for creating a bulk of InspectionDisposalItem entities.
+func (c *InspectionDisposalItemClient) CreateBulk(builders ...*InspectionDisposalItemCreate) *InspectionDisposalItemCreateBulk {
+ return &InspectionDisposalItemCreateBulk{config: c.config, builders: builders}
+}
+
+// MapCreateBulk creates a bulk creation builder from the given slice. For each item in the slice, the function creates
+// a builder and applies setFunc on it.
+func (c *InspectionDisposalItemClient) MapCreateBulk(slice any, setFunc func(*InspectionDisposalItemCreate, int)) *InspectionDisposalItemCreateBulk {
+ rv := reflect.ValueOf(slice)
+ if rv.Kind() != reflect.Slice {
+ return &InspectionDisposalItemCreateBulk{err: fmt.Errorf("calling to InspectionDisposalItemClient.MapCreateBulk with wrong type %T, need slice", slice)}
+ }
+ builders := make([]*InspectionDisposalItemCreate, rv.Len())
+ for i := 0; i < rv.Len(); i++ {
+ builders[i] = c.Create()
+ setFunc(builders[i], i)
+ }
+ return &InspectionDisposalItemCreateBulk{config: c.config, builders: builders}
+}
+
+// Update returns an update builder for InspectionDisposalItem.
+func (c *InspectionDisposalItemClient) Update() *InspectionDisposalItemUpdate {
+ mutation := newInspectionDisposalItemMutation(c.config, OpUpdate)
+ return &InspectionDisposalItemUpdate{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOne returns an update builder for the given entity.
+func (c *InspectionDisposalItemClient) UpdateOne(_m *InspectionDisposalItem) *InspectionDisposalItemUpdateOne {
+ mutation := newInspectionDisposalItemMutation(c.config, OpUpdateOne, withInspectionDisposalItem(_m))
+ return &InspectionDisposalItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// UpdateOneID returns an update builder for the given id.
+func (c *InspectionDisposalItemClient) UpdateOneID(id int) *InspectionDisposalItemUpdateOne {
+ mutation := newInspectionDisposalItemMutation(c.config, OpUpdateOne, withInspectionDisposalItemID(id))
+ return &InspectionDisposalItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// Delete returns a delete builder for InspectionDisposalItem.
+func (c *InspectionDisposalItemClient) Delete() *InspectionDisposalItemDelete {
+ mutation := newInspectionDisposalItemMutation(c.config, OpDelete)
+ return &InspectionDisposalItemDelete{config: c.config, hooks: c.Hooks(), mutation: mutation}
+}
+
+// DeleteOne returns a builder for deleting the given entity.
+func (c *InspectionDisposalItemClient) DeleteOne(_m *InspectionDisposalItem) *InspectionDisposalItemDeleteOne {
+ return c.DeleteOneID(_m.ID)
+}
+
+// DeleteOneID returns a builder for deleting the given entity by its id.
+func (c *InspectionDisposalItemClient) DeleteOneID(id int) *InspectionDisposalItemDeleteOne {
+ builder := c.Delete().Where(inspectiondisposalitem.ID(id))
+ builder.mutation.id = &id
+ builder.mutation.op = OpDeleteOne
+ return &InspectionDisposalItemDeleteOne{builder}
+}
+
+// Query returns a query builder for InspectionDisposalItem.
+func (c *InspectionDisposalItemClient) Query() *InspectionDisposalItemQuery {
+ return &InspectionDisposalItemQuery{
+ config: c.config,
+ ctx: &QueryContext{Type: TypeInspectionDisposalItem},
+ inters: c.Interceptors(),
+ }
+}
+
+// Get returns a InspectionDisposalItem entity by its id.
+func (c *InspectionDisposalItemClient) Get(ctx context.Context, id int) (*InspectionDisposalItem, error) {
+ return c.Query().Where(inspectiondisposalitem.ID(id)).Only(ctx)
+}
+
+// GetX is like Get, but panics if an error occurs.
+func (c *InspectionDisposalItemClient) GetX(ctx context.Context, id int) *InspectionDisposalItem {
+ obj, err := c.Get(ctx, id)
+ if err != nil {
+ panic(err)
+ }
+ return obj
+}
+
+// Hooks returns the client hooks.
+func (c *InspectionDisposalItemClient) Hooks() []Hook {
+ return c.hooks.InspectionDisposalItem
+}
+
+// Interceptors returns the client interceptors.
+func (c *InspectionDisposalItemClient) Interceptors() []Interceptor {
+ return c.inters.InspectionDisposalItem
+}
+
+func (c *InspectionDisposalItemClient) mutate(ctx context.Context, m *InspectionDisposalItemMutation) (Value, error) {
+ switch m.Op() {
+ case OpCreate:
+ return (&InspectionDisposalItemCreate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpUpdate:
+ return (&InspectionDisposalItemUpdate{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpUpdateOne:
+ return (&InspectionDisposalItemUpdateOne{config: c.config, hooks: c.Hooks(), mutation: m}).Save(ctx)
+ case OpDelete, OpDeleteOne:
+ return (&InspectionDisposalItemDelete{config: c.config, hooks: c.Hooks(), mutation: m}).Exec(ctx)
+ default:
+ return nil, fmt.Errorf("ent: unknown InspectionDisposalItem mutation op: %q", m.Op())
+ }
+}
+
// InspectionRecordClient is a client for the InspectionRecord schema.
type InspectionRecordClient struct {
config
@@ -4018,16 +4159,18 @@ func (c *ZoneClient) mutate(ctx context.Context, m *ZoneMutation) (Value, error)
type (
hooks struct {
Alert, AlertRule, Attachment, BackupRecord, DeliveryOrder, DeliveryOrderItem,
- EventLog, InboundDetail, InboundOrder, InspectionRecord, Inventory,
- InventoryLock, Material, MaterialDemand, OrderMaterialLedger, OutboundDetail,
- OutboundOrder, Permission, ReturnOrder, Role, SemiFinished, StocktakeItem,
- StocktakeOrder, SyncFailure, SysConfig, User, Zone []ent.Hook
+ EventLog, InboundDetail, InboundOrder, InspectionDisposalItem,
+ InspectionRecord, Inventory, InventoryLock, Material, MaterialDemand,
+ OrderMaterialLedger, OutboundDetail, OutboundOrder, Permission, ReturnOrder,
+ Role, SemiFinished, StocktakeItem, StocktakeOrder, SyncFailure, SysConfig,
+ User, Zone []ent.Hook
}
inters struct {
Alert, AlertRule, Attachment, BackupRecord, DeliveryOrder, DeliveryOrderItem,
- EventLog, InboundDetail, InboundOrder, InspectionRecord, Inventory,
- InventoryLock, Material, MaterialDemand, OrderMaterialLedger, OutboundDetail,
- OutboundOrder, Permission, ReturnOrder, Role, SemiFinished, StocktakeItem,
- StocktakeOrder, SyncFailure, SysConfig, User, Zone []ent.Interceptor
+ EventLog, InboundDetail, InboundOrder, InspectionDisposalItem,
+ InspectionRecord, Inventory, InventoryLock, Material, MaterialDemand,
+ OrderMaterialLedger, OutboundDetail, OutboundOrder, Permission, ReturnOrder,
+ Role, SemiFinished, StocktakeItem, StocktakeOrder, SyncFailure, SysConfig,
+ User, Zone []ent.Interceptor
}
)
diff --git a/bj_power_wms/ent/ent.go b/bj_power_wms/ent/ent.go
index 22772bf..a41ed63 100644
--- a/bj_power_wms/ent/ent.go
+++ b/bj_power_wms/ent/ent.go
@@ -12,6 +12,7 @@ import (
"bj_power_wms/ent/eventlog"
"bj_power_wms/ent/inbounddetail"
"bj_power_wms/ent/inboundorder"
+ "bj_power_wms/ent/inspectiondisposalitem"
"bj_power_wms/ent/inspectionrecord"
"bj_power_wms/ent/inventory"
"bj_power_wms/ent/inventorylock"
@@ -99,33 +100,34 @@ var (
func checkColumn(t, c string) error {
initCheck.Do(func() {
columnCheck = sql.NewColumnCheck(map[string]func(string) bool{
- alert.Table: alert.ValidColumn,
- alertrule.Table: alertrule.ValidColumn,
- attachment.Table: attachment.ValidColumn,
- backuprecord.Table: backuprecord.ValidColumn,
- deliveryorder.Table: deliveryorder.ValidColumn,
- deliveryorderitem.Table: deliveryorderitem.ValidColumn,
- eventlog.Table: eventlog.ValidColumn,
- inbounddetail.Table: inbounddetail.ValidColumn,
- inboundorder.Table: inboundorder.ValidColumn,
- inspectionrecord.Table: inspectionrecord.ValidColumn,
- inventory.Table: inventory.ValidColumn,
- inventorylock.Table: inventorylock.ValidColumn,
- material.Table: material.ValidColumn,
- materialdemand.Table: materialdemand.ValidColumn,
- ordermaterialledger.Table: ordermaterialledger.ValidColumn,
- outbounddetail.Table: outbounddetail.ValidColumn,
- outboundorder.Table: outboundorder.ValidColumn,
- permission.Table: permission.ValidColumn,
- returnorder.Table: returnorder.ValidColumn,
- role.Table: role.ValidColumn,
- semifinished.Table: semifinished.ValidColumn,
- stocktakeitem.Table: stocktakeitem.ValidColumn,
- stocktakeorder.Table: stocktakeorder.ValidColumn,
- syncfailure.Table: syncfailure.ValidColumn,
- sysconfig.Table: sysconfig.ValidColumn,
- user.Table: user.ValidColumn,
- zone.Table: zone.ValidColumn,
+ alert.Table: alert.ValidColumn,
+ alertrule.Table: alertrule.ValidColumn,
+ attachment.Table: attachment.ValidColumn,
+ backuprecord.Table: backuprecord.ValidColumn,
+ deliveryorder.Table: deliveryorder.ValidColumn,
+ deliveryorderitem.Table: deliveryorderitem.ValidColumn,
+ eventlog.Table: eventlog.ValidColumn,
+ inbounddetail.Table: inbounddetail.ValidColumn,
+ inboundorder.Table: inboundorder.ValidColumn,
+ inspectiondisposalitem.Table: inspectiondisposalitem.ValidColumn,
+ inspectionrecord.Table: inspectionrecord.ValidColumn,
+ inventory.Table: inventory.ValidColumn,
+ inventorylock.Table: inventorylock.ValidColumn,
+ material.Table: material.ValidColumn,
+ materialdemand.Table: materialdemand.ValidColumn,
+ ordermaterialledger.Table: ordermaterialledger.ValidColumn,
+ outbounddetail.Table: outbounddetail.ValidColumn,
+ outboundorder.Table: outboundorder.ValidColumn,
+ permission.Table: permission.ValidColumn,
+ returnorder.Table: returnorder.ValidColumn,
+ role.Table: role.ValidColumn,
+ semifinished.Table: semifinished.ValidColumn,
+ stocktakeitem.Table: stocktakeitem.ValidColumn,
+ stocktakeorder.Table: stocktakeorder.ValidColumn,
+ syncfailure.Table: syncfailure.ValidColumn,
+ sysconfig.Table: sysconfig.ValidColumn,
+ user.Table: user.ValidColumn,
+ zone.Table: zone.ValidColumn,
})
})
return columnCheck(t, c)
diff --git a/bj_power_wms/ent/hook/hook.go b/bj_power_wms/ent/hook/hook.go
index 3df78f2..3ac4b7f 100644
--- a/bj_power_wms/ent/hook/hook.go
+++ b/bj_power_wms/ent/hook/hook.go
@@ -116,6 +116,18 @@ func (f InboundOrderFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value
return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.InboundOrderMutation", m)
}
+// The InspectionDisposalItemFunc type is an adapter to allow the use of ordinary
+// function as InspectionDisposalItem mutator.
+type InspectionDisposalItemFunc func(context.Context, *ent.InspectionDisposalItemMutation) (ent.Value, error)
+
+// Mutate calls f(ctx, m).
+func (f InspectionDisposalItemFunc) Mutate(ctx context.Context, m ent.Mutation) (ent.Value, error) {
+ if mv, ok := m.(*ent.InspectionDisposalItemMutation); ok {
+ return f(ctx, mv)
+ }
+ return nil, fmt.Errorf("unexpected mutation type %T. expect *ent.InspectionDisposalItemMutation", m)
+}
+
// The InspectionRecordFunc type is an adapter to allow the use of ordinary
// function as InspectionRecord mutator.
type InspectionRecordFunc func(context.Context, *ent.InspectionRecordMutation) (ent.Value, error)
diff --git a/bj_power_wms/ent/inspectiondisposalitem.go b/bj_power_wms/ent/inspectiondisposalitem.go
new file mode 100644
index 0000000..f8ae2e3
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem.go
@@ -0,0 +1,158 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "bj_power_wms/ent/inspectiondisposalitem"
+ "fmt"
+ "strings"
+
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/sql"
+)
+
+// InspectionDisposalItem 不合格品处置明细(按数量分退货/返修/报废)
+type InspectionDisposalItem struct {
+ config `json:"-"`
+ // ID of the ent.
+ ID int `json:"id,omitempty"`
+ // 父检验记录ID(inspection_records.id)
+ RecordID int64 `json:"recordId,omitempty"`
+ // 处置方式 RETURN/REWORK/SCRAP
+ DisposeType string `json:"disposeType,omitempty"`
+ // 本行处置数量(合计=记录不合格数)
+ Qty int `json:"qty,omitempty"`
+ // 处置备注(非必填;退货物流信息也填此处)
+ Remark string `json:"remark,omitempty"`
+ // 操作人
+ Operator string `json:"operator,omitempty"`
+ // CreatedAt holds the value of the "created_at" field.
+ CreatedAt int64 `json:"createdAt,omitempty"`
+ selectValues sql.SelectValues
+}
+
+// scanValues returns the types for scanning values from sql.Rows.
+func (*InspectionDisposalItem) scanValues(columns []string) ([]any, error) {
+ values := make([]any, len(columns))
+ for i := range columns {
+ switch columns[i] {
+ case inspectiondisposalitem.FieldID, inspectiondisposalitem.FieldRecordID, inspectiondisposalitem.FieldQty, inspectiondisposalitem.FieldCreatedAt:
+ values[i] = new(sql.NullInt64)
+ case inspectiondisposalitem.FieldDisposeType, inspectiondisposalitem.FieldRemark, inspectiondisposalitem.FieldOperator:
+ values[i] = new(sql.NullString)
+ default:
+ values[i] = new(sql.UnknownType)
+ }
+ }
+ return values, nil
+}
+
+// assignValues assigns the values that were returned from sql.Rows (after scanning)
+// to the InspectionDisposalItem fields.
+func (_m *InspectionDisposalItem) assignValues(columns []string, values []any) error {
+ if m, n := len(values), len(columns); m < n {
+ return fmt.Errorf("mismatch number of scan values: %d != %d", m, n)
+ }
+ for i := range columns {
+ switch columns[i] {
+ case inspectiondisposalitem.FieldID:
+ value, ok := values[i].(*sql.NullInt64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field id", value)
+ }
+ _m.ID = int(value.Int64)
+ case inspectiondisposalitem.FieldRecordID:
+ if value, ok := values[i].(*sql.NullInt64); !ok {
+ return fmt.Errorf("unexpected type %T for field record_id", values[i])
+ } else if value.Valid {
+ _m.RecordID = value.Int64
+ }
+ case inspectiondisposalitem.FieldDisposeType:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field dispose_type", values[i])
+ } else if value.Valid {
+ _m.DisposeType = value.String
+ }
+ case inspectiondisposalitem.FieldQty:
+ if value, ok := values[i].(*sql.NullInt64); !ok {
+ return fmt.Errorf("unexpected type %T for field qty", values[i])
+ } else if value.Valid {
+ _m.Qty = int(value.Int64)
+ }
+ case inspectiondisposalitem.FieldRemark:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field remark", values[i])
+ } else if value.Valid {
+ _m.Remark = value.String
+ }
+ case inspectiondisposalitem.FieldOperator:
+ if value, ok := values[i].(*sql.NullString); !ok {
+ return fmt.Errorf("unexpected type %T for field operator", values[i])
+ } else if value.Valid {
+ _m.Operator = value.String
+ }
+ case inspectiondisposalitem.FieldCreatedAt:
+ if value, ok := values[i].(*sql.NullInt64); !ok {
+ return fmt.Errorf("unexpected type %T for field created_at", values[i])
+ } else if value.Valid {
+ _m.CreatedAt = value.Int64
+ }
+ default:
+ _m.selectValues.Set(columns[i], values[i])
+ }
+ }
+ return nil
+}
+
+// Value returns the ent.Value that was dynamically selected and assigned to the InspectionDisposalItem.
+// This includes values selected through modifiers, order, etc.
+func (_m *InspectionDisposalItem) Value(name string) (ent.Value, error) {
+ return _m.selectValues.Get(name)
+}
+
+// Update returns a builder for updating this InspectionDisposalItem.
+// Note that you need to call InspectionDisposalItem.Unwrap() before calling this method if this InspectionDisposalItem
+// was returned from a transaction, and the transaction was committed or rolled back.
+func (_m *InspectionDisposalItem) Update() *InspectionDisposalItemUpdateOne {
+ return NewInspectionDisposalItemClient(_m.config).UpdateOne(_m)
+}
+
+// Unwrap unwraps the InspectionDisposalItem entity that was returned from a transaction after it was closed,
+// so that all future queries will be executed through the driver which created the transaction.
+func (_m *InspectionDisposalItem) Unwrap() *InspectionDisposalItem {
+ _tx, ok := _m.config.driver.(*txDriver)
+ if !ok {
+ panic("ent: InspectionDisposalItem is not a transactional entity")
+ }
+ _m.config.driver = _tx.drv
+ return _m
+}
+
+// String implements the fmt.Stringer.
+func (_m *InspectionDisposalItem) String() string {
+ var builder strings.Builder
+ builder.WriteString("InspectionDisposalItem(")
+ builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
+ builder.WriteString("record_id=")
+ builder.WriteString(fmt.Sprintf("%v", _m.RecordID))
+ builder.WriteString(", ")
+ builder.WriteString("dispose_type=")
+ builder.WriteString(_m.DisposeType)
+ builder.WriteString(", ")
+ builder.WriteString("qty=")
+ builder.WriteString(fmt.Sprintf("%v", _m.Qty))
+ builder.WriteString(", ")
+ builder.WriteString("remark=")
+ builder.WriteString(_m.Remark)
+ builder.WriteString(", ")
+ builder.WriteString("operator=")
+ builder.WriteString(_m.Operator)
+ builder.WriteString(", ")
+ builder.WriteString("created_at=")
+ builder.WriteString(fmt.Sprintf("%v", _m.CreatedAt))
+ builder.WriteByte(')')
+ return builder.String()
+}
+
+// InspectionDisposalItems is a parsable slice of InspectionDisposalItem.
+type InspectionDisposalItems []*InspectionDisposalItem
diff --git a/bj_power_wms/ent/inspectiondisposalitem/inspectiondisposalitem.go b/bj_power_wms/ent/inspectiondisposalitem/inspectiondisposalitem.go
new file mode 100644
index 0000000..b0c675d
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem/inspectiondisposalitem.go
@@ -0,0 +1,96 @@
+// Code generated by ent, DO NOT EDIT.
+
+package inspectiondisposalitem
+
+import (
+ "entgo.io/ent/dialect/sql"
+)
+
+const (
+ // Label holds the string label denoting the inspectiondisposalitem type in the database.
+ Label = "inspection_disposal_item"
+ // FieldID holds the string denoting the id field in the database.
+ FieldID = "id"
+ // FieldRecordID holds the string denoting the record_id field in the database.
+ FieldRecordID = "record_id"
+ // FieldDisposeType holds the string denoting the dispose_type field in the database.
+ FieldDisposeType = "dispose_type"
+ // FieldQty holds the string denoting the qty field in the database.
+ FieldQty = "qty"
+ // FieldRemark holds the string denoting the remark field in the database.
+ FieldRemark = "remark"
+ // FieldOperator holds the string denoting the operator field in the database.
+ FieldOperator = "operator"
+ // FieldCreatedAt holds the string denoting the created_at field in the database.
+ FieldCreatedAt = "created_at"
+ // Table holds the table name of the inspectiondisposalitem in the database.
+ Table = "inspection_disposal_items"
+)
+
+// Columns holds all SQL columns for inspectiondisposalitem fields.
+var Columns = []string{
+ FieldID,
+ FieldRecordID,
+ FieldDisposeType,
+ FieldQty,
+ FieldRemark,
+ FieldOperator,
+ FieldCreatedAt,
+}
+
+// ValidColumn reports if the column name is valid (part of the table columns).
+func ValidColumn(column string) bool {
+ for i := range Columns {
+ if column == Columns[i] {
+ return true
+ }
+ }
+ return false
+}
+
+var (
+ // QtyValidator is a validator for the "qty" field. It is called by the builders before save.
+ QtyValidator func(int) error
+ // DefaultOperator holds the default value on creation for the "operator" field.
+ DefaultOperator string
+ // DefaultCreatedAt holds the default value on creation for the "created_at" field.
+ DefaultCreatedAt func() int64
+)
+
+// OrderOption defines the ordering options for the InspectionDisposalItem queries.
+type OrderOption func(*sql.Selector)
+
+// ByID orders the results by the id field.
+func ByID(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldID, opts...).ToFunc()
+}
+
+// ByRecordID orders the results by the record_id field.
+func ByRecordID(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldRecordID, opts...).ToFunc()
+}
+
+// ByDisposeType orders the results by the dispose_type field.
+func ByDisposeType(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldDisposeType, opts...).ToFunc()
+}
+
+// ByQty orders the results by the qty field.
+func ByQty(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldQty, opts...).ToFunc()
+}
+
+// ByRemark orders the results by the remark field.
+func ByRemark(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldRemark, opts...).ToFunc()
+}
+
+// ByOperator orders the results by the operator field.
+func ByOperator(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldOperator, opts...).ToFunc()
+}
+
+// ByCreatedAt orders the results by the created_at field.
+func ByCreatedAt(opts ...sql.OrderTermOption) OrderOption {
+ return sql.OrderByField(FieldCreatedAt, opts...).ToFunc()
+}
diff --git a/bj_power_wms/ent/inspectiondisposalitem/where.go b/bj_power_wms/ent/inspectiondisposalitem/where.go
new file mode 100644
index 0000000..73763b0
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem/where.go
@@ -0,0 +1,424 @@
+// Code generated by ent, DO NOT EDIT.
+
+package inspectiondisposalitem
+
+import (
+ "bj_power_wms/ent/predicate"
+
+ "entgo.io/ent/dialect/sql"
+)
+
+// ID filters vertices based on their ID field.
+func ID(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldID, id))
+}
+
+// IDEQ applies the EQ predicate on the ID field.
+func IDEQ(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldID, id))
+}
+
+// IDNEQ applies the NEQ predicate on the ID field.
+func IDNEQ(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldID, id))
+}
+
+// IDIn applies the In predicate on the ID field.
+func IDIn(ids ...int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldID, ids...))
+}
+
+// IDNotIn applies the NotIn predicate on the ID field.
+func IDNotIn(ids ...int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldID, ids...))
+}
+
+// IDGT applies the GT predicate on the ID field.
+func IDGT(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldID, id))
+}
+
+// IDGTE applies the GTE predicate on the ID field.
+func IDGTE(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldID, id))
+}
+
+// IDLT applies the LT predicate on the ID field.
+func IDLT(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldID, id))
+}
+
+// IDLTE applies the LTE predicate on the ID field.
+func IDLTE(id int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldID, id))
+}
+
+// RecordID applies equality check predicate on the "record_id" field. It's identical to RecordIDEQ.
+func RecordID(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldRecordID, v))
+}
+
+// DisposeType applies equality check predicate on the "dispose_type" field. It's identical to DisposeTypeEQ.
+func DisposeType(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldDisposeType, v))
+}
+
+// Qty applies equality check predicate on the "qty" field. It's identical to QtyEQ.
+func Qty(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldQty, v))
+}
+
+// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ.
+func Remark(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldRemark, v))
+}
+
+// Operator applies equality check predicate on the "operator" field. It's identical to OperatorEQ.
+func Operator(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldOperator, v))
+}
+
+// CreatedAt applies equality check predicate on the "created_at" field. It's identical to CreatedAtEQ.
+func CreatedAt(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// RecordIDEQ applies the EQ predicate on the "record_id" field.
+func RecordIDEQ(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldRecordID, v))
+}
+
+// RecordIDNEQ applies the NEQ predicate on the "record_id" field.
+func RecordIDNEQ(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldRecordID, v))
+}
+
+// RecordIDIn applies the In predicate on the "record_id" field.
+func RecordIDIn(vs ...int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldRecordID, vs...))
+}
+
+// RecordIDNotIn applies the NotIn predicate on the "record_id" field.
+func RecordIDNotIn(vs ...int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldRecordID, vs...))
+}
+
+// RecordIDGT applies the GT predicate on the "record_id" field.
+func RecordIDGT(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldRecordID, v))
+}
+
+// RecordIDGTE applies the GTE predicate on the "record_id" field.
+func RecordIDGTE(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldRecordID, v))
+}
+
+// RecordIDLT applies the LT predicate on the "record_id" field.
+func RecordIDLT(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldRecordID, v))
+}
+
+// RecordIDLTE applies the LTE predicate on the "record_id" field.
+func RecordIDLTE(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldRecordID, v))
+}
+
+// DisposeTypeEQ applies the EQ predicate on the "dispose_type" field.
+func DisposeTypeEQ(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldDisposeType, v))
+}
+
+// DisposeTypeNEQ applies the NEQ predicate on the "dispose_type" field.
+func DisposeTypeNEQ(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldDisposeType, v))
+}
+
+// DisposeTypeIn applies the In predicate on the "dispose_type" field.
+func DisposeTypeIn(vs ...string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldDisposeType, vs...))
+}
+
+// DisposeTypeNotIn applies the NotIn predicate on the "dispose_type" field.
+func DisposeTypeNotIn(vs ...string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldDisposeType, vs...))
+}
+
+// DisposeTypeGT applies the GT predicate on the "dispose_type" field.
+func DisposeTypeGT(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldDisposeType, v))
+}
+
+// DisposeTypeGTE applies the GTE predicate on the "dispose_type" field.
+func DisposeTypeGTE(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldDisposeType, v))
+}
+
+// DisposeTypeLT applies the LT predicate on the "dispose_type" field.
+func DisposeTypeLT(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldDisposeType, v))
+}
+
+// DisposeTypeLTE applies the LTE predicate on the "dispose_type" field.
+func DisposeTypeLTE(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldDisposeType, v))
+}
+
+// DisposeTypeContains applies the Contains predicate on the "dispose_type" field.
+func DisposeTypeContains(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldContains(FieldDisposeType, v))
+}
+
+// DisposeTypeHasPrefix applies the HasPrefix predicate on the "dispose_type" field.
+func DisposeTypeHasPrefix(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldHasPrefix(FieldDisposeType, v))
+}
+
+// DisposeTypeHasSuffix applies the HasSuffix predicate on the "dispose_type" field.
+func DisposeTypeHasSuffix(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldHasSuffix(FieldDisposeType, v))
+}
+
+// DisposeTypeEqualFold applies the EqualFold predicate on the "dispose_type" field.
+func DisposeTypeEqualFold(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEqualFold(FieldDisposeType, v))
+}
+
+// DisposeTypeContainsFold applies the ContainsFold predicate on the "dispose_type" field.
+func DisposeTypeContainsFold(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldContainsFold(FieldDisposeType, v))
+}
+
+// QtyEQ applies the EQ predicate on the "qty" field.
+func QtyEQ(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldQty, v))
+}
+
+// QtyNEQ applies the NEQ predicate on the "qty" field.
+func QtyNEQ(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldQty, v))
+}
+
+// QtyIn applies the In predicate on the "qty" field.
+func QtyIn(vs ...int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldQty, vs...))
+}
+
+// QtyNotIn applies the NotIn predicate on the "qty" field.
+func QtyNotIn(vs ...int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldQty, vs...))
+}
+
+// QtyGT applies the GT predicate on the "qty" field.
+func QtyGT(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldQty, v))
+}
+
+// QtyGTE applies the GTE predicate on the "qty" field.
+func QtyGTE(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldQty, v))
+}
+
+// QtyLT applies the LT predicate on the "qty" field.
+func QtyLT(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldQty, v))
+}
+
+// QtyLTE applies the LTE predicate on the "qty" field.
+func QtyLTE(v int) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldQty, v))
+}
+
+// RemarkEQ applies the EQ predicate on the "remark" field.
+func RemarkEQ(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldRemark, v))
+}
+
+// RemarkNEQ applies the NEQ predicate on the "remark" field.
+func RemarkNEQ(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldRemark, v))
+}
+
+// RemarkIn applies the In predicate on the "remark" field.
+func RemarkIn(vs ...string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldRemark, vs...))
+}
+
+// RemarkNotIn applies the NotIn predicate on the "remark" field.
+func RemarkNotIn(vs ...string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldRemark, vs...))
+}
+
+// RemarkGT applies the GT predicate on the "remark" field.
+func RemarkGT(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldRemark, v))
+}
+
+// RemarkGTE applies the GTE predicate on the "remark" field.
+func RemarkGTE(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldRemark, v))
+}
+
+// RemarkLT applies the LT predicate on the "remark" field.
+func RemarkLT(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldRemark, v))
+}
+
+// RemarkLTE applies the LTE predicate on the "remark" field.
+func RemarkLTE(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldRemark, v))
+}
+
+// RemarkContains applies the Contains predicate on the "remark" field.
+func RemarkContains(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldContains(FieldRemark, v))
+}
+
+// RemarkHasPrefix applies the HasPrefix predicate on the "remark" field.
+func RemarkHasPrefix(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldHasPrefix(FieldRemark, v))
+}
+
+// RemarkHasSuffix applies the HasSuffix predicate on the "remark" field.
+func RemarkHasSuffix(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldHasSuffix(FieldRemark, v))
+}
+
+// RemarkIsNil applies the IsNil predicate on the "remark" field.
+func RemarkIsNil() predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIsNull(FieldRemark))
+}
+
+// RemarkNotNil applies the NotNil predicate on the "remark" field.
+func RemarkNotNil() predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotNull(FieldRemark))
+}
+
+// RemarkEqualFold applies the EqualFold predicate on the "remark" field.
+func RemarkEqualFold(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEqualFold(FieldRemark, v))
+}
+
+// RemarkContainsFold applies the ContainsFold predicate on the "remark" field.
+func RemarkContainsFold(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldContainsFold(FieldRemark, v))
+}
+
+// OperatorEQ applies the EQ predicate on the "operator" field.
+func OperatorEQ(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldOperator, v))
+}
+
+// OperatorNEQ applies the NEQ predicate on the "operator" field.
+func OperatorNEQ(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldOperator, v))
+}
+
+// OperatorIn applies the In predicate on the "operator" field.
+func OperatorIn(vs ...string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldOperator, vs...))
+}
+
+// OperatorNotIn applies the NotIn predicate on the "operator" field.
+func OperatorNotIn(vs ...string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldOperator, vs...))
+}
+
+// OperatorGT applies the GT predicate on the "operator" field.
+func OperatorGT(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldOperator, v))
+}
+
+// OperatorGTE applies the GTE predicate on the "operator" field.
+func OperatorGTE(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldOperator, v))
+}
+
+// OperatorLT applies the LT predicate on the "operator" field.
+func OperatorLT(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldOperator, v))
+}
+
+// OperatorLTE applies the LTE predicate on the "operator" field.
+func OperatorLTE(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldOperator, v))
+}
+
+// OperatorContains applies the Contains predicate on the "operator" field.
+func OperatorContains(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldContains(FieldOperator, v))
+}
+
+// OperatorHasPrefix applies the HasPrefix predicate on the "operator" field.
+func OperatorHasPrefix(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldHasPrefix(FieldOperator, v))
+}
+
+// OperatorHasSuffix applies the HasSuffix predicate on the "operator" field.
+func OperatorHasSuffix(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldHasSuffix(FieldOperator, v))
+}
+
+// OperatorEqualFold applies the EqualFold predicate on the "operator" field.
+func OperatorEqualFold(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEqualFold(FieldOperator, v))
+}
+
+// OperatorContainsFold applies the ContainsFold predicate on the "operator" field.
+func OperatorContainsFold(v string) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldContainsFold(FieldOperator, v))
+}
+
+// CreatedAtEQ applies the EQ predicate on the "created_at" field.
+func CreatedAtEQ(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtNEQ applies the NEQ predicate on the "created_at" field.
+func CreatedAtNEQ(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNEQ(FieldCreatedAt, v))
+}
+
+// CreatedAtIn applies the In predicate on the "created_at" field.
+func CreatedAtIn(vs ...int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtNotIn applies the NotIn predicate on the "created_at" field.
+func CreatedAtNotIn(vs ...int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldNotIn(FieldCreatedAt, vs...))
+}
+
+// CreatedAtGT applies the GT predicate on the "created_at" field.
+func CreatedAtGT(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGT(FieldCreatedAt, v))
+}
+
+// CreatedAtGTE applies the GTE predicate on the "created_at" field.
+func CreatedAtGTE(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldGTE(FieldCreatedAt, v))
+}
+
+// CreatedAtLT applies the LT predicate on the "created_at" field.
+func CreatedAtLT(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLT(FieldCreatedAt, v))
+}
+
+// CreatedAtLTE applies the LTE predicate on the "created_at" field.
+func CreatedAtLTE(v int64) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.FieldLTE(FieldCreatedAt, v))
+}
+
+// And groups predicates with the AND operator between them.
+func And(predicates ...predicate.InspectionDisposalItem) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.AndPredicates(predicates...))
+}
+
+// Or groups predicates with the OR operator between them.
+func Or(predicates ...predicate.InspectionDisposalItem) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.OrPredicates(predicates...))
+}
+
+// Not applies the not operator on the given predicate.
+func Not(p predicate.InspectionDisposalItem) predicate.InspectionDisposalItem {
+ return predicate.InspectionDisposalItem(sql.NotPredicates(p))
+}
diff --git a/bj_power_wms/ent/inspectiondisposalitem_create.go b/bj_power_wms/ent/inspectiondisposalitem_create.go
new file mode 100644
index 0000000..4203b46
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem_create.go
@@ -0,0 +1,839 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "bj_power_wms/ent/inspectiondisposalitem"
+ "context"
+ "errors"
+ "fmt"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+)
+
+// InspectionDisposalItemCreate is the builder for creating a InspectionDisposalItem entity.
+type InspectionDisposalItemCreate struct {
+ config
+ mutation *InspectionDisposalItemMutation
+ hooks []Hook
+ conflict []sql.ConflictOption
+}
+
+// SetRecordID sets the "record_id" field.
+func (_c *InspectionDisposalItemCreate) SetRecordID(v int64) *InspectionDisposalItemCreate {
+ _c.mutation.SetRecordID(v)
+ return _c
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (_c *InspectionDisposalItemCreate) SetDisposeType(v string) *InspectionDisposalItemCreate {
+ _c.mutation.SetDisposeType(v)
+ return _c
+}
+
+// SetQty sets the "qty" field.
+func (_c *InspectionDisposalItemCreate) SetQty(v int) *InspectionDisposalItemCreate {
+ _c.mutation.SetQty(v)
+ return _c
+}
+
+// SetRemark sets the "remark" field.
+func (_c *InspectionDisposalItemCreate) SetRemark(v string) *InspectionDisposalItemCreate {
+ _c.mutation.SetRemark(v)
+ return _c
+}
+
+// SetNillableRemark sets the "remark" field if the given value is not nil.
+func (_c *InspectionDisposalItemCreate) SetNillableRemark(v *string) *InspectionDisposalItemCreate {
+ if v != nil {
+ _c.SetRemark(*v)
+ }
+ return _c
+}
+
+// SetOperator sets the "operator" field.
+func (_c *InspectionDisposalItemCreate) SetOperator(v string) *InspectionDisposalItemCreate {
+ _c.mutation.SetOperator(v)
+ return _c
+}
+
+// SetNillableOperator sets the "operator" field if the given value is not nil.
+func (_c *InspectionDisposalItemCreate) SetNillableOperator(v *string) *InspectionDisposalItemCreate {
+ if v != nil {
+ _c.SetOperator(*v)
+ }
+ return _c
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (_c *InspectionDisposalItemCreate) SetCreatedAt(v int64) *InspectionDisposalItemCreate {
+ _c.mutation.SetCreatedAt(v)
+ return _c
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (_c *InspectionDisposalItemCreate) SetNillableCreatedAt(v *int64) *InspectionDisposalItemCreate {
+ if v != nil {
+ _c.SetCreatedAt(*v)
+ }
+ return _c
+}
+
+// Mutation returns the InspectionDisposalItemMutation object of the builder.
+func (_c *InspectionDisposalItemCreate) Mutation() *InspectionDisposalItemMutation {
+ return _c.mutation
+}
+
+// Save creates the InspectionDisposalItem in the database.
+func (_c *InspectionDisposalItemCreate) Save(ctx context.Context) (*InspectionDisposalItem, error) {
+ _c.defaults()
+ return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
+}
+
+// SaveX calls Save and panics if Save returns an error.
+func (_c *InspectionDisposalItemCreate) SaveX(ctx context.Context) *InspectionDisposalItem {
+ v, err := _c.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Exec executes the query.
+func (_c *InspectionDisposalItemCreate) Exec(ctx context.Context) error {
+ _, err := _c.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_c *InspectionDisposalItemCreate) ExecX(ctx context.Context) {
+ if err := _c.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// defaults sets the default values of the builder before save.
+func (_c *InspectionDisposalItemCreate) defaults() {
+ if _, ok := _c.mutation.Operator(); !ok {
+ v := inspectiondisposalitem.DefaultOperator
+ _c.mutation.SetOperator(v)
+ }
+ if _, ok := _c.mutation.CreatedAt(); !ok {
+ v := inspectiondisposalitem.DefaultCreatedAt()
+ _c.mutation.SetCreatedAt(v)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_c *InspectionDisposalItemCreate) check() error {
+ if _, ok := _c.mutation.RecordID(); !ok {
+ return &ValidationError{Name: "record_id", err: errors.New(`ent: missing required field "InspectionDisposalItem.record_id"`)}
+ }
+ if _, ok := _c.mutation.DisposeType(); !ok {
+ return &ValidationError{Name: "dispose_type", err: errors.New(`ent: missing required field "InspectionDisposalItem.dispose_type"`)}
+ }
+ if _, ok := _c.mutation.Qty(); !ok {
+ return &ValidationError{Name: "qty", err: errors.New(`ent: missing required field "InspectionDisposalItem.qty"`)}
+ }
+ if v, ok := _c.mutation.Qty(); ok {
+ if err := inspectiondisposalitem.QtyValidator(v); err != nil {
+ return &ValidationError{Name: "qty", err: fmt.Errorf(`ent: validator failed for field "InspectionDisposalItem.qty": %w`, err)}
+ }
+ }
+ if _, ok := _c.mutation.Operator(); !ok {
+ return &ValidationError{Name: "operator", err: errors.New(`ent: missing required field "InspectionDisposalItem.operator"`)}
+ }
+ if _, ok := _c.mutation.CreatedAt(); !ok {
+ return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "InspectionDisposalItem.created_at"`)}
+ }
+ return nil
+}
+
+func (_c *InspectionDisposalItemCreate) sqlSave(ctx context.Context) (*InspectionDisposalItem, error) {
+ if err := _c.check(); err != nil {
+ return nil, err
+ }
+ _node, _spec := _c.createSpec()
+ if err := sqlgraph.CreateNode(ctx, _c.driver, _spec); err != nil {
+ if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return nil, err
+ }
+ id := _spec.ID.Value.(int64)
+ _node.ID = int(id)
+ _c.mutation.id = &_node.ID
+ _c.mutation.done = true
+ return _node, nil
+}
+
+func (_c *InspectionDisposalItemCreate) createSpec() (*InspectionDisposalItem, *sqlgraph.CreateSpec) {
+ var (
+ _node = &InspectionDisposalItem{config: _c.config}
+ _spec = sqlgraph.NewCreateSpec(inspectiondisposalitem.Table, sqlgraph.NewFieldSpec(inspectiondisposalitem.FieldID, field.TypeInt))
+ )
+ _spec.OnConflict = _c.conflict
+ if value, ok := _c.mutation.RecordID(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
+ _node.RecordID = value
+ }
+ if value, ok := _c.mutation.DisposeType(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldDisposeType, field.TypeString, value)
+ _node.DisposeType = value
+ }
+ if value, ok := _c.mutation.Qty(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
+ _node.Qty = value
+ }
+ if value, ok := _c.mutation.Remark(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldRemark, field.TypeString, value)
+ _node.Remark = value
+ }
+ if value, ok := _c.mutation.Operator(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldOperator, field.TypeString, value)
+ _node.Operator = value
+ }
+ if value, ok := _c.mutation.CreatedAt(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
+ _node.CreatedAt = value
+ }
+ return _node, _spec
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+// client.InspectionDisposalItem.Create().
+// SetRecordID(v).
+// OnConflict(
+// // Update the row with the new values
+// // the was proposed for insertion.
+// sql.ResolveWithNewValues(),
+// ).
+// // Override some of the fields with custom
+// // update values.
+// Update(func(u *ent.InspectionDisposalItemUpsert) {
+// SetRecordID(v+v).
+// }).
+// Exec(ctx)
+func (_c *InspectionDisposalItemCreate) OnConflict(opts ...sql.ConflictOption) *InspectionDisposalItemUpsertOne {
+ _c.conflict = opts
+ return &InspectionDisposalItemUpsertOne{
+ create: _c,
+ }
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+// client.InspectionDisposalItem.Create().
+// OnConflict(sql.ConflictColumns(columns...)).
+// Exec(ctx)
+func (_c *InspectionDisposalItemCreate) OnConflictColumns(columns ...string) *InspectionDisposalItemUpsertOne {
+ _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
+ return &InspectionDisposalItemUpsertOne{
+ create: _c,
+ }
+}
+
+type (
+ // InspectionDisposalItemUpsertOne is the builder for "upsert"-ing
+ // one InspectionDisposalItem node.
+ InspectionDisposalItemUpsertOne struct {
+ create *InspectionDisposalItemCreate
+ }
+
+ // InspectionDisposalItemUpsert is the "OnConflict" setter.
+ InspectionDisposalItemUpsert struct {
+ *sql.UpdateSet
+ }
+)
+
+// SetRecordID sets the "record_id" field.
+func (u *InspectionDisposalItemUpsert) SetRecordID(v int64) *InspectionDisposalItemUpsert {
+ u.Set(inspectiondisposalitem.FieldRecordID, v)
+ return u
+}
+
+// UpdateRecordID sets the "record_id" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsert) UpdateRecordID() *InspectionDisposalItemUpsert {
+ u.SetExcluded(inspectiondisposalitem.FieldRecordID)
+ return u
+}
+
+// AddRecordID adds v to the "record_id" field.
+func (u *InspectionDisposalItemUpsert) AddRecordID(v int64) *InspectionDisposalItemUpsert {
+ u.Add(inspectiondisposalitem.FieldRecordID, v)
+ return u
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (u *InspectionDisposalItemUpsert) SetDisposeType(v string) *InspectionDisposalItemUpsert {
+ u.Set(inspectiondisposalitem.FieldDisposeType, v)
+ return u
+}
+
+// UpdateDisposeType sets the "dispose_type" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsert) UpdateDisposeType() *InspectionDisposalItemUpsert {
+ u.SetExcluded(inspectiondisposalitem.FieldDisposeType)
+ return u
+}
+
+// SetQty sets the "qty" field.
+func (u *InspectionDisposalItemUpsert) SetQty(v int) *InspectionDisposalItemUpsert {
+ u.Set(inspectiondisposalitem.FieldQty, v)
+ return u
+}
+
+// UpdateQty sets the "qty" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsert) UpdateQty() *InspectionDisposalItemUpsert {
+ u.SetExcluded(inspectiondisposalitem.FieldQty)
+ return u
+}
+
+// AddQty adds v to the "qty" field.
+func (u *InspectionDisposalItemUpsert) AddQty(v int) *InspectionDisposalItemUpsert {
+ u.Add(inspectiondisposalitem.FieldQty, v)
+ return u
+}
+
+// SetRemark sets the "remark" field.
+func (u *InspectionDisposalItemUpsert) SetRemark(v string) *InspectionDisposalItemUpsert {
+ u.Set(inspectiondisposalitem.FieldRemark, v)
+ return u
+}
+
+// UpdateRemark sets the "remark" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsert) UpdateRemark() *InspectionDisposalItemUpsert {
+ u.SetExcluded(inspectiondisposalitem.FieldRemark)
+ return u
+}
+
+// ClearRemark clears the value of the "remark" field.
+func (u *InspectionDisposalItemUpsert) ClearRemark() *InspectionDisposalItemUpsert {
+ u.SetNull(inspectiondisposalitem.FieldRemark)
+ return u
+}
+
+// SetOperator sets the "operator" field.
+func (u *InspectionDisposalItemUpsert) SetOperator(v string) *InspectionDisposalItemUpsert {
+ u.Set(inspectiondisposalitem.FieldOperator, v)
+ return u
+}
+
+// UpdateOperator sets the "operator" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsert) UpdateOperator() *InspectionDisposalItemUpsert {
+ u.SetExcluded(inspectiondisposalitem.FieldOperator)
+ return u
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (u *InspectionDisposalItemUpsert) SetCreatedAt(v int64) *InspectionDisposalItemUpsert {
+ u.Set(inspectiondisposalitem.FieldCreatedAt, v)
+ return u
+}
+
+// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsert) UpdateCreatedAt() *InspectionDisposalItemUpsert {
+ u.SetExcluded(inspectiondisposalitem.FieldCreatedAt)
+ return u
+}
+
+// AddCreatedAt adds v to the "created_at" field.
+func (u *InspectionDisposalItemUpsert) AddCreatedAt(v int64) *InspectionDisposalItemUpsert {
+ u.Add(inspectiondisposalitem.FieldCreatedAt, v)
+ return u
+}
+
+// UpdateNewValues updates the mutable fields using the new values that were set on create.
+// Using this option is equivalent to using:
+//
+// client.InspectionDisposalItem.Create().
+// OnConflict(
+// sql.ResolveWithNewValues(),
+// ).
+// Exec(ctx)
+func (u *InspectionDisposalItemUpsertOne) UpdateNewValues() *InspectionDisposalItemUpsertOne {
+ u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+ return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+// client.InspectionDisposalItem.Create().
+// OnConflict(sql.ResolveWithIgnore()).
+// Exec(ctx)
+func (u *InspectionDisposalItemUpsertOne) Ignore() *InspectionDisposalItemUpsertOne {
+ u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+ return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *InspectionDisposalItemUpsertOne) DoNothing() *InspectionDisposalItemUpsertOne {
+ u.create.conflict = append(u.create.conflict, sql.DoNothing())
+ return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the InspectionDisposalItemCreate.OnConflict
+// documentation for more info.
+func (u *InspectionDisposalItemUpsertOne) Update(set func(*InspectionDisposalItemUpsert)) *InspectionDisposalItemUpsertOne {
+ u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+ set(&InspectionDisposalItemUpsert{UpdateSet: update})
+ }))
+ return u
+}
+
+// SetRecordID sets the "record_id" field.
+func (u *InspectionDisposalItemUpsertOne) SetRecordID(v int64) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetRecordID(v)
+ })
+}
+
+// AddRecordID adds v to the "record_id" field.
+func (u *InspectionDisposalItemUpsertOne) AddRecordID(v int64) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.AddRecordID(v)
+ })
+}
+
+// UpdateRecordID sets the "record_id" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertOne) UpdateRecordID() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateRecordID()
+ })
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (u *InspectionDisposalItemUpsertOne) SetDisposeType(v string) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetDisposeType(v)
+ })
+}
+
+// UpdateDisposeType sets the "dispose_type" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertOne) UpdateDisposeType() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateDisposeType()
+ })
+}
+
+// SetQty sets the "qty" field.
+func (u *InspectionDisposalItemUpsertOne) SetQty(v int) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetQty(v)
+ })
+}
+
+// AddQty adds v to the "qty" field.
+func (u *InspectionDisposalItemUpsertOne) AddQty(v int) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.AddQty(v)
+ })
+}
+
+// UpdateQty sets the "qty" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertOne) UpdateQty() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateQty()
+ })
+}
+
+// SetRemark sets the "remark" field.
+func (u *InspectionDisposalItemUpsertOne) SetRemark(v string) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetRemark(v)
+ })
+}
+
+// UpdateRemark sets the "remark" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertOne) UpdateRemark() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateRemark()
+ })
+}
+
+// ClearRemark clears the value of the "remark" field.
+func (u *InspectionDisposalItemUpsertOne) ClearRemark() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.ClearRemark()
+ })
+}
+
+// SetOperator sets the "operator" field.
+func (u *InspectionDisposalItemUpsertOne) SetOperator(v string) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetOperator(v)
+ })
+}
+
+// UpdateOperator sets the "operator" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertOne) UpdateOperator() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateOperator()
+ })
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (u *InspectionDisposalItemUpsertOne) SetCreatedAt(v int64) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetCreatedAt(v)
+ })
+}
+
+// AddCreatedAt adds v to the "created_at" field.
+func (u *InspectionDisposalItemUpsertOne) AddCreatedAt(v int64) *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.AddCreatedAt(v)
+ })
+}
+
+// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertOne) UpdateCreatedAt() *InspectionDisposalItemUpsertOne {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateCreatedAt()
+ })
+}
+
+// Exec executes the query.
+func (u *InspectionDisposalItemUpsertOne) Exec(ctx context.Context) error {
+ if len(u.create.conflict) == 0 {
+ return errors.New("ent: missing options for InspectionDisposalItemCreate.OnConflict")
+ }
+ return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *InspectionDisposalItemUpsertOne) ExecX(ctx context.Context) {
+ if err := u.create.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// Exec executes the UPSERT query and returns the inserted/updated ID.
+func (u *InspectionDisposalItemUpsertOne) ID(ctx context.Context) (id int, err error) {
+ node, err := u.create.Save(ctx)
+ if err != nil {
+ return id, err
+ }
+ return node.ID, nil
+}
+
+// IDX is like ID, but panics if an error occurs.
+func (u *InspectionDisposalItemUpsertOne) IDX(ctx context.Context) int {
+ id, err := u.ID(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return id
+}
+
+// InspectionDisposalItemCreateBulk is the builder for creating many InspectionDisposalItem entities in bulk.
+type InspectionDisposalItemCreateBulk struct {
+ config
+ err error
+ builders []*InspectionDisposalItemCreate
+ conflict []sql.ConflictOption
+}
+
+// Save creates the InspectionDisposalItem entities in the database.
+func (_c *InspectionDisposalItemCreateBulk) Save(ctx context.Context) ([]*InspectionDisposalItem, error) {
+ if _c.err != nil {
+ return nil, _c.err
+ }
+ specs := make([]*sqlgraph.CreateSpec, len(_c.builders))
+ nodes := make([]*InspectionDisposalItem, len(_c.builders))
+ mutators := make([]Mutator, len(_c.builders))
+ for i := range _c.builders {
+ func(i int, root context.Context) {
+ builder := _c.builders[i]
+ builder.defaults()
+ var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
+ mutation, ok := m.(*InspectionDisposalItemMutation)
+ if !ok {
+ return nil, fmt.Errorf("unexpected mutation type %T", m)
+ }
+ if err := builder.check(); err != nil {
+ return nil, err
+ }
+ builder.mutation = mutation
+ var err error
+ nodes[i], specs[i] = builder.createSpec()
+ if i < len(mutators)-1 {
+ _, err = mutators[i+1].Mutate(root, _c.builders[i+1].mutation)
+ } else {
+ spec := &sqlgraph.BatchCreateSpec{Nodes: specs}
+ spec.OnConflict = _c.conflict
+ // Invoke the actual operation on the latest mutation in the chain.
+ if err = sqlgraph.BatchCreate(ctx, _c.driver, spec); err != nil {
+ if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ }
+ }
+ if err != nil {
+ return nil, err
+ }
+ mutation.id = &nodes[i].ID
+ if specs[i].ID.Value != nil {
+ id := specs[i].ID.Value.(int64)
+ nodes[i].ID = int(id)
+ }
+ mutation.done = true
+ return nodes[i], nil
+ })
+ for i := len(builder.hooks) - 1; i >= 0; i-- {
+ mut = builder.hooks[i](mut)
+ }
+ mutators[i] = mut
+ }(i, ctx)
+ }
+ if len(mutators) > 0 {
+ if _, err := mutators[0].Mutate(ctx, _c.builders[0].mutation); err != nil {
+ return nil, err
+ }
+ }
+ return nodes, nil
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_c *InspectionDisposalItemCreateBulk) SaveX(ctx context.Context) []*InspectionDisposalItem {
+ v, err := _c.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return v
+}
+
+// Exec executes the query.
+func (_c *InspectionDisposalItemCreateBulk) Exec(ctx context.Context) error {
+ _, err := _c.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_c *InspectionDisposalItemCreateBulk) ExecX(ctx context.Context) {
+ if err := _c.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// OnConflict allows configuring the `ON CONFLICT` / `ON DUPLICATE KEY` clause
+// of the `INSERT` statement. For example:
+//
+// client.InspectionDisposalItem.CreateBulk(builders...).
+// OnConflict(
+// // Update the row with the new values
+// // the was proposed for insertion.
+// sql.ResolveWithNewValues(),
+// ).
+// // Override some of the fields with custom
+// // update values.
+// Update(func(u *ent.InspectionDisposalItemUpsert) {
+// SetRecordID(v+v).
+// }).
+// Exec(ctx)
+func (_c *InspectionDisposalItemCreateBulk) OnConflict(opts ...sql.ConflictOption) *InspectionDisposalItemUpsertBulk {
+ _c.conflict = opts
+ return &InspectionDisposalItemUpsertBulk{
+ create: _c,
+ }
+}
+
+// OnConflictColumns calls `OnConflict` and configures the columns
+// as conflict target. Using this option is equivalent to using:
+//
+// client.InspectionDisposalItem.Create().
+// OnConflict(sql.ConflictColumns(columns...)).
+// Exec(ctx)
+func (_c *InspectionDisposalItemCreateBulk) OnConflictColumns(columns ...string) *InspectionDisposalItemUpsertBulk {
+ _c.conflict = append(_c.conflict, sql.ConflictColumns(columns...))
+ return &InspectionDisposalItemUpsertBulk{
+ create: _c,
+ }
+}
+
+// InspectionDisposalItemUpsertBulk is the builder for "upsert"-ing
+// a bulk of InspectionDisposalItem nodes.
+type InspectionDisposalItemUpsertBulk struct {
+ create *InspectionDisposalItemCreateBulk
+}
+
+// UpdateNewValues updates the mutable fields using the new values that
+// were set on create. Using this option is equivalent to using:
+//
+// client.InspectionDisposalItem.Create().
+// OnConflict(
+// sql.ResolveWithNewValues(),
+// ).
+// Exec(ctx)
+func (u *InspectionDisposalItemUpsertBulk) UpdateNewValues() *InspectionDisposalItemUpsertBulk {
+ u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
+ return u
+}
+
+// Ignore sets each column to itself in case of conflict.
+// Using this option is equivalent to using:
+//
+// client.InspectionDisposalItem.Create().
+// OnConflict(sql.ResolveWithIgnore()).
+// Exec(ctx)
+func (u *InspectionDisposalItemUpsertBulk) Ignore() *InspectionDisposalItemUpsertBulk {
+ u.create.conflict = append(u.create.conflict, sql.ResolveWithIgnore())
+ return u
+}
+
+// DoNothing configures the conflict_action to `DO NOTHING`.
+// Supported only by SQLite and PostgreSQL.
+func (u *InspectionDisposalItemUpsertBulk) DoNothing() *InspectionDisposalItemUpsertBulk {
+ u.create.conflict = append(u.create.conflict, sql.DoNothing())
+ return u
+}
+
+// Update allows overriding fields `UPDATE` values. See the InspectionDisposalItemCreateBulk.OnConflict
+// documentation for more info.
+func (u *InspectionDisposalItemUpsertBulk) Update(set func(*InspectionDisposalItemUpsert)) *InspectionDisposalItemUpsertBulk {
+ u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(update *sql.UpdateSet) {
+ set(&InspectionDisposalItemUpsert{UpdateSet: update})
+ }))
+ return u
+}
+
+// SetRecordID sets the "record_id" field.
+func (u *InspectionDisposalItemUpsertBulk) SetRecordID(v int64) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetRecordID(v)
+ })
+}
+
+// AddRecordID adds v to the "record_id" field.
+func (u *InspectionDisposalItemUpsertBulk) AddRecordID(v int64) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.AddRecordID(v)
+ })
+}
+
+// UpdateRecordID sets the "record_id" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertBulk) UpdateRecordID() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateRecordID()
+ })
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (u *InspectionDisposalItemUpsertBulk) SetDisposeType(v string) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetDisposeType(v)
+ })
+}
+
+// UpdateDisposeType sets the "dispose_type" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertBulk) UpdateDisposeType() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateDisposeType()
+ })
+}
+
+// SetQty sets the "qty" field.
+func (u *InspectionDisposalItemUpsertBulk) SetQty(v int) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetQty(v)
+ })
+}
+
+// AddQty adds v to the "qty" field.
+func (u *InspectionDisposalItemUpsertBulk) AddQty(v int) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.AddQty(v)
+ })
+}
+
+// UpdateQty sets the "qty" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertBulk) UpdateQty() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateQty()
+ })
+}
+
+// SetRemark sets the "remark" field.
+func (u *InspectionDisposalItemUpsertBulk) SetRemark(v string) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetRemark(v)
+ })
+}
+
+// UpdateRemark sets the "remark" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertBulk) UpdateRemark() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateRemark()
+ })
+}
+
+// ClearRemark clears the value of the "remark" field.
+func (u *InspectionDisposalItemUpsertBulk) ClearRemark() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.ClearRemark()
+ })
+}
+
+// SetOperator sets the "operator" field.
+func (u *InspectionDisposalItemUpsertBulk) SetOperator(v string) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetOperator(v)
+ })
+}
+
+// UpdateOperator sets the "operator" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertBulk) UpdateOperator() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateOperator()
+ })
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (u *InspectionDisposalItemUpsertBulk) SetCreatedAt(v int64) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.SetCreatedAt(v)
+ })
+}
+
+// AddCreatedAt adds v to the "created_at" field.
+func (u *InspectionDisposalItemUpsertBulk) AddCreatedAt(v int64) *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.AddCreatedAt(v)
+ })
+}
+
+// UpdateCreatedAt sets the "created_at" field to the value that was provided on create.
+func (u *InspectionDisposalItemUpsertBulk) UpdateCreatedAt() *InspectionDisposalItemUpsertBulk {
+ return u.Update(func(s *InspectionDisposalItemUpsert) {
+ s.UpdateCreatedAt()
+ })
+}
+
+// Exec executes the query.
+func (u *InspectionDisposalItemUpsertBulk) Exec(ctx context.Context) error {
+ if u.create.err != nil {
+ return u.create.err
+ }
+ for i, b := range u.create.builders {
+ if len(b.conflict) != 0 {
+ return fmt.Errorf("ent: OnConflict was set for builder %d. Set it on the InspectionDisposalItemCreateBulk instead", i)
+ }
+ }
+ if len(u.create.conflict) == 0 {
+ return errors.New("ent: missing options for InspectionDisposalItemCreateBulk.OnConflict")
+ }
+ return u.create.Exec(ctx)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (u *InspectionDisposalItemUpsertBulk) ExecX(ctx context.Context) {
+ if err := u.create.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
diff --git a/bj_power_wms/ent/inspectiondisposalitem_delete.go b/bj_power_wms/ent/inspectiondisposalitem_delete.go
new file mode 100644
index 0000000..2318f35
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem_delete.go
@@ -0,0 +1,88 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "bj_power_wms/ent/inspectiondisposalitem"
+ "bj_power_wms/ent/predicate"
+ "context"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+)
+
+// InspectionDisposalItemDelete is the builder for deleting a InspectionDisposalItem entity.
+type InspectionDisposalItemDelete struct {
+ config
+ hooks []Hook
+ mutation *InspectionDisposalItemMutation
+}
+
+// Where appends a list predicates to the InspectionDisposalItemDelete builder.
+func (_d *InspectionDisposalItemDelete) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemDelete {
+ _d.mutation.Where(ps...)
+ return _d
+}
+
+// Exec executes the deletion query and returns how many vertices were deleted.
+func (_d *InspectionDisposalItemDelete) Exec(ctx context.Context) (int, error) {
+ return withHooks(ctx, _d.sqlExec, _d.mutation, _d.hooks)
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_d *InspectionDisposalItemDelete) ExecX(ctx context.Context) int {
+ n, err := _d.Exec(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return n
+}
+
+func (_d *InspectionDisposalItemDelete) sqlExec(ctx context.Context) (int, error) {
+ _spec := sqlgraph.NewDeleteSpec(inspectiondisposalitem.Table, sqlgraph.NewFieldSpec(inspectiondisposalitem.FieldID, field.TypeInt))
+ if ps := _d.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ affected, err := sqlgraph.DeleteNodes(ctx, _d.driver, _spec)
+ if err != nil && sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ _d.mutation.done = true
+ return affected, err
+}
+
+// InspectionDisposalItemDeleteOne is the builder for deleting a single InspectionDisposalItem entity.
+type InspectionDisposalItemDeleteOne struct {
+ _d *InspectionDisposalItemDelete
+}
+
+// Where appends a list predicates to the InspectionDisposalItemDelete builder.
+func (_d *InspectionDisposalItemDeleteOne) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemDeleteOne {
+ _d._d.mutation.Where(ps...)
+ return _d
+}
+
+// Exec executes the deletion query.
+func (_d *InspectionDisposalItemDeleteOne) Exec(ctx context.Context) error {
+ n, err := _d._d.Exec(ctx)
+ switch {
+ case err != nil:
+ return err
+ case n == 0:
+ return &NotFoundError{inspectiondisposalitem.Label}
+ default:
+ return nil
+ }
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_d *InspectionDisposalItemDeleteOne) ExecX(ctx context.Context) {
+ if err := _d.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
diff --git a/bj_power_wms/ent/inspectiondisposalitem_query.go b/bj_power_wms/ent/inspectiondisposalitem_query.go
new file mode 100644
index 0000000..6955748
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem_query.go
@@ -0,0 +1,527 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "bj_power_wms/ent/inspectiondisposalitem"
+ "bj_power_wms/ent/predicate"
+ "context"
+ "fmt"
+ "math"
+
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+)
+
+// InspectionDisposalItemQuery is the builder for querying InspectionDisposalItem entities.
+type InspectionDisposalItemQuery struct {
+ config
+ ctx *QueryContext
+ order []inspectiondisposalitem.OrderOption
+ inters []Interceptor
+ predicates []predicate.InspectionDisposalItem
+ // intermediate query (i.e. traversal path).
+ sql *sql.Selector
+ path func(context.Context) (*sql.Selector, error)
+}
+
+// Where adds a new predicate for the InspectionDisposalItemQuery builder.
+func (_q *InspectionDisposalItemQuery) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemQuery {
+ _q.predicates = append(_q.predicates, ps...)
+ return _q
+}
+
+// Limit the number of records to be returned by this query.
+func (_q *InspectionDisposalItemQuery) Limit(limit int) *InspectionDisposalItemQuery {
+ _q.ctx.Limit = &limit
+ return _q
+}
+
+// Offset to start from.
+func (_q *InspectionDisposalItemQuery) Offset(offset int) *InspectionDisposalItemQuery {
+ _q.ctx.Offset = &offset
+ return _q
+}
+
+// Unique configures the query builder to filter duplicate records on query.
+// By default, unique is set to true, and can be disabled using this method.
+func (_q *InspectionDisposalItemQuery) Unique(unique bool) *InspectionDisposalItemQuery {
+ _q.ctx.Unique = &unique
+ return _q
+}
+
+// Order specifies how the records should be ordered.
+func (_q *InspectionDisposalItemQuery) Order(o ...inspectiondisposalitem.OrderOption) *InspectionDisposalItemQuery {
+ _q.order = append(_q.order, o...)
+ return _q
+}
+
+// First returns the first InspectionDisposalItem entity from the query.
+// Returns a *NotFoundError when no InspectionDisposalItem was found.
+func (_q *InspectionDisposalItemQuery) First(ctx context.Context) (*InspectionDisposalItem, error) {
+ nodes, err := _q.Limit(1).All(setContextOp(ctx, _q.ctx, ent.OpQueryFirst))
+ if err != nil {
+ return nil, err
+ }
+ if len(nodes) == 0 {
+ return nil, &NotFoundError{inspectiondisposalitem.Label}
+ }
+ return nodes[0], nil
+}
+
+// FirstX is like First, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) FirstX(ctx context.Context) *InspectionDisposalItem {
+ node, err := _q.First(ctx)
+ if err != nil && !IsNotFound(err) {
+ panic(err)
+ }
+ return node
+}
+
+// FirstID returns the first InspectionDisposalItem ID from the query.
+// Returns a *NotFoundError when no InspectionDisposalItem ID was found.
+func (_q *InspectionDisposalItemQuery) FirstID(ctx context.Context) (id int, err error) {
+ var ids []int
+ if ids, err = _q.Limit(1).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryFirstID)); err != nil {
+ return
+ }
+ if len(ids) == 0 {
+ err = &NotFoundError{inspectiondisposalitem.Label}
+ return
+ }
+ return ids[0], nil
+}
+
+// FirstIDX is like FirstID, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) FirstIDX(ctx context.Context) int {
+ id, err := _q.FirstID(ctx)
+ if err != nil && !IsNotFound(err) {
+ panic(err)
+ }
+ return id
+}
+
+// Only returns a single InspectionDisposalItem entity found by the query, ensuring it only returns one.
+// Returns a *NotSingularError when more than one InspectionDisposalItem entity is found.
+// Returns a *NotFoundError when no InspectionDisposalItem entities are found.
+func (_q *InspectionDisposalItemQuery) Only(ctx context.Context) (*InspectionDisposalItem, error) {
+ nodes, err := _q.Limit(2).All(setContextOp(ctx, _q.ctx, ent.OpQueryOnly))
+ if err != nil {
+ return nil, err
+ }
+ switch len(nodes) {
+ case 1:
+ return nodes[0], nil
+ case 0:
+ return nil, &NotFoundError{inspectiondisposalitem.Label}
+ default:
+ return nil, &NotSingularError{inspectiondisposalitem.Label}
+ }
+}
+
+// OnlyX is like Only, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) OnlyX(ctx context.Context) *InspectionDisposalItem {
+ node, err := _q.Only(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return node
+}
+
+// OnlyID is like Only, but returns the only InspectionDisposalItem ID in the query.
+// Returns a *NotSingularError when more than one InspectionDisposalItem ID is found.
+// Returns a *NotFoundError when no entities are found.
+func (_q *InspectionDisposalItemQuery) OnlyID(ctx context.Context) (id int, err error) {
+ var ids []int
+ if ids, err = _q.Limit(2).IDs(setContextOp(ctx, _q.ctx, ent.OpQueryOnlyID)); err != nil {
+ return
+ }
+ switch len(ids) {
+ case 1:
+ id = ids[0]
+ case 0:
+ err = &NotFoundError{inspectiondisposalitem.Label}
+ default:
+ err = &NotSingularError{inspectiondisposalitem.Label}
+ }
+ return
+}
+
+// OnlyIDX is like OnlyID, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) OnlyIDX(ctx context.Context) int {
+ id, err := _q.OnlyID(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return id
+}
+
+// All executes the query and returns a list of InspectionDisposalItems.
+func (_q *InspectionDisposalItemQuery) All(ctx context.Context) ([]*InspectionDisposalItem, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryAll)
+ if err := _q.prepareQuery(ctx); err != nil {
+ return nil, err
+ }
+ qr := querierAll[[]*InspectionDisposalItem, *InspectionDisposalItemQuery]()
+ return withInterceptors[[]*InspectionDisposalItem](ctx, _q, qr, _q.inters)
+}
+
+// AllX is like All, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) AllX(ctx context.Context) []*InspectionDisposalItem {
+ nodes, err := _q.All(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return nodes
+}
+
+// IDs executes the query and returns a list of InspectionDisposalItem IDs.
+func (_q *InspectionDisposalItemQuery) IDs(ctx context.Context) (ids []int, err error) {
+ if _q.ctx.Unique == nil && _q.path != nil {
+ _q.Unique(true)
+ }
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryIDs)
+ if err = _q.Select(inspectiondisposalitem.FieldID).Scan(ctx, &ids); err != nil {
+ return nil, err
+ }
+ return ids, nil
+}
+
+// IDsX is like IDs, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) IDsX(ctx context.Context) []int {
+ ids, err := _q.IDs(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return ids
+}
+
+// Count returns the count of the given query.
+func (_q *InspectionDisposalItemQuery) Count(ctx context.Context) (int, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryCount)
+ if err := _q.prepareQuery(ctx); err != nil {
+ return 0, err
+ }
+ return withInterceptors[int](ctx, _q, querierCount[*InspectionDisposalItemQuery](), _q.inters)
+}
+
+// CountX is like Count, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) CountX(ctx context.Context) int {
+ count, err := _q.Count(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return count
+}
+
+// Exist returns true if the query has elements in the graph.
+func (_q *InspectionDisposalItemQuery) Exist(ctx context.Context) (bool, error) {
+ ctx = setContextOp(ctx, _q.ctx, ent.OpQueryExist)
+ switch _, err := _q.FirstID(ctx); {
+ case IsNotFound(err):
+ return false, nil
+ case err != nil:
+ return false, fmt.Errorf("ent: check existence: %w", err)
+ default:
+ return true, nil
+ }
+}
+
+// ExistX is like Exist, but panics if an error occurs.
+func (_q *InspectionDisposalItemQuery) ExistX(ctx context.Context) bool {
+ exist, err := _q.Exist(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return exist
+}
+
+// Clone returns a duplicate of the InspectionDisposalItemQuery builder, including all associated steps. It can be
+// used to prepare common query builders and use them differently after the clone is made.
+func (_q *InspectionDisposalItemQuery) Clone() *InspectionDisposalItemQuery {
+ if _q == nil {
+ return nil
+ }
+ return &InspectionDisposalItemQuery{
+ config: _q.config,
+ ctx: _q.ctx.Clone(),
+ order: append([]inspectiondisposalitem.OrderOption{}, _q.order...),
+ inters: append([]Interceptor{}, _q.inters...),
+ predicates: append([]predicate.InspectionDisposalItem{}, _q.predicates...),
+ // clone intermediate query.
+ sql: _q.sql.Clone(),
+ path: _q.path,
+ }
+}
+
+// GroupBy is used to group vertices by one or more fields/columns.
+// It is often used with aggregate functions, like: count, max, mean, min, sum.
+//
+// Example:
+//
+// var v []struct {
+// RecordID int64 `json:"recordId,omitempty"`
+// Count int `json:"count,omitempty"`
+// }
+//
+// client.InspectionDisposalItem.Query().
+// GroupBy(inspectiondisposalitem.FieldRecordID).
+// Aggregate(ent.Count()).
+// Scan(ctx, &v)
+func (_q *InspectionDisposalItemQuery) GroupBy(field string, fields ...string) *InspectionDisposalItemGroupBy {
+ _q.ctx.Fields = append([]string{field}, fields...)
+ grbuild := &InspectionDisposalItemGroupBy{build: _q}
+ grbuild.flds = &_q.ctx.Fields
+ grbuild.label = inspectiondisposalitem.Label
+ grbuild.scan = grbuild.Scan
+ return grbuild
+}
+
+// Select allows the selection one or more fields/columns for the given query,
+// instead of selecting all fields in the entity.
+//
+// Example:
+//
+// var v []struct {
+// RecordID int64 `json:"recordId,omitempty"`
+// }
+//
+// client.InspectionDisposalItem.Query().
+// Select(inspectiondisposalitem.FieldRecordID).
+// Scan(ctx, &v)
+func (_q *InspectionDisposalItemQuery) Select(fields ...string) *InspectionDisposalItemSelect {
+ _q.ctx.Fields = append(_q.ctx.Fields, fields...)
+ sbuild := &InspectionDisposalItemSelect{InspectionDisposalItemQuery: _q}
+ sbuild.label = inspectiondisposalitem.Label
+ sbuild.flds, sbuild.scan = &_q.ctx.Fields, sbuild.Scan
+ return sbuild
+}
+
+// Aggregate returns a InspectionDisposalItemSelect configured with the given aggregations.
+func (_q *InspectionDisposalItemQuery) Aggregate(fns ...AggregateFunc) *InspectionDisposalItemSelect {
+ return _q.Select().Aggregate(fns...)
+}
+
+func (_q *InspectionDisposalItemQuery) prepareQuery(ctx context.Context) error {
+ for _, inter := range _q.inters {
+ if inter == nil {
+ return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
+ }
+ if trv, ok := inter.(Traverser); ok {
+ if err := trv.Traverse(ctx, _q); err != nil {
+ return err
+ }
+ }
+ }
+ for _, f := range _q.ctx.Fields {
+ if !inspectiondisposalitem.ValidColumn(f) {
+ return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+ }
+ }
+ if _q.path != nil {
+ prev, err := _q.path(ctx)
+ if err != nil {
+ return err
+ }
+ _q.sql = prev
+ }
+ return nil
+}
+
+func (_q *InspectionDisposalItemQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*InspectionDisposalItem, error) {
+ var (
+ nodes = []*InspectionDisposalItem{}
+ _spec = _q.querySpec()
+ )
+ _spec.ScanValues = func(columns []string) ([]any, error) {
+ return (*InspectionDisposalItem).scanValues(nil, columns)
+ }
+ _spec.Assign = func(columns []string, values []any) error {
+ node := &InspectionDisposalItem{config: _q.config}
+ nodes = append(nodes, node)
+ return node.assignValues(columns, values)
+ }
+ for i := range hooks {
+ hooks[i](ctx, _spec)
+ }
+ if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil {
+ return nil, err
+ }
+ if len(nodes) == 0 {
+ return nodes, nil
+ }
+ return nodes, nil
+}
+
+func (_q *InspectionDisposalItemQuery) sqlCount(ctx context.Context) (int, error) {
+ _spec := _q.querySpec()
+ _spec.Node.Columns = _q.ctx.Fields
+ if len(_q.ctx.Fields) > 0 {
+ _spec.Unique = _q.ctx.Unique != nil && *_q.ctx.Unique
+ }
+ return sqlgraph.CountNodes(ctx, _q.driver, _spec)
+}
+
+func (_q *InspectionDisposalItemQuery) querySpec() *sqlgraph.QuerySpec {
+ _spec := sqlgraph.NewQuerySpec(inspectiondisposalitem.Table, inspectiondisposalitem.Columns, sqlgraph.NewFieldSpec(inspectiondisposalitem.FieldID, field.TypeInt))
+ _spec.From = _q.sql
+ if unique := _q.ctx.Unique; unique != nil {
+ _spec.Unique = *unique
+ } else if _q.path != nil {
+ _spec.Unique = true
+ }
+ if fields := _q.ctx.Fields; len(fields) > 0 {
+ _spec.Node.Columns = make([]string, 0, len(fields))
+ _spec.Node.Columns = append(_spec.Node.Columns, inspectiondisposalitem.FieldID)
+ for i := range fields {
+ if fields[i] != inspectiondisposalitem.FieldID {
+ _spec.Node.Columns = append(_spec.Node.Columns, fields[i])
+ }
+ }
+ }
+ if ps := _q.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if limit := _q.ctx.Limit; limit != nil {
+ _spec.Limit = *limit
+ }
+ if offset := _q.ctx.Offset; offset != nil {
+ _spec.Offset = *offset
+ }
+ if ps := _q.order; len(ps) > 0 {
+ _spec.Order = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ return _spec
+}
+
+func (_q *InspectionDisposalItemQuery) sqlQuery(ctx context.Context) *sql.Selector {
+ builder := sql.Dialect(_q.driver.Dialect())
+ t1 := builder.Table(inspectiondisposalitem.Table)
+ columns := _q.ctx.Fields
+ if len(columns) == 0 {
+ columns = inspectiondisposalitem.Columns
+ }
+ selector := builder.Select(t1.Columns(columns...)...).From(t1)
+ if _q.sql != nil {
+ selector = _q.sql
+ selector.Select(selector.Columns(columns...)...)
+ }
+ if _q.ctx.Unique != nil && *_q.ctx.Unique {
+ selector.Distinct()
+ }
+ for _, p := range _q.predicates {
+ p(selector)
+ }
+ for _, p := range _q.order {
+ p(selector)
+ }
+ if offset := _q.ctx.Offset; offset != nil {
+ // limit is mandatory for offset clause. We start
+ // with default value, and override it below if needed.
+ selector.Offset(*offset).Limit(math.MaxInt32)
+ }
+ if limit := _q.ctx.Limit; limit != nil {
+ selector.Limit(*limit)
+ }
+ return selector
+}
+
+// InspectionDisposalItemGroupBy is the group-by builder for InspectionDisposalItem entities.
+type InspectionDisposalItemGroupBy struct {
+ selector
+ build *InspectionDisposalItemQuery
+}
+
+// Aggregate adds the given aggregation functions to the group-by query.
+func (_g *InspectionDisposalItemGroupBy) Aggregate(fns ...AggregateFunc) *InspectionDisposalItemGroupBy {
+ _g.fns = append(_g.fns, fns...)
+ return _g
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (_g *InspectionDisposalItemGroupBy) Scan(ctx context.Context, v any) error {
+ ctx = setContextOp(ctx, _g.build.ctx, ent.OpQueryGroupBy)
+ if err := _g.build.prepareQuery(ctx); err != nil {
+ return err
+ }
+ return scanWithInterceptors[*InspectionDisposalItemQuery, *InspectionDisposalItemGroupBy](ctx, _g.build, _g, _g.build.inters, v)
+}
+
+func (_g *InspectionDisposalItemGroupBy) sqlScan(ctx context.Context, root *InspectionDisposalItemQuery, v any) error {
+ selector := root.sqlQuery(ctx).Select()
+ aggregation := make([]string, 0, len(_g.fns))
+ for _, fn := range _g.fns {
+ aggregation = append(aggregation, fn(selector))
+ }
+ if len(selector.SelectedColumns()) == 0 {
+ columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
+ for _, f := range *_g.flds {
+ columns = append(columns, selector.C(f))
+ }
+ columns = append(columns, aggregation...)
+ selector.Select(columns...)
+ }
+ selector.GroupBy(selector.Columns(*_g.flds...)...)
+ if err := selector.Err(); err != nil {
+ return err
+ }
+ rows := &sql.Rows{}
+ query, args := selector.Query()
+ if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
+ return err
+ }
+ defer rows.Close()
+ return sql.ScanSlice(rows, v)
+}
+
+// InspectionDisposalItemSelect is the builder for selecting fields of InspectionDisposalItem entities.
+type InspectionDisposalItemSelect struct {
+ *InspectionDisposalItemQuery
+ selector
+}
+
+// Aggregate adds the given aggregation functions to the selector query.
+func (_s *InspectionDisposalItemSelect) Aggregate(fns ...AggregateFunc) *InspectionDisposalItemSelect {
+ _s.fns = append(_s.fns, fns...)
+ return _s
+}
+
+// Scan applies the selector query and scans the result into the given value.
+func (_s *InspectionDisposalItemSelect) Scan(ctx context.Context, v any) error {
+ ctx = setContextOp(ctx, _s.ctx, ent.OpQuerySelect)
+ if err := _s.prepareQuery(ctx); err != nil {
+ return err
+ }
+ return scanWithInterceptors[*InspectionDisposalItemQuery, *InspectionDisposalItemSelect](ctx, _s.InspectionDisposalItemQuery, _s, _s.inters, v)
+}
+
+func (_s *InspectionDisposalItemSelect) sqlScan(ctx context.Context, root *InspectionDisposalItemQuery, v any) error {
+ selector := root.sqlQuery(ctx)
+ aggregation := make([]string, 0, len(_s.fns))
+ for _, fn := range _s.fns {
+ aggregation = append(aggregation, fn(selector))
+ }
+ switch n := len(*_s.selector.flds); {
+ case n == 0 && len(aggregation) > 0:
+ selector.Select(aggregation...)
+ case n != 0 && len(aggregation) > 0:
+ selector.AppendSelect(aggregation...)
+ }
+ rows := &sql.Rows{}
+ query, args := selector.Query()
+ if err := _s.driver.Query(ctx, query, args, rows); err != nil {
+ return err
+ }
+ defer rows.Close()
+ return sql.ScanSlice(rows, v)
+}
diff --git a/bj_power_wms/ent/inspectiondisposalitem_update.go b/bj_power_wms/ent/inspectiondisposalitem_update.go
new file mode 100644
index 0000000..8b46c20
--- /dev/null
+++ b/bj_power_wms/ent/inspectiondisposalitem_update.go
@@ -0,0 +1,483 @@
+// Code generated by ent, DO NOT EDIT.
+
+package ent
+
+import (
+ "bj_power_wms/ent/inspectiondisposalitem"
+ "bj_power_wms/ent/predicate"
+ "context"
+ "errors"
+ "fmt"
+
+ "entgo.io/ent/dialect/sql"
+ "entgo.io/ent/dialect/sql/sqlgraph"
+ "entgo.io/ent/schema/field"
+)
+
+// InspectionDisposalItemUpdate is the builder for updating InspectionDisposalItem entities.
+type InspectionDisposalItemUpdate struct {
+ config
+ hooks []Hook
+ mutation *InspectionDisposalItemMutation
+}
+
+// Where appends a list predicates to the InspectionDisposalItemUpdate builder.
+func (_u *InspectionDisposalItemUpdate) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemUpdate {
+ _u.mutation.Where(ps...)
+ return _u
+}
+
+// SetRecordID sets the "record_id" field.
+func (_u *InspectionDisposalItemUpdate) SetRecordID(v int64) *InspectionDisposalItemUpdate {
+ _u.mutation.ResetRecordID()
+ _u.mutation.SetRecordID(v)
+ return _u
+}
+
+// SetNillableRecordID sets the "record_id" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdate) SetNillableRecordID(v *int64) *InspectionDisposalItemUpdate {
+ if v != nil {
+ _u.SetRecordID(*v)
+ }
+ return _u
+}
+
+// AddRecordID adds value to the "record_id" field.
+func (_u *InspectionDisposalItemUpdate) AddRecordID(v int64) *InspectionDisposalItemUpdate {
+ _u.mutation.AddRecordID(v)
+ return _u
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (_u *InspectionDisposalItemUpdate) SetDisposeType(v string) *InspectionDisposalItemUpdate {
+ _u.mutation.SetDisposeType(v)
+ return _u
+}
+
+// SetNillableDisposeType sets the "dispose_type" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdate) SetNillableDisposeType(v *string) *InspectionDisposalItemUpdate {
+ if v != nil {
+ _u.SetDisposeType(*v)
+ }
+ return _u
+}
+
+// SetQty sets the "qty" field.
+func (_u *InspectionDisposalItemUpdate) SetQty(v int) *InspectionDisposalItemUpdate {
+ _u.mutation.ResetQty()
+ _u.mutation.SetQty(v)
+ return _u
+}
+
+// SetNillableQty sets the "qty" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdate) SetNillableQty(v *int) *InspectionDisposalItemUpdate {
+ if v != nil {
+ _u.SetQty(*v)
+ }
+ return _u
+}
+
+// AddQty adds value to the "qty" field.
+func (_u *InspectionDisposalItemUpdate) AddQty(v int) *InspectionDisposalItemUpdate {
+ _u.mutation.AddQty(v)
+ return _u
+}
+
+// SetRemark sets the "remark" field.
+func (_u *InspectionDisposalItemUpdate) SetRemark(v string) *InspectionDisposalItemUpdate {
+ _u.mutation.SetRemark(v)
+ return _u
+}
+
+// SetNillableRemark sets the "remark" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdate) SetNillableRemark(v *string) *InspectionDisposalItemUpdate {
+ if v != nil {
+ _u.SetRemark(*v)
+ }
+ return _u
+}
+
+// ClearRemark clears the value of the "remark" field.
+func (_u *InspectionDisposalItemUpdate) ClearRemark() *InspectionDisposalItemUpdate {
+ _u.mutation.ClearRemark()
+ return _u
+}
+
+// SetOperator sets the "operator" field.
+func (_u *InspectionDisposalItemUpdate) SetOperator(v string) *InspectionDisposalItemUpdate {
+ _u.mutation.SetOperator(v)
+ return _u
+}
+
+// SetNillableOperator sets the "operator" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdate) SetNillableOperator(v *string) *InspectionDisposalItemUpdate {
+ if v != nil {
+ _u.SetOperator(*v)
+ }
+ return _u
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (_u *InspectionDisposalItemUpdate) SetCreatedAt(v int64) *InspectionDisposalItemUpdate {
+ _u.mutation.ResetCreatedAt()
+ _u.mutation.SetCreatedAt(v)
+ return _u
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdate) SetNillableCreatedAt(v *int64) *InspectionDisposalItemUpdate {
+ if v != nil {
+ _u.SetCreatedAt(*v)
+ }
+ return _u
+}
+
+// AddCreatedAt adds value to the "created_at" field.
+func (_u *InspectionDisposalItemUpdate) AddCreatedAt(v int64) *InspectionDisposalItemUpdate {
+ _u.mutation.AddCreatedAt(v)
+ return _u
+}
+
+// Mutation returns the InspectionDisposalItemMutation object of the builder.
+func (_u *InspectionDisposalItemUpdate) Mutation() *InspectionDisposalItemMutation {
+ return _u.mutation
+}
+
+// Save executes the query and returns the number of nodes affected by the update operation.
+func (_u *InspectionDisposalItemUpdate) Save(ctx context.Context) (int, error) {
+ return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_u *InspectionDisposalItemUpdate) SaveX(ctx context.Context) int {
+ affected, err := _u.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return affected
+}
+
+// Exec executes the query.
+func (_u *InspectionDisposalItemUpdate) Exec(ctx context.Context) error {
+ _, err := _u.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_u *InspectionDisposalItemUpdate) ExecX(ctx context.Context) {
+ if err := _u.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_u *InspectionDisposalItemUpdate) check() error {
+ if v, ok := _u.mutation.Qty(); ok {
+ if err := inspectiondisposalitem.QtyValidator(v); err != nil {
+ return &ValidationError{Name: "qty", err: fmt.Errorf(`ent: validator failed for field "InspectionDisposalItem.qty": %w`, err)}
+ }
+ }
+ return nil
+}
+
+func (_u *InspectionDisposalItemUpdate) sqlSave(ctx context.Context) (_node int, err error) {
+ if err := _u.check(); err != nil {
+ return _node, err
+ }
+ _spec := sqlgraph.NewUpdateSpec(inspectiondisposalitem.Table, inspectiondisposalitem.Columns, sqlgraph.NewFieldSpec(inspectiondisposalitem.FieldID, field.TypeInt))
+ if ps := _u.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if value, ok := _u.mutation.RecordID(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
+ }
+ if value, ok := _u.mutation.AddedRecordID(); ok {
+ _spec.AddField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
+ }
+ if value, ok := _u.mutation.DisposeType(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldDisposeType, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.Qty(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.AddedQty(); ok {
+ _spec.AddField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.Remark(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldRemark, field.TypeString, value)
+ }
+ if _u.mutation.RemarkCleared() {
+ _spec.ClearField(inspectiondisposalitem.FieldRemark, field.TypeString)
+ }
+ if value, ok := _u.mutation.Operator(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldOperator, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.CreatedAt(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
+ }
+ if value, ok := _u.mutation.AddedCreatedAt(); ok {
+ _spec.AddField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
+ }
+ if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
+ if _, ok := err.(*sqlgraph.NotFoundError); ok {
+ err = &NotFoundError{inspectiondisposalitem.Label}
+ } else if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return 0, err
+ }
+ _u.mutation.done = true
+ return _node, nil
+}
+
+// InspectionDisposalItemUpdateOne is the builder for updating a single InspectionDisposalItem entity.
+type InspectionDisposalItemUpdateOne struct {
+ config
+ fields []string
+ hooks []Hook
+ mutation *InspectionDisposalItemMutation
+}
+
+// SetRecordID sets the "record_id" field.
+func (_u *InspectionDisposalItemUpdateOne) SetRecordID(v int64) *InspectionDisposalItemUpdateOne {
+ _u.mutation.ResetRecordID()
+ _u.mutation.SetRecordID(v)
+ return _u
+}
+
+// SetNillableRecordID sets the "record_id" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdateOne) SetNillableRecordID(v *int64) *InspectionDisposalItemUpdateOne {
+ if v != nil {
+ _u.SetRecordID(*v)
+ }
+ return _u
+}
+
+// AddRecordID adds value to the "record_id" field.
+func (_u *InspectionDisposalItemUpdateOne) AddRecordID(v int64) *InspectionDisposalItemUpdateOne {
+ _u.mutation.AddRecordID(v)
+ return _u
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (_u *InspectionDisposalItemUpdateOne) SetDisposeType(v string) *InspectionDisposalItemUpdateOne {
+ _u.mutation.SetDisposeType(v)
+ return _u
+}
+
+// SetNillableDisposeType sets the "dispose_type" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdateOne) SetNillableDisposeType(v *string) *InspectionDisposalItemUpdateOne {
+ if v != nil {
+ _u.SetDisposeType(*v)
+ }
+ return _u
+}
+
+// SetQty sets the "qty" field.
+func (_u *InspectionDisposalItemUpdateOne) SetQty(v int) *InspectionDisposalItemUpdateOne {
+ _u.mutation.ResetQty()
+ _u.mutation.SetQty(v)
+ return _u
+}
+
+// SetNillableQty sets the "qty" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdateOne) SetNillableQty(v *int) *InspectionDisposalItemUpdateOne {
+ if v != nil {
+ _u.SetQty(*v)
+ }
+ return _u
+}
+
+// AddQty adds value to the "qty" field.
+func (_u *InspectionDisposalItemUpdateOne) AddQty(v int) *InspectionDisposalItemUpdateOne {
+ _u.mutation.AddQty(v)
+ return _u
+}
+
+// SetRemark sets the "remark" field.
+func (_u *InspectionDisposalItemUpdateOne) SetRemark(v string) *InspectionDisposalItemUpdateOne {
+ _u.mutation.SetRemark(v)
+ return _u
+}
+
+// SetNillableRemark sets the "remark" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdateOne) SetNillableRemark(v *string) *InspectionDisposalItemUpdateOne {
+ if v != nil {
+ _u.SetRemark(*v)
+ }
+ return _u
+}
+
+// ClearRemark clears the value of the "remark" field.
+func (_u *InspectionDisposalItemUpdateOne) ClearRemark() *InspectionDisposalItemUpdateOne {
+ _u.mutation.ClearRemark()
+ return _u
+}
+
+// SetOperator sets the "operator" field.
+func (_u *InspectionDisposalItemUpdateOne) SetOperator(v string) *InspectionDisposalItemUpdateOne {
+ _u.mutation.SetOperator(v)
+ return _u
+}
+
+// SetNillableOperator sets the "operator" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdateOne) SetNillableOperator(v *string) *InspectionDisposalItemUpdateOne {
+ if v != nil {
+ _u.SetOperator(*v)
+ }
+ return _u
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (_u *InspectionDisposalItemUpdateOne) SetCreatedAt(v int64) *InspectionDisposalItemUpdateOne {
+ _u.mutation.ResetCreatedAt()
+ _u.mutation.SetCreatedAt(v)
+ return _u
+}
+
+// SetNillableCreatedAt sets the "created_at" field if the given value is not nil.
+func (_u *InspectionDisposalItemUpdateOne) SetNillableCreatedAt(v *int64) *InspectionDisposalItemUpdateOne {
+ if v != nil {
+ _u.SetCreatedAt(*v)
+ }
+ return _u
+}
+
+// AddCreatedAt adds value to the "created_at" field.
+func (_u *InspectionDisposalItemUpdateOne) AddCreatedAt(v int64) *InspectionDisposalItemUpdateOne {
+ _u.mutation.AddCreatedAt(v)
+ return _u
+}
+
+// Mutation returns the InspectionDisposalItemMutation object of the builder.
+func (_u *InspectionDisposalItemUpdateOne) Mutation() *InspectionDisposalItemMutation {
+ return _u.mutation
+}
+
+// Where appends a list predicates to the InspectionDisposalItemUpdate builder.
+func (_u *InspectionDisposalItemUpdateOne) Where(ps ...predicate.InspectionDisposalItem) *InspectionDisposalItemUpdateOne {
+ _u.mutation.Where(ps...)
+ return _u
+}
+
+// Select allows selecting one or more fields (columns) of the returned entity.
+// The default is selecting all fields defined in the entity schema.
+func (_u *InspectionDisposalItemUpdateOne) Select(field string, fields ...string) *InspectionDisposalItemUpdateOne {
+ _u.fields = append([]string{field}, fields...)
+ return _u
+}
+
+// Save executes the query and returns the updated InspectionDisposalItem entity.
+func (_u *InspectionDisposalItemUpdateOne) Save(ctx context.Context) (*InspectionDisposalItem, error) {
+ return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
+}
+
+// SaveX is like Save, but panics if an error occurs.
+func (_u *InspectionDisposalItemUpdateOne) SaveX(ctx context.Context) *InspectionDisposalItem {
+ node, err := _u.Save(ctx)
+ if err != nil {
+ panic(err)
+ }
+ return node
+}
+
+// Exec executes the query on the entity.
+func (_u *InspectionDisposalItemUpdateOne) Exec(ctx context.Context) error {
+ _, err := _u.Save(ctx)
+ return err
+}
+
+// ExecX is like Exec, but panics if an error occurs.
+func (_u *InspectionDisposalItemUpdateOne) ExecX(ctx context.Context) {
+ if err := _u.Exec(ctx); err != nil {
+ panic(err)
+ }
+}
+
+// check runs all checks and user-defined validators on the builder.
+func (_u *InspectionDisposalItemUpdateOne) check() error {
+ if v, ok := _u.mutation.Qty(); ok {
+ if err := inspectiondisposalitem.QtyValidator(v); err != nil {
+ return &ValidationError{Name: "qty", err: fmt.Errorf(`ent: validator failed for field "InspectionDisposalItem.qty": %w`, err)}
+ }
+ }
+ return nil
+}
+
+func (_u *InspectionDisposalItemUpdateOne) sqlSave(ctx context.Context) (_node *InspectionDisposalItem, err error) {
+ if err := _u.check(); err != nil {
+ return _node, err
+ }
+ _spec := sqlgraph.NewUpdateSpec(inspectiondisposalitem.Table, inspectiondisposalitem.Columns, sqlgraph.NewFieldSpec(inspectiondisposalitem.FieldID, field.TypeInt))
+ id, ok := _u.mutation.ID()
+ if !ok {
+ return nil, &ValidationError{Name: "id", err: errors.New(`ent: missing "InspectionDisposalItem.id" for update`)}
+ }
+ _spec.Node.ID.Value = id
+ if fields := _u.fields; len(fields) > 0 {
+ _spec.Node.Columns = make([]string, 0, len(fields))
+ _spec.Node.Columns = append(_spec.Node.Columns, inspectiondisposalitem.FieldID)
+ for _, f := range fields {
+ if !inspectiondisposalitem.ValidColumn(f) {
+ return nil, &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
+ }
+ if f != inspectiondisposalitem.FieldID {
+ _spec.Node.Columns = append(_spec.Node.Columns, f)
+ }
+ }
+ }
+ if ps := _u.mutation.predicates; len(ps) > 0 {
+ _spec.Predicate = func(selector *sql.Selector) {
+ for i := range ps {
+ ps[i](selector)
+ }
+ }
+ }
+ if value, ok := _u.mutation.RecordID(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
+ }
+ if value, ok := _u.mutation.AddedRecordID(); ok {
+ _spec.AddField(inspectiondisposalitem.FieldRecordID, field.TypeInt64, value)
+ }
+ if value, ok := _u.mutation.DisposeType(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldDisposeType, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.Qty(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.AddedQty(); ok {
+ _spec.AddField(inspectiondisposalitem.FieldQty, field.TypeInt, value)
+ }
+ if value, ok := _u.mutation.Remark(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldRemark, field.TypeString, value)
+ }
+ if _u.mutation.RemarkCleared() {
+ _spec.ClearField(inspectiondisposalitem.FieldRemark, field.TypeString)
+ }
+ if value, ok := _u.mutation.Operator(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldOperator, field.TypeString, value)
+ }
+ if value, ok := _u.mutation.CreatedAt(); ok {
+ _spec.SetField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
+ }
+ if value, ok := _u.mutation.AddedCreatedAt(); ok {
+ _spec.AddField(inspectiondisposalitem.FieldCreatedAt, field.TypeInt64, value)
+ }
+ _node = &InspectionDisposalItem{config: _u.config}
+ _spec.Assign = _node.assignValues
+ _spec.ScanValues = _node.scanValues
+ if err = sqlgraph.UpdateNode(ctx, _u.driver, _spec); err != nil {
+ if _, ok := err.(*sqlgraph.NotFoundError); ok {
+ err = &NotFoundError{inspectiondisposalitem.Label}
+ } else if sqlgraph.IsConstraintError(err) {
+ err = &ConstraintError{msg: err.Error(), wrap: err}
+ }
+ return nil, err
+ }
+ _u.mutation.done = true
+ return _node, nil
+}
diff --git a/bj_power_wms/ent/inspectionrecord.go b/bj_power_wms/ent/inspectionrecord.go
index 22aa10c..2a67aeb 100644
--- a/bj_power_wms/ent/inspectionrecord.go
+++ b/bj_power_wms/ent/inspectionrecord.go
@@ -60,16 +60,10 @@ type InspectionRecord struct {
ReportNo string `json:"reportNo,omitempty"`
// 检验结论 合格/不合格/待检/挑选(与处置方式正交)
InspectionConclusion string `json:"inspectionConclusion,omitempty"`
- // 不合格品处置状态 待处置/退货中/已退货/返修中/已返修/已报废/已处置
+ // 不合格品处置状态 待处置/已处置
DisposalStatus string `json:"disposalStatus,omitempty"`
// 拆行来源检验记录ID(不合格隔离行回挂原单)
ParentRecordID int64 `json:"parentRecordId,omitempty"`
- // 不合格部分处置 NONE/RETURN/SCRAP/PARTIAL/REWORK
- DisposalType string `json:"disposalType,omitempty"`
- // 处置说明(报废/退货原因)
- DisposalRemark string `json:"disposalRemark,omitempty"`
- // 退货货运单号
- ReturnTrackingNo string `json:"returnTrackingNo,omitempty"`
// 备注
Remark string `json:"remark,omitempty"`
// CreatedAt holds the value of the "created_at" field.
@@ -86,7 +80,7 @@ func (*InspectionRecord) scanValues(columns []string) ([]any, error) {
switch columns[i] {
case inspectionrecord.FieldID, inspectionrecord.FieldInspectQty, inspectionrecord.FieldPassQty, inspectionrecord.FieldBatchSeq, inspectionrecord.FieldBatchTotal, inspectionrecord.FieldRejectQty, inspectionrecord.FieldParentRecordID, inspectionrecord.FieldCreatedAt, inspectionrecord.FieldUpdatedAt:
values[i] = new(sql.NullInt64)
- case inspectionrecord.FieldTargetType, inspectionrecord.FieldTargetID, inspectionrecord.FieldMaterialCode, inspectionrecord.FieldMaterialName, inspectionrecord.FieldOwnershipType, inspectionrecord.FieldOwnershipNo, inspectionrecord.FieldProductWorkNo, inspectionrecord.FieldRelatedStandard, inspectionrecord.FieldManufacturer, inspectionrecord.FieldInspectionType, inspectionrecord.FieldStatus, inspectionrecord.FieldResultValue, inspectionrecord.FieldCheckDesc, inspectionrecord.FieldInspector, inspectionrecord.FieldInspectionNo, inspectionrecord.FieldReportNo, inspectionrecord.FieldInspectionConclusion, inspectionrecord.FieldDisposalStatus, inspectionrecord.FieldDisposalType, inspectionrecord.FieldDisposalRemark, inspectionrecord.FieldReturnTrackingNo, inspectionrecord.FieldRemark:
+ case inspectionrecord.FieldTargetType, inspectionrecord.FieldTargetID, inspectionrecord.FieldMaterialCode, inspectionrecord.FieldMaterialName, inspectionrecord.FieldOwnershipType, inspectionrecord.FieldOwnershipNo, inspectionrecord.FieldProductWorkNo, inspectionrecord.FieldRelatedStandard, inspectionrecord.FieldManufacturer, inspectionrecord.FieldInspectionType, inspectionrecord.FieldStatus, inspectionrecord.FieldResultValue, inspectionrecord.FieldCheckDesc, inspectionrecord.FieldInspector, inspectionrecord.FieldInspectionNo, inspectionrecord.FieldReportNo, inspectionrecord.FieldInspectionConclusion, inspectionrecord.FieldDisposalStatus, inspectionrecord.FieldRemark:
values[i] = new(sql.NullString)
default:
values[i] = new(sql.UnknownType)
@@ -253,24 +247,6 @@ func (_m *InspectionRecord) assignValues(columns []string, values []any) error {
} else if value.Valid {
_m.ParentRecordID = value.Int64
}
- case inspectionrecord.FieldDisposalType:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field disposal_type", values[i])
- } else if value.Valid {
- _m.DisposalType = value.String
- }
- case inspectionrecord.FieldDisposalRemark:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field disposal_remark", values[i])
- } else if value.Valid {
- _m.DisposalRemark = value.String
- }
- case inspectionrecord.FieldReturnTrackingNo:
- if value, ok := values[i].(*sql.NullString); !ok {
- return fmt.Errorf("unexpected type %T for field return_tracking_no", values[i])
- } else if value.Valid {
- _m.ReturnTrackingNo = value.String
- }
case inspectionrecord.FieldRemark:
if value, ok := values[i].(*sql.NullString); !ok {
return fmt.Errorf("unexpected type %T for field remark", values[i])
@@ -397,15 +373,6 @@ func (_m *InspectionRecord) String() string {
builder.WriteString("parent_record_id=")
builder.WriteString(fmt.Sprintf("%v", _m.ParentRecordID))
builder.WriteString(", ")
- builder.WriteString("disposal_type=")
- builder.WriteString(_m.DisposalType)
- builder.WriteString(", ")
- builder.WriteString("disposal_remark=")
- builder.WriteString(_m.DisposalRemark)
- builder.WriteString(", ")
- builder.WriteString("return_tracking_no=")
- builder.WriteString(_m.ReturnTrackingNo)
- builder.WriteString(", ")
builder.WriteString("remark=")
builder.WriteString(_m.Remark)
builder.WriteString(", ")
diff --git a/bj_power_wms/ent/inspectionrecord/inspectionrecord.go b/bj_power_wms/ent/inspectionrecord/inspectionrecord.go
index 0b387fd..e9a6e59 100644
--- a/bj_power_wms/ent/inspectionrecord/inspectionrecord.go
+++ b/bj_power_wms/ent/inspectionrecord/inspectionrecord.go
@@ -59,12 +59,6 @@ const (
FieldDisposalStatus = "disposal_status"
// FieldParentRecordID holds the string denoting the parent_record_id field in the database.
FieldParentRecordID = "parent_record_id"
- // FieldDisposalType holds the string denoting the disposal_type field in the database.
- FieldDisposalType = "disposal_type"
- // FieldDisposalRemark holds the string denoting the disposal_remark field in the database.
- FieldDisposalRemark = "disposal_remark"
- // FieldReturnTrackingNo holds the string denoting the return_tracking_no field in the database.
- FieldReturnTrackingNo = "return_tracking_no"
// FieldRemark holds the string denoting the remark field in the database.
FieldRemark = "remark"
// FieldCreatedAt holds the string denoting the created_at field in the database.
@@ -102,9 +96,6 @@ var Columns = []string{
FieldInspectionConclusion,
FieldDisposalStatus,
FieldParentRecordID,
- FieldDisposalType,
- FieldDisposalRemark,
- FieldReturnTrackingNo,
FieldRemark,
FieldCreatedAt,
FieldUpdatedAt,
@@ -141,8 +132,6 @@ var (
DefaultDisposalStatus string
// DefaultParentRecordID holds the default value on creation for the "parent_record_id" field.
DefaultParentRecordID int64
- // DefaultDisposalType holds the default value on creation for the "disposal_type" field.
- DefaultDisposalType string
// DefaultCreatedAt holds the default value on creation for the "created_at" field.
DefaultCreatedAt func() int64
// DefaultUpdatedAt holds the default value on creation for the "updated_at" field.
@@ -277,21 +266,6 @@ func ByParentRecordID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldParentRecordID, opts...).ToFunc()
}
-// ByDisposalType orders the results by the disposal_type field.
-func ByDisposalType(opts ...sql.OrderTermOption) OrderOption {
- return sql.OrderByField(FieldDisposalType, opts...).ToFunc()
-}
-
-// ByDisposalRemark orders the results by the disposal_remark field.
-func ByDisposalRemark(opts ...sql.OrderTermOption) OrderOption {
- return sql.OrderByField(FieldDisposalRemark, opts...).ToFunc()
-}
-
-// ByReturnTrackingNo orders the results by the return_tracking_no field.
-func ByReturnTrackingNo(opts ...sql.OrderTermOption) OrderOption {
- return sql.OrderByField(FieldReturnTrackingNo, opts...).ToFunc()
-}
-
// ByRemark orders the results by the remark field.
func ByRemark(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldRemark, opts...).ToFunc()
diff --git a/bj_power_wms/ent/inspectionrecord/where.go b/bj_power_wms/ent/inspectionrecord/where.go
index e8b0d36..392f69e 100644
--- a/bj_power_wms/ent/inspectionrecord/where.go
+++ b/bj_power_wms/ent/inspectionrecord/where.go
@@ -173,21 +173,6 @@ func ParentRecordID(v int64) predicate.InspectionRecord {
return predicate.InspectionRecord(sql.FieldEQ(FieldParentRecordID, v))
}
-// DisposalType applies equality check predicate on the "disposal_type" field. It's identical to DisposalTypeEQ.
-func DisposalType(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEQ(FieldDisposalType, v))
-}
-
-// DisposalRemark applies equality check predicate on the "disposal_remark" field. It's identical to DisposalRemarkEQ.
-func DisposalRemark(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEQ(FieldDisposalRemark, v))
-}
-
-// ReturnTrackingNo applies equality check predicate on the "return_tracking_no" field. It's identical to ReturnTrackingNoEQ.
-func ReturnTrackingNo(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEQ(FieldReturnTrackingNo, v))
-}
-
// Remark applies equality check predicate on the "remark" field. It's identical to RemarkEQ.
func Remark(v string) predicate.InspectionRecord {
return predicate.InspectionRecord(sql.FieldEQ(FieldRemark, v))
@@ -1723,221 +1708,6 @@ func ParentRecordIDLTE(v int64) predicate.InspectionRecord {
return predicate.InspectionRecord(sql.FieldLTE(FieldParentRecordID, v))
}
-// DisposalTypeEQ applies the EQ predicate on the "disposal_type" field.
-func DisposalTypeEQ(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEQ(FieldDisposalType, v))
-}
-
-// DisposalTypeNEQ applies the NEQ predicate on the "disposal_type" field.
-func DisposalTypeNEQ(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNEQ(FieldDisposalType, v))
-}
-
-// DisposalTypeIn applies the In predicate on the "disposal_type" field.
-func DisposalTypeIn(vs ...string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldIn(FieldDisposalType, vs...))
-}
-
-// DisposalTypeNotIn applies the NotIn predicate on the "disposal_type" field.
-func DisposalTypeNotIn(vs ...string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNotIn(FieldDisposalType, vs...))
-}
-
-// DisposalTypeGT applies the GT predicate on the "disposal_type" field.
-func DisposalTypeGT(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldGT(FieldDisposalType, v))
-}
-
-// DisposalTypeGTE applies the GTE predicate on the "disposal_type" field.
-func DisposalTypeGTE(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldGTE(FieldDisposalType, v))
-}
-
-// DisposalTypeLT applies the LT predicate on the "disposal_type" field.
-func DisposalTypeLT(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldLT(FieldDisposalType, v))
-}
-
-// DisposalTypeLTE applies the LTE predicate on the "disposal_type" field.
-func DisposalTypeLTE(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldLTE(FieldDisposalType, v))
-}
-
-// DisposalTypeContains applies the Contains predicate on the "disposal_type" field.
-func DisposalTypeContains(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldContains(FieldDisposalType, v))
-}
-
-// DisposalTypeHasPrefix applies the HasPrefix predicate on the "disposal_type" field.
-func DisposalTypeHasPrefix(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldHasPrefix(FieldDisposalType, v))
-}
-
-// DisposalTypeHasSuffix applies the HasSuffix predicate on the "disposal_type" field.
-func DisposalTypeHasSuffix(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldHasSuffix(FieldDisposalType, v))
-}
-
-// DisposalTypeEqualFold applies the EqualFold predicate on the "disposal_type" field.
-func DisposalTypeEqualFold(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEqualFold(FieldDisposalType, v))
-}
-
-// DisposalTypeContainsFold applies the ContainsFold predicate on the "disposal_type" field.
-func DisposalTypeContainsFold(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldContainsFold(FieldDisposalType, v))
-}
-
-// DisposalRemarkEQ applies the EQ predicate on the "disposal_remark" field.
-func DisposalRemarkEQ(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEQ(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkNEQ applies the NEQ predicate on the "disposal_remark" field.
-func DisposalRemarkNEQ(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNEQ(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkIn applies the In predicate on the "disposal_remark" field.
-func DisposalRemarkIn(vs ...string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldIn(FieldDisposalRemark, vs...))
-}
-
-// DisposalRemarkNotIn applies the NotIn predicate on the "disposal_remark" field.
-func DisposalRemarkNotIn(vs ...string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNotIn(FieldDisposalRemark, vs...))
-}
-
-// DisposalRemarkGT applies the GT predicate on the "disposal_remark" field.
-func DisposalRemarkGT(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldGT(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkGTE applies the GTE predicate on the "disposal_remark" field.
-func DisposalRemarkGTE(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldGTE(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkLT applies the LT predicate on the "disposal_remark" field.
-func DisposalRemarkLT(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldLT(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkLTE applies the LTE predicate on the "disposal_remark" field.
-func DisposalRemarkLTE(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldLTE(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkContains applies the Contains predicate on the "disposal_remark" field.
-func DisposalRemarkContains(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldContains(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkHasPrefix applies the HasPrefix predicate on the "disposal_remark" field.
-func DisposalRemarkHasPrefix(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldHasPrefix(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkHasSuffix applies the HasSuffix predicate on the "disposal_remark" field.
-func DisposalRemarkHasSuffix(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldHasSuffix(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkIsNil applies the IsNil predicate on the "disposal_remark" field.
-func DisposalRemarkIsNil() predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldIsNull(FieldDisposalRemark))
-}
-
-// DisposalRemarkNotNil applies the NotNil predicate on the "disposal_remark" field.
-func DisposalRemarkNotNil() predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNotNull(FieldDisposalRemark))
-}
-
-// DisposalRemarkEqualFold applies the EqualFold predicate on the "disposal_remark" field.
-func DisposalRemarkEqualFold(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEqualFold(FieldDisposalRemark, v))
-}
-
-// DisposalRemarkContainsFold applies the ContainsFold predicate on the "disposal_remark" field.
-func DisposalRemarkContainsFold(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldContainsFold(FieldDisposalRemark, v))
-}
-
-// ReturnTrackingNoEQ applies the EQ predicate on the "return_tracking_no" field.
-func ReturnTrackingNoEQ(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEQ(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoNEQ applies the NEQ predicate on the "return_tracking_no" field.
-func ReturnTrackingNoNEQ(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNEQ(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoIn applies the In predicate on the "return_tracking_no" field.
-func ReturnTrackingNoIn(vs ...string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldIn(FieldReturnTrackingNo, vs...))
-}
-
-// ReturnTrackingNoNotIn applies the NotIn predicate on the "return_tracking_no" field.
-func ReturnTrackingNoNotIn(vs ...string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNotIn(FieldReturnTrackingNo, vs...))
-}
-
-// ReturnTrackingNoGT applies the GT predicate on the "return_tracking_no" field.
-func ReturnTrackingNoGT(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldGT(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoGTE applies the GTE predicate on the "return_tracking_no" field.
-func ReturnTrackingNoGTE(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldGTE(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoLT applies the LT predicate on the "return_tracking_no" field.
-func ReturnTrackingNoLT(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldLT(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoLTE applies the LTE predicate on the "return_tracking_no" field.
-func ReturnTrackingNoLTE(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldLTE(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoContains applies the Contains predicate on the "return_tracking_no" field.
-func ReturnTrackingNoContains(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldContains(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoHasPrefix applies the HasPrefix predicate on the "return_tracking_no" field.
-func ReturnTrackingNoHasPrefix(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldHasPrefix(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoHasSuffix applies the HasSuffix predicate on the "return_tracking_no" field.
-func ReturnTrackingNoHasSuffix(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldHasSuffix(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoIsNil applies the IsNil predicate on the "return_tracking_no" field.
-func ReturnTrackingNoIsNil() predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldIsNull(FieldReturnTrackingNo))
-}
-
-// ReturnTrackingNoNotNil applies the NotNil predicate on the "return_tracking_no" field.
-func ReturnTrackingNoNotNil() predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldNotNull(FieldReturnTrackingNo))
-}
-
-// ReturnTrackingNoEqualFold applies the EqualFold predicate on the "return_tracking_no" field.
-func ReturnTrackingNoEqualFold(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldEqualFold(FieldReturnTrackingNo, v))
-}
-
-// ReturnTrackingNoContainsFold applies the ContainsFold predicate on the "return_tracking_no" field.
-func ReturnTrackingNoContainsFold(v string) predicate.InspectionRecord {
- return predicate.InspectionRecord(sql.FieldContainsFold(FieldReturnTrackingNo, v))
-}
-
// RemarkEQ applies the EQ predicate on the "remark" field.
func RemarkEQ(v string) predicate.InspectionRecord {
return predicate.InspectionRecord(sql.FieldEQ(FieldRemark, v))
diff --git a/bj_power_wms/ent/inspectionrecord_create.go b/bj_power_wms/ent/inspectionrecord_create.go
index eba57f0..9859030 100644
--- a/bj_power_wms/ent/inspectionrecord_create.go
+++ b/bj_power_wms/ent/inspectionrecord_create.go
@@ -333,48 +333,6 @@ func (_c *InspectionRecordCreate) SetNillableParentRecordID(v *int64) *Inspectio
return _c
}
-// SetDisposalType sets the "disposal_type" field.
-func (_c *InspectionRecordCreate) SetDisposalType(v string) *InspectionRecordCreate {
- _c.mutation.SetDisposalType(v)
- return _c
-}
-
-// SetNillableDisposalType sets the "disposal_type" field if the given value is not nil.
-func (_c *InspectionRecordCreate) SetNillableDisposalType(v *string) *InspectionRecordCreate {
- if v != nil {
- _c.SetDisposalType(*v)
- }
- return _c
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (_c *InspectionRecordCreate) SetDisposalRemark(v string) *InspectionRecordCreate {
- _c.mutation.SetDisposalRemark(v)
- return _c
-}
-
-// SetNillableDisposalRemark sets the "disposal_remark" field if the given value is not nil.
-func (_c *InspectionRecordCreate) SetNillableDisposalRemark(v *string) *InspectionRecordCreate {
- if v != nil {
- _c.SetDisposalRemark(*v)
- }
- return _c
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (_c *InspectionRecordCreate) SetReturnTrackingNo(v string) *InspectionRecordCreate {
- _c.mutation.SetReturnTrackingNo(v)
- return _c
-}
-
-// SetNillableReturnTrackingNo sets the "return_tracking_no" field if the given value is not nil.
-func (_c *InspectionRecordCreate) SetNillableReturnTrackingNo(v *string) *InspectionRecordCreate {
- if v != nil {
- _c.SetReturnTrackingNo(*v)
- }
- return _c
-}
-
// SetRemark sets the "remark" field.
func (_c *InspectionRecordCreate) SetRemark(v string) *InspectionRecordCreate {
_c.mutation.SetRemark(v)
@@ -492,10 +450,6 @@ func (_c *InspectionRecordCreate) defaults() {
v := inspectionrecord.DefaultParentRecordID
_c.mutation.SetParentRecordID(v)
}
- if _, ok := _c.mutation.DisposalType(); !ok {
- v := inspectionrecord.DefaultDisposalType
- _c.mutation.SetDisposalType(v)
- }
if _, ok := _c.mutation.CreatedAt(); !ok {
v := inspectionrecord.DefaultCreatedAt()
_c.mutation.SetCreatedAt(v)
@@ -547,9 +501,6 @@ func (_c *InspectionRecordCreate) check() error {
if _, ok := _c.mutation.ParentRecordID(); !ok {
return &ValidationError{Name: "parent_record_id", err: errors.New(`ent: missing required field "InspectionRecord.parent_record_id"`)}
}
- if _, ok := _c.mutation.DisposalType(); !ok {
- return &ValidationError{Name: "disposal_type", err: errors.New(`ent: missing required field "InspectionRecord.disposal_type"`)}
- }
if _, ok := _c.mutation.CreatedAt(); !ok {
return &ValidationError{Name: "created_at", err: errors.New(`ent: missing required field "InspectionRecord.created_at"`)}
}
@@ -679,18 +630,6 @@ func (_c *InspectionRecordCreate) createSpec() (*InspectionRecord, *sqlgraph.Cre
_spec.SetField(inspectionrecord.FieldParentRecordID, field.TypeInt64, value)
_node.ParentRecordID = value
}
- if value, ok := _c.mutation.DisposalType(); ok {
- _spec.SetField(inspectionrecord.FieldDisposalType, field.TypeString, value)
- _node.DisposalType = value
- }
- if value, ok := _c.mutation.DisposalRemark(); ok {
- _spec.SetField(inspectionrecord.FieldDisposalRemark, field.TypeString, value)
- _node.DisposalRemark = value
- }
- if value, ok := _c.mutation.ReturnTrackingNo(); ok {
- _spec.SetField(inspectionrecord.FieldReturnTrackingNo, field.TypeString, value)
- _node.ReturnTrackingNo = value
- }
if value, ok := _c.mutation.Remark(); ok {
_spec.SetField(inspectionrecord.FieldRemark, field.TypeString, value)
_node.Remark = value
@@ -1145,54 +1084,6 @@ func (u *InspectionRecordUpsert) AddParentRecordID(v int64) *InspectionRecordUps
return u
}
-// SetDisposalType sets the "disposal_type" field.
-func (u *InspectionRecordUpsert) SetDisposalType(v string) *InspectionRecordUpsert {
- u.Set(inspectionrecord.FieldDisposalType, v)
- return u
-}
-
-// UpdateDisposalType sets the "disposal_type" field to the value that was provided on create.
-func (u *InspectionRecordUpsert) UpdateDisposalType() *InspectionRecordUpsert {
- u.SetExcluded(inspectionrecord.FieldDisposalType)
- return u
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (u *InspectionRecordUpsert) SetDisposalRemark(v string) *InspectionRecordUpsert {
- u.Set(inspectionrecord.FieldDisposalRemark, v)
- return u
-}
-
-// UpdateDisposalRemark sets the "disposal_remark" field to the value that was provided on create.
-func (u *InspectionRecordUpsert) UpdateDisposalRemark() *InspectionRecordUpsert {
- u.SetExcluded(inspectionrecord.FieldDisposalRemark)
- return u
-}
-
-// ClearDisposalRemark clears the value of the "disposal_remark" field.
-func (u *InspectionRecordUpsert) ClearDisposalRemark() *InspectionRecordUpsert {
- u.SetNull(inspectionrecord.FieldDisposalRemark)
- return u
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (u *InspectionRecordUpsert) SetReturnTrackingNo(v string) *InspectionRecordUpsert {
- u.Set(inspectionrecord.FieldReturnTrackingNo, v)
- return u
-}
-
-// UpdateReturnTrackingNo sets the "return_tracking_no" field to the value that was provided on create.
-func (u *InspectionRecordUpsert) UpdateReturnTrackingNo() *InspectionRecordUpsert {
- u.SetExcluded(inspectionrecord.FieldReturnTrackingNo)
- return u
-}
-
-// ClearReturnTrackingNo clears the value of the "return_tracking_no" field.
-func (u *InspectionRecordUpsert) ClearReturnTrackingNo() *InspectionRecordUpsert {
- u.SetNull(inspectionrecord.FieldReturnTrackingNo)
- return u
-}
-
// SetRemark sets the "remark" field.
func (u *InspectionRecordUpsert) SetRemark(v string) *InspectionRecordUpsert {
u.Set(inspectionrecord.FieldRemark, v)
@@ -1742,62 +1633,6 @@ func (u *InspectionRecordUpsertOne) UpdateParentRecordID() *InspectionRecordUpse
})
}
-// SetDisposalType sets the "disposal_type" field.
-func (u *InspectionRecordUpsertOne) SetDisposalType(v string) *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.SetDisposalType(v)
- })
-}
-
-// UpdateDisposalType sets the "disposal_type" field to the value that was provided on create.
-func (u *InspectionRecordUpsertOne) UpdateDisposalType() *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.UpdateDisposalType()
- })
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (u *InspectionRecordUpsertOne) SetDisposalRemark(v string) *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.SetDisposalRemark(v)
- })
-}
-
-// UpdateDisposalRemark sets the "disposal_remark" field to the value that was provided on create.
-func (u *InspectionRecordUpsertOne) UpdateDisposalRemark() *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.UpdateDisposalRemark()
- })
-}
-
-// ClearDisposalRemark clears the value of the "disposal_remark" field.
-func (u *InspectionRecordUpsertOne) ClearDisposalRemark() *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.ClearDisposalRemark()
- })
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (u *InspectionRecordUpsertOne) SetReturnTrackingNo(v string) *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.SetReturnTrackingNo(v)
- })
-}
-
-// UpdateReturnTrackingNo sets the "return_tracking_no" field to the value that was provided on create.
-func (u *InspectionRecordUpsertOne) UpdateReturnTrackingNo() *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.UpdateReturnTrackingNo()
- })
-}
-
-// ClearReturnTrackingNo clears the value of the "return_tracking_no" field.
-func (u *InspectionRecordUpsertOne) ClearReturnTrackingNo() *InspectionRecordUpsertOne {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.ClearReturnTrackingNo()
- })
-}
-
// SetRemark sets the "remark" field.
func (u *InspectionRecordUpsertOne) SetRemark(v string) *InspectionRecordUpsertOne {
return u.Update(func(s *InspectionRecordUpsert) {
@@ -2520,62 +2355,6 @@ func (u *InspectionRecordUpsertBulk) UpdateParentRecordID() *InspectionRecordUps
})
}
-// SetDisposalType sets the "disposal_type" field.
-func (u *InspectionRecordUpsertBulk) SetDisposalType(v string) *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.SetDisposalType(v)
- })
-}
-
-// UpdateDisposalType sets the "disposal_type" field to the value that was provided on create.
-func (u *InspectionRecordUpsertBulk) UpdateDisposalType() *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.UpdateDisposalType()
- })
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (u *InspectionRecordUpsertBulk) SetDisposalRemark(v string) *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.SetDisposalRemark(v)
- })
-}
-
-// UpdateDisposalRemark sets the "disposal_remark" field to the value that was provided on create.
-func (u *InspectionRecordUpsertBulk) UpdateDisposalRemark() *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.UpdateDisposalRemark()
- })
-}
-
-// ClearDisposalRemark clears the value of the "disposal_remark" field.
-func (u *InspectionRecordUpsertBulk) ClearDisposalRemark() *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.ClearDisposalRemark()
- })
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (u *InspectionRecordUpsertBulk) SetReturnTrackingNo(v string) *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.SetReturnTrackingNo(v)
- })
-}
-
-// UpdateReturnTrackingNo sets the "return_tracking_no" field to the value that was provided on create.
-func (u *InspectionRecordUpsertBulk) UpdateReturnTrackingNo() *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.UpdateReturnTrackingNo()
- })
-}
-
-// ClearReturnTrackingNo clears the value of the "return_tracking_no" field.
-func (u *InspectionRecordUpsertBulk) ClearReturnTrackingNo() *InspectionRecordUpsertBulk {
- return u.Update(func(s *InspectionRecordUpsert) {
- s.ClearReturnTrackingNo()
- })
-}
-
// SetRemark sets the "remark" field.
func (u *InspectionRecordUpsertBulk) SetRemark(v string) *InspectionRecordUpsertBulk {
return u.Update(func(s *InspectionRecordUpsert) {
diff --git a/bj_power_wms/ent/inspectionrecord_update.go b/bj_power_wms/ent/inspectionrecord_update.go
index 49ef0c2..95145e9 100644
--- a/bj_power_wms/ent/inspectionrecord_update.go
+++ b/bj_power_wms/ent/inspectionrecord_update.go
@@ -471,60 +471,6 @@ func (_u *InspectionRecordUpdate) AddParentRecordID(v int64) *InspectionRecordUp
return _u
}
-// SetDisposalType sets the "disposal_type" field.
-func (_u *InspectionRecordUpdate) SetDisposalType(v string) *InspectionRecordUpdate {
- _u.mutation.SetDisposalType(v)
- return _u
-}
-
-// SetNillableDisposalType sets the "disposal_type" field if the given value is not nil.
-func (_u *InspectionRecordUpdate) SetNillableDisposalType(v *string) *InspectionRecordUpdate {
- if v != nil {
- _u.SetDisposalType(*v)
- }
- return _u
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (_u *InspectionRecordUpdate) SetDisposalRemark(v string) *InspectionRecordUpdate {
- _u.mutation.SetDisposalRemark(v)
- return _u
-}
-
-// SetNillableDisposalRemark sets the "disposal_remark" field if the given value is not nil.
-func (_u *InspectionRecordUpdate) SetNillableDisposalRemark(v *string) *InspectionRecordUpdate {
- if v != nil {
- _u.SetDisposalRemark(*v)
- }
- return _u
-}
-
-// ClearDisposalRemark clears the value of the "disposal_remark" field.
-func (_u *InspectionRecordUpdate) ClearDisposalRemark() *InspectionRecordUpdate {
- _u.mutation.ClearDisposalRemark()
- return _u
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (_u *InspectionRecordUpdate) SetReturnTrackingNo(v string) *InspectionRecordUpdate {
- _u.mutation.SetReturnTrackingNo(v)
- return _u
-}
-
-// SetNillableReturnTrackingNo sets the "return_tracking_no" field if the given value is not nil.
-func (_u *InspectionRecordUpdate) SetNillableReturnTrackingNo(v *string) *InspectionRecordUpdate {
- if v != nil {
- _u.SetReturnTrackingNo(*v)
- }
- return _u
-}
-
-// ClearReturnTrackingNo clears the value of the "return_tracking_no" field.
-func (_u *InspectionRecordUpdate) ClearReturnTrackingNo() *InspectionRecordUpdate {
- _u.mutation.ClearReturnTrackingNo()
- return _u
-}
-
// SetRemark sets the "remark" field.
func (_u *InspectionRecordUpdate) SetRemark(v string) *InspectionRecordUpdate {
_u.mutation.SetRemark(v)
@@ -751,21 +697,6 @@ func (_u *InspectionRecordUpdate) sqlSave(ctx context.Context) (_node int, err e
if value, ok := _u.mutation.AddedParentRecordID(); ok {
_spec.AddField(inspectionrecord.FieldParentRecordID, field.TypeInt64, value)
}
- if value, ok := _u.mutation.DisposalType(); ok {
- _spec.SetField(inspectionrecord.FieldDisposalType, field.TypeString, value)
- }
- if value, ok := _u.mutation.DisposalRemark(); ok {
- _spec.SetField(inspectionrecord.FieldDisposalRemark, field.TypeString, value)
- }
- if _u.mutation.DisposalRemarkCleared() {
- _spec.ClearField(inspectionrecord.FieldDisposalRemark, field.TypeString)
- }
- if value, ok := _u.mutation.ReturnTrackingNo(); ok {
- _spec.SetField(inspectionrecord.FieldReturnTrackingNo, field.TypeString, value)
- }
- if _u.mutation.ReturnTrackingNoCleared() {
- _spec.ClearField(inspectionrecord.FieldReturnTrackingNo, field.TypeString)
- }
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(inspectionrecord.FieldRemark, field.TypeString, value)
}
@@ -1248,60 +1179,6 @@ func (_u *InspectionRecordUpdateOne) AddParentRecordID(v int64) *InspectionRecor
return _u
}
-// SetDisposalType sets the "disposal_type" field.
-func (_u *InspectionRecordUpdateOne) SetDisposalType(v string) *InspectionRecordUpdateOne {
- _u.mutation.SetDisposalType(v)
- return _u
-}
-
-// SetNillableDisposalType sets the "disposal_type" field if the given value is not nil.
-func (_u *InspectionRecordUpdateOne) SetNillableDisposalType(v *string) *InspectionRecordUpdateOne {
- if v != nil {
- _u.SetDisposalType(*v)
- }
- return _u
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (_u *InspectionRecordUpdateOne) SetDisposalRemark(v string) *InspectionRecordUpdateOne {
- _u.mutation.SetDisposalRemark(v)
- return _u
-}
-
-// SetNillableDisposalRemark sets the "disposal_remark" field if the given value is not nil.
-func (_u *InspectionRecordUpdateOne) SetNillableDisposalRemark(v *string) *InspectionRecordUpdateOne {
- if v != nil {
- _u.SetDisposalRemark(*v)
- }
- return _u
-}
-
-// ClearDisposalRemark clears the value of the "disposal_remark" field.
-func (_u *InspectionRecordUpdateOne) ClearDisposalRemark() *InspectionRecordUpdateOne {
- _u.mutation.ClearDisposalRemark()
- return _u
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (_u *InspectionRecordUpdateOne) SetReturnTrackingNo(v string) *InspectionRecordUpdateOne {
- _u.mutation.SetReturnTrackingNo(v)
- return _u
-}
-
-// SetNillableReturnTrackingNo sets the "return_tracking_no" field if the given value is not nil.
-func (_u *InspectionRecordUpdateOne) SetNillableReturnTrackingNo(v *string) *InspectionRecordUpdateOne {
- if v != nil {
- _u.SetReturnTrackingNo(*v)
- }
- return _u
-}
-
-// ClearReturnTrackingNo clears the value of the "return_tracking_no" field.
-func (_u *InspectionRecordUpdateOne) ClearReturnTrackingNo() *InspectionRecordUpdateOne {
- _u.mutation.ClearReturnTrackingNo()
- return _u
-}
-
// SetRemark sets the "remark" field.
func (_u *InspectionRecordUpdateOne) SetRemark(v string) *InspectionRecordUpdateOne {
_u.mutation.SetRemark(v)
@@ -1558,21 +1435,6 @@ func (_u *InspectionRecordUpdateOne) sqlSave(ctx context.Context) (_node *Inspec
if value, ok := _u.mutation.AddedParentRecordID(); ok {
_spec.AddField(inspectionrecord.FieldParentRecordID, field.TypeInt64, value)
}
- if value, ok := _u.mutation.DisposalType(); ok {
- _spec.SetField(inspectionrecord.FieldDisposalType, field.TypeString, value)
- }
- if value, ok := _u.mutation.DisposalRemark(); ok {
- _spec.SetField(inspectionrecord.FieldDisposalRemark, field.TypeString, value)
- }
- if _u.mutation.DisposalRemarkCleared() {
- _spec.ClearField(inspectionrecord.FieldDisposalRemark, field.TypeString)
- }
- if value, ok := _u.mutation.ReturnTrackingNo(); ok {
- _spec.SetField(inspectionrecord.FieldReturnTrackingNo, field.TypeString, value)
- }
- if _u.mutation.ReturnTrackingNoCleared() {
- _spec.ClearField(inspectionrecord.FieldReturnTrackingNo, field.TypeString)
- }
if value, ok := _u.mutation.Remark(); ok {
_spec.SetField(inspectionrecord.FieldRemark, field.TypeString, value)
}
diff --git a/bj_power_wms/ent/migrate/schema.go b/bj_power_wms/ent/migrate/schema.go
index 21c342d..9220bc0 100644
--- a/bj_power_wms/ent/migrate/schema.go
+++ b/bj_power_wms/ent/migrate/schema.go
@@ -336,6 +336,30 @@ var (
},
},
}
+ // InspectionDisposalItemsColumns holds the columns for the "inspection_disposal_items" table.
+ InspectionDisposalItemsColumns = []*schema.Column{
+ {Name: "id", Type: field.TypeInt, Increment: true},
+ {Name: "record_id", Type: field.TypeInt64, Comment: "父检验记录ID(inspection_records.id)"},
+ {Name: "dispose_type", Type: field.TypeString, Comment: "处置方式 RETURN/REWORK/SCRAP"},
+ {Name: "qty", Type: field.TypeInt, Comment: "本行处置数量(合计=记录不合格数)"},
+ {Name: "remark", Type: field.TypeString, Nullable: true, Comment: "处置备注(非必填;退货物流信息也填此处)"},
+ {Name: "operator", Type: field.TypeString, Comment: "操作人", Default: ""},
+ {Name: "created_at", Type: field.TypeInt64},
+ }
+ // InspectionDisposalItemsTable holds the schema information for the "inspection_disposal_items" table.
+ InspectionDisposalItemsTable = &schema.Table{
+ Name: "inspection_disposal_items",
+ Comment: "InspectionDisposalItem 不合格品处置明细(按数量分退货/返修/报废)",
+ Columns: InspectionDisposalItemsColumns,
+ PrimaryKey: []*schema.Column{InspectionDisposalItemsColumns[0]},
+ Indexes: []*schema.Index{
+ {
+ Name: "inspectiondisposalitem_record_id",
+ Unique: false,
+ Columns: []*schema.Column{InspectionDisposalItemsColumns[1]},
+ },
+ },
+ }
// InspectionRecordsColumns holds the columns for the "inspection_records" table.
InspectionRecordsColumns = []*schema.Column{
{Name: "id", Type: field.TypeInt, Increment: true},
@@ -361,11 +385,8 @@ var (
{Name: "inspection_no", Type: field.TypeString, Nullable: true, Comment: "检测单号(检验报告单号)"},
{Name: "report_no", Type: field.TypeString, Nullable: true, Comment: "报检单号(生产报检关联)"},
{Name: "inspection_conclusion", Type: field.TypeString, Comment: "检验结论 合格/不合格/待检/挑选(与处置方式正交)", Default: ""},
- {Name: "disposal_status", Type: field.TypeString, Comment: "不合格品处置状态 待处置/退货中/已退货/返修中/已返修/已报废/已处置", Default: ""},
+ {Name: "disposal_status", Type: field.TypeString, Comment: "不合格品处置状态 待处置/已处置", Default: ""},
{Name: "parent_record_id", Type: field.TypeInt64, Comment: "拆行来源检验记录ID(不合格隔离行回挂原单)", Default: 0},
- {Name: "disposal_type", Type: field.TypeString, Comment: "不合格部分处置 NONE/RETURN/SCRAP/PARTIAL/REWORK", Default: "NONE"},
- {Name: "disposal_remark", Type: field.TypeString, Nullable: true, Comment: "处置说明(报废/退货原因)"},
- {Name: "return_tracking_no", Type: field.TypeString, Nullable: true, Comment: "退货货运单号"},
{Name: "remark", Type: field.TypeString, Nullable: true, Comment: "备注"},
{Name: "created_at", Type: field.TypeInt64},
{Name: "updated_at", Type: field.TypeInt64},
@@ -1053,6 +1074,7 @@ var (
EventLogTable,
InboundDetailsTable,
InboundOrdersTable,
+ InspectionDisposalItemsTable,
InspectionRecordsTable,
InventoriesTable,
InventoryLocksTable,
@@ -1102,6 +1124,9 @@ func init() {
InboundOrdersTable.Annotation = &entsql.Annotation{
Table: "inbound_orders",
}
+ InspectionDisposalItemsTable.Annotation = &entsql.Annotation{
+ Table: "inspection_disposal_items",
+ }
InspectionRecordsTable.Annotation = &entsql.Annotation{
Table: "inspection_records",
}
diff --git a/bj_power_wms/ent/mutation.go b/bj_power_wms/ent/mutation.go
index c821e5b..c746e97 100644
--- a/bj_power_wms/ent/mutation.go
+++ b/bj_power_wms/ent/mutation.go
@@ -12,6 +12,7 @@ import (
"bj_power_wms/ent/eventlog"
"bj_power_wms/ent/inbounddetail"
"bj_power_wms/ent/inboundorder"
+ "bj_power_wms/ent/inspectiondisposalitem"
"bj_power_wms/ent/inspectionrecord"
"bj_power_wms/ent/inventory"
"bj_power_wms/ent/inventorylock"
@@ -50,33 +51,34 @@ const (
OpUpdateOne = ent.OpUpdateOne
// Node types.
- TypeAlert = "Alert"
- TypeAlertRule = "AlertRule"
- TypeAttachment = "Attachment"
- TypeBackupRecord = "BackupRecord"
- TypeDeliveryOrder = "DeliveryOrder"
- TypeDeliveryOrderItem = "DeliveryOrderItem"
- TypeEventLog = "EventLog"
- TypeInboundDetail = "InboundDetail"
- TypeInboundOrder = "InboundOrder"
- TypeInspectionRecord = "InspectionRecord"
- TypeInventory = "Inventory"
- TypeInventoryLock = "InventoryLock"
- TypeMaterial = "Material"
- TypeMaterialDemand = "MaterialDemand"
- TypeOrderMaterialLedger = "OrderMaterialLedger"
- TypeOutboundDetail = "OutboundDetail"
- TypeOutboundOrder = "OutboundOrder"
- TypePermission = "Permission"
- TypeReturnOrder = "ReturnOrder"
- TypeRole = "Role"
- TypeSemiFinished = "SemiFinished"
- TypeStocktakeItem = "StocktakeItem"
- TypeStocktakeOrder = "StocktakeOrder"
- TypeSyncFailure = "SyncFailure"
- TypeSysConfig = "SysConfig"
- TypeUser = "User"
- TypeZone = "Zone"
+ TypeAlert = "Alert"
+ TypeAlertRule = "AlertRule"
+ TypeAttachment = "Attachment"
+ TypeBackupRecord = "BackupRecord"
+ TypeDeliveryOrder = "DeliveryOrder"
+ TypeDeliveryOrderItem = "DeliveryOrderItem"
+ TypeEventLog = "EventLog"
+ TypeInboundDetail = "InboundDetail"
+ TypeInboundOrder = "InboundOrder"
+ TypeInspectionDisposalItem = "InspectionDisposalItem"
+ TypeInspectionRecord = "InspectionRecord"
+ TypeInventory = "Inventory"
+ TypeInventoryLock = "InventoryLock"
+ TypeMaterial = "Material"
+ TypeMaterialDemand = "MaterialDemand"
+ TypeOrderMaterialLedger = "OrderMaterialLedger"
+ TypeOutboundDetail = "OutboundDetail"
+ TypeOutboundOrder = "OutboundOrder"
+ TypePermission = "Permission"
+ TypeReturnOrder = "ReturnOrder"
+ TypeRole = "Role"
+ TypeSemiFinished = "SemiFinished"
+ TypeStocktakeItem = "StocktakeItem"
+ TypeStocktakeOrder = "StocktakeOrder"
+ TypeSyncFailure = "SyncFailure"
+ TypeSysConfig = "SysConfig"
+ TypeUser = "User"
+ TypeZone = "Zone"
)
// AlertMutation represents an operation that mutates the Alert nodes in the graph.
@@ -9493,6 +9495,726 @@ func (m *InboundOrderMutation) ResetEdge(name string) error {
return fmt.Errorf("unknown InboundOrder edge %s", name)
}
+// InspectionDisposalItemMutation represents an operation that mutates the InspectionDisposalItem nodes in the graph.
+type InspectionDisposalItemMutation struct {
+ config
+ op Op
+ typ string
+ id *int
+ record_id *int64
+ addrecord_id *int64
+ dispose_type *string
+ qty *int
+ addqty *int
+ remark *string
+ operator *string
+ created_at *int64
+ addcreated_at *int64
+ clearedFields map[string]struct{}
+ done bool
+ oldValue func(context.Context) (*InspectionDisposalItem, error)
+ predicates []predicate.InspectionDisposalItem
+}
+
+var _ ent.Mutation = (*InspectionDisposalItemMutation)(nil)
+
+// inspectiondisposalitemOption allows management of the mutation configuration using functional options.
+type inspectiondisposalitemOption func(*InspectionDisposalItemMutation)
+
+// newInspectionDisposalItemMutation creates new mutation for the InspectionDisposalItem entity.
+func newInspectionDisposalItemMutation(c config, op Op, opts ...inspectiondisposalitemOption) *InspectionDisposalItemMutation {
+ m := &InspectionDisposalItemMutation{
+ config: c,
+ op: op,
+ typ: TypeInspectionDisposalItem,
+ clearedFields: make(map[string]struct{}),
+ }
+ for _, opt := range opts {
+ opt(m)
+ }
+ return m
+}
+
+// withInspectionDisposalItemID sets the ID field of the mutation.
+func withInspectionDisposalItemID(id int) inspectiondisposalitemOption {
+ return func(m *InspectionDisposalItemMutation) {
+ var (
+ err error
+ once sync.Once
+ value *InspectionDisposalItem
+ )
+ m.oldValue = func(ctx context.Context) (*InspectionDisposalItem, error) {
+ once.Do(func() {
+ if m.done {
+ err = errors.New("querying old values post mutation is not allowed")
+ } else {
+ value, err = m.Client().InspectionDisposalItem.Get(ctx, id)
+ }
+ })
+ return value, err
+ }
+ m.id = &id
+ }
+}
+
+// withInspectionDisposalItem sets the old InspectionDisposalItem of the mutation.
+func withInspectionDisposalItem(node *InspectionDisposalItem) inspectiondisposalitemOption {
+ return func(m *InspectionDisposalItemMutation) {
+ m.oldValue = func(context.Context) (*InspectionDisposalItem, error) {
+ return node, nil
+ }
+ m.id = &node.ID
+ }
+}
+
+// Client returns a new `ent.Client` from the mutation. If the mutation was
+// executed in a transaction (ent.Tx), a transactional client is returned.
+func (m InspectionDisposalItemMutation) Client() *Client {
+ client := &Client{config: m.config}
+ client.init()
+ return client
+}
+
+// Tx returns an `ent.Tx` for mutations that were executed in transactions;
+// it returns an error otherwise.
+func (m InspectionDisposalItemMutation) Tx() (*Tx, error) {
+ if _, ok := m.driver.(*txDriver); !ok {
+ return nil, errors.New("ent: mutation is not running in a transaction")
+ }
+ tx := &Tx{config: m.config}
+ tx.init()
+ return tx, nil
+}
+
+// ID returns the ID value in the mutation. Note that the ID is only available
+// if it was provided to the builder or after it was returned from the database.
+func (m *InspectionDisposalItemMutation) ID() (id int, exists bool) {
+ if m.id == nil {
+ return
+ }
+ return *m.id, true
+}
+
+// IDs queries the database and returns the entity ids that match the mutation's predicate.
+// That means, if the mutation is applied within a transaction with an isolation level such
+// as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
+// or updated by the mutation.
+func (m *InspectionDisposalItemMutation) IDs(ctx context.Context) ([]int, error) {
+ switch {
+ case m.op.Is(OpUpdateOne | OpDeleteOne):
+ id, exists := m.ID()
+ if exists {
+ return []int{id}, nil
+ }
+ fallthrough
+ case m.op.Is(OpUpdate | OpDelete):
+ return m.Client().InspectionDisposalItem.Query().Where(m.predicates...).IDs(ctx)
+ default:
+ return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
+ }
+}
+
+// SetRecordID sets the "record_id" field.
+func (m *InspectionDisposalItemMutation) SetRecordID(i int64) {
+ m.record_id = &i
+ m.addrecord_id = nil
+}
+
+// RecordID returns the value of the "record_id" field in the mutation.
+func (m *InspectionDisposalItemMutation) RecordID() (r int64, exists bool) {
+ v := m.record_id
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldRecordID returns the old "record_id" field's value of the InspectionDisposalItem entity.
+// If the InspectionDisposalItem object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *InspectionDisposalItemMutation) OldRecordID(ctx context.Context) (v int64, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldRecordID is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldRecordID requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldRecordID: %w", err)
+ }
+ return oldValue.RecordID, nil
+}
+
+// AddRecordID adds i to the "record_id" field.
+func (m *InspectionDisposalItemMutation) AddRecordID(i int64) {
+ if m.addrecord_id != nil {
+ *m.addrecord_id += i
+ } else {
+ m.addrecord_id = &i
+ }
+}
+
+// AddedRecordID returns the value that was added to the "record_id" field in this mutation.
+func (m *InspectionDisposalItemMutation) AddedRecordID() (r int64, exists bool) {
+ v := m.addrecord_id
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// ResetRecordID resets all changes to the "record_id" field.
+func (m *InspectionDisposalItemMutation) ResetRecordID() {
+ m.record_id = nil
+ m.addrecord_id = nil
+}
+
+// SetDisposeType sets the "dispose_type" field.
+func (m *InspectionDisposalItemMutation) SetDisposeType(s string) {
+ m.dispose_type = &s
+}
+
+// DisposeType returns the value of the "dispose_type" field in the mutation.
+func (m *InspectionDisposalItemMutation) DisposeType() (r string, exists bool) {
+ v := m.dispose_type
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldDisposeType returns the old "dispose_type" field's value of the InspectionDisposalItem entity.
+// If the InspectionDisposalItem object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *InspectionDisposalItemMutation) OldDisposeType(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldDisposeType is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldDisposeType requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldDisposeType: %w", err)
+ }
+ return oldValue.DisposeType, nil
+}
+
+// ResetDisposeType resets all changes to the "dispose_type" field.
+func (m *InspectionDisposalItemMutation) ResetDisposeType() {
+ m.dispose_type = nil
+}
+
+// SetQty sets the "qty" field.
+func (m *InspectionDisposalItemMutation) SetQty(i int) {
+ m.qty = &i
+ m.addqty = nil
+}
+
+// Qty returns the value of the "qty" field in the mutation.
+func (m *InspectionDisposalItemMutation) Qty() (r int, exists bool) {
+ v := m.qty
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldQty returns the old "qty" field's value of the InspectionDisposalItem entity.
+// If the InspectionDisposalItem object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *InspectionDisposalItemMutation) OldQty(ctx context.Context) (v int, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldQty is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldQty requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldQty: %w", err)
+ }
+ return oldValue.Qty, nil
+}
+
+// AddQty adds i to the "qty" field.
+func (m *InspectionDisposalItemMutation) AddQty(i int) {
+ if m.addqty != nil {
+ *m.addqty += i
+ } else {
+ m.addqty = &i
+ }
+}
+
+// AddedQty returns the value that was added to the "qty" field in this mutation.
+func (m *InspectionDisposalItemMutation) AddedQty() (r int, exists bool) {
+ v := m.addqty
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// ResetQty resets all changes to the "qty" field.
+func (m *InspectionDisposalItemMutation) ResetQty() {
+ m.qty = nil
+ m.addqty = nil
+}
+
+// SetRemark sets the "remark" field.
+func (m *InspectionDisposalItemMutation) SetRemark(s string) {
+ m.remark = &s
+}
+
+// Remark returns the value of the "remark" field in the mutation.
+func (m *InspectionDisposalItemMutation) Remark() (r string, exists bool) {
+ v := m.remark
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldRemark returns the old "remark" field's value of the InspectionDisposalItem entity.
+// If the InspectionDisposalItem object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *InspectionDisposalItemMutation) OldRemark(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldRemark is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldRemark requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldRemark: %w", err)
+ }
+ return oldValue.Remark, nil
+}
+
+// ClearRemark clears the value of the "remark" field.
+func (m *InspectionDisposalItemMutation) ClearRemark() {
+ m.remark = nil
+ m.clearedFields[inspectiondisposalitem.FieldRemark] = struct{}{}
+}
+
+// RemarkCleared returns if the "remark" field was cleared in this mutation.
+func (m *InspectionDisposalItemMutation) RemarkCleared() bool {
+ _, ok := m.clearedFields[inspectiondisposalitem.FieldRemark]
+ return ok
+}
+
+// ResetRemark resets all changes to the "remark" field.
+func (m *InspectionDisposalItemMutation) ResetRemark() {
+ m.remark = nil
+ delete(m.clearedFields, inspectiondisposalitem.FieldRemark)
+}
+
+// SetOperator sets the "operator" field.
+func (m *InspectionDisposalItemMutation) SetOperator(s string) {
+ m.operator = &s
+}
+
+// Operator returns the value of the "operator" field in the mutation.
+func (m *InspectionDisposalItemMutation) Operator() (r string, exists bool) {
+ v := m.operator
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldOperator returns the old "operator" field's value of the InspectionDisposalItem entity.
+// If the InspectionDisposalItem object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *InspectionDisposalItemMutation) OldOperator(ctx context.Context) (v string, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldOperator is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldOperator requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldOperator: %w", err)
+ }
+ return oldValue.Operator, nil
+}
+
+// ResetOperator resets all changes to the "operator" field.
+func (m *InspectionDisposalItemMutation) ResetOperator() {
+ m.operator = nil
+}
+
+// SetCreatedAt sets the "created_at" field.
+func (m *InspectionDisposalItemMutation) SetCreatedAt(i int64) {
+ m.created_at = &i
+ m.addcreated_at = nil
+}
+
+// CreatedAt returns the value of the "created_at" field in the mutation.
+func (m *InspectionDisposalItemMutation) CreatedAt() (r int64, exists bool) {
+ v := m.created_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// OldCreatedAt returns the old "created_at" field's value of the InspectionDisposalItem entity.
+// If the InspectionDisposalItem object wasn't provided to the builder, the object is fetched from the database.
+// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
+func (m *InspectionDisposalItemMutation) OldCreatedAt(ctx context.Context) (v int64, err error) {
+ if !m.op.Is(OpUpdateOne) {
+ return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
+ }
+ if m.id == nil || m.oldValue == nil {
+ return v, errors.New("OldCreatedAt requires an ID field in the mutation")
+ }
+ oldValue, err := m.oldValue(ctx)
+ if err != nil {
+ return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
+ }
+ return oldValue.CreatedAt, nil
+}
+
+// AddCreatedAt adds i to the "created_at" field.
+func (m *InspectionDisposalItemMutation) AddCreatedAt(i int64) {
+ if m.addcreated_at != nil {
+ *m.addcreated_at += i
+ } else {
+ m.addcreated_at = &i
+ }
+}
+
+// AddedCreatedAt returns the value that was added to the "created_at" field in this mutation.
+func (m *InspectionDisposalItemMutation) AddedCreatedAt() (r int64, exists bool) {
+ v := m.addcreated_at
+ if v == nil {
+ return
+ }
+ return *v, true
+}
+
+// ResetCreatedAt resets all changes to the "created_at" field.
+func (m *InspectionDisposalItemMutation) ResetCreatedAt() {
+ m.created_at = nil
+ m.addcreated_at = nil
+}
+
+// Where appends a list predicates to the InspectionDisposalItemMutation builder.
+func (m *InspectionDisposalItemMutation) Where(ps ...predicate.InspectionDisposalItem) {
+ m.predicates = append(m.predicates, ps...)
+}
+
+// WhereP appends storage-level predicates to the InspectionDisposalItemMutation builder. Using this method,
+// users can use type-assertion to append predicates that do not depend on any generated package.
+func (m *InspectionDisposalItemMutation) WhereP(ps ...func(*sql.Selector)) {
+ p := make([]predicate.InspectionDisposalItem, len(ps))
+ for i := range ps {
+ p[i] = ps[i]
+ }
+ m.Where(p...)
+}
+
+// Op returns the operation name.
+func (m *InspectionDisposalItemMutation) Op() Op {
+ return m.op
+}
+
+// SetOp allows setting the mutation operation.
+func (m *InspectionDisposalItemMutation) SetOp(op Op) {
+ m.op = op
+}
+
+// Type returns the node type of this mutation (InspectionDisposalItem).
+func (m *InspectionDisposalItemMutation) Type() string {
+ return m.typ
+}
+
+// Fields returns all fields that were changed during this mutation. Note that in
+// order to get all numeric fields that were incremented/decremented, call
+// AddedFields().
+func (m *InspectionDisposalItemMutation) Fields() []string {
+ fields := make([]string, 0, 6)
+ if m.record_id != nil {
+ fields = append(fields, inspectiondisposalitem.FieldRecordID)
+ }
+ if m.dispose_type != nil {
+ fields = append(fields, inspectiondisposalitem.FieldDisposeType)
+ }
+ if m.qty != nil {
+ fields = append(fields, inspectiondisposalitem.FieldQty)
+ }
+ if m.remark != nil {
+ fields = append(fields, inspectiondisposalitem.FieldRemark)
+ }
+ if m.operator != nil {
+ fields = append(fields, inspectiondisposalitem.FieldOperator)
+ }
+ if m.created_at != nil {
+ fields = append(fields, inspectiondisposalitem.FieldCreatedAt)
+ }
+ return fields
+}
+
+// Field returns the value of a field with the given name. The second boolean
+// return value indicates that this field was not set, or was not defined in the
+// schema.
+func (m *InspectionDisposalItemMutation) Field(name string) (ent.Value, bool) {
+ switch name {
+ case inspectiondisposalitem.FieldRecordID:
+ return m.RecordID()
+ case inspectiondisposalitem.FieldDisposeType:
+ return m.DisposeType()
+ case inspectiondisposalitem.FieldQty:
+ return m.Qty()
+ case inspectiondisposalitem.FieldRemark:
+ return m.Remark()
+ case inspectiondisposalitem.FieldOperator:
+ return m.Operator()
+ case inspectiondisposalitem.FieldCreatedAt:
+ return m.CreatedAt()
+ }
+ return nil, false
+}
+
+// OldField returns the old value of the field from the database. An error is
+// returned if the mutation operation is not UpdateOne, or the query to the
+// database failed.
+func (m *InspectionDisposalItemMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
+ switch name {
+ case inspectiondisposalitem.FieldRecordID:
+ return m.OldRecordID(ctx)
+ case inspectiondisposalitem.FieldDisposeType:
+ return m.OldDisposeType(ctx)
+ case inspectiondisposalitem.FieldQty:
+ return m.OldQty(ctx)
+ case inspectiondisposalitem.FieldRemark:
+ return m.OldRemark(ctx)
+ case inspectiondisposalitem.FieldOperator:
+ return m.OldOperator(ctx)
+ case inspectiondisposalitem.FieldCreatedAt:
+ return m.OldCreatedAt(ctx)
+ }
+ return nil, fmt.Errorf("unknown InspectionDisposalItem field %s", name)
+}
+
+// SetField sets the value of a field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *InspectionDisposalItemMutation) SetField(name string, value ent.Value) error {
+ switch name {
+ case inspectiondisposalitem.FieldRecordID:
+ v, ok := value.(int64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetRecordID(v)
+ return nil
+ case inspectiondisposalitem.FieldDisposeType:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetDisposeType(v)
+ return nil
+ case inspectiondisposalitem.FieldQty:
+ v, ok := value.(int)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetQty(v)
+ return nil
+ case inspectiondisposalitem.FieldRemark:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetRemark(v)
+ return nil
+ case inspectiondisposalitem.FieldOperator:
+ v, ok := value.(string)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetOperator(v)
+ return nil
+ case inspectiondisposalitem.FieldCreatedAt:
+ v, ok := value.(int64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.SetCreatedAt(v)
+ return nil
+ }
+ return fmt.Errorf("unknown InspectionDisposalItem field %s", name)
+}
+
+// AddedFields returns all numeric fields that were incremented/decremented during
+// this mutation.
+func (m *InspectionDisposalItemMutation) AddedFields() []string {
+ var fields []string
+ if m.addrecord_id != nil {
+ fields = append(fields, inspectiondisposalitem.FieldRecordID)
+ }
+ if m.addqty != nil {
+ fields = append(fields, inspectiondisposalitem.FieldQty)
+ }
+ if m.addcreated_at != nil {
+ fields = append(fields, inspectiondisposalitem.FieldCreatedAt)
+ }
+ return fields
+}
+
+// AddedField returns the numeric value that was incremented/decremented on a field
+// with the given name. The second boolean return value indicates that this field
+// was not set, or was not defined in the schema.
+func (m *InspectionDisposalItemMutation) AddedField(name string) (ent.Value, bool) {
+ switch name {
+ case inspectiondisposalitem.FieldRecordID:
+ return m.AddedRecordID()
+ case inspectiondisposalitem.FieldQty:
+ return m.AddedQty()
+ case inspectiondisposalitem.FieldCreatedAt:
+ return m.AddedCreatedAt()
+ }
+ return nil, false
+}
+
+// AddField adds the value to the field with the given name. It returns an error if
+// the field is not defined in the schema, or if the type mismatched the field
+// type.
+func (m *InspectionDisposalItemMutation) AddField(name string, value ent.Value) error {
+ switch name {
+ case inspectiondisposalitem.FieldRecordID:
+ v, ok := value.(int64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.AddRecordID(v)
+ return nil
+ case inspectiondisposalitem.FieldQty:
+ v, ok := value.(int)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.AddQty(v)
+ return nil
+ case inspectiondisposalitem.FieldCreatedAt:
+ v, ok := value.(int64)
+ if !ok {
+ return fmt.Errorf("unexpected type %T for field %s", value, name)
+ }
+ m.AddCreatedAt(v)
+ return nil
+ }
+ return fmt.Errorf("unknown InspectionDisposalItem numeric field %s", name)
+}
+
+// ClearedFields returns all nullable fields that were cleared during this
+// mutation.
+func (m *InspectionDisposalItemMutation) ClearedFields() []string {
+ var fields []string
+ if m.FieldCleared(inspectiondisposalitem.FieldRemark) {
+ fields = append(fields, inspectiondisposalitem.FieldRemark)
+ }
+ return fields
+}
+
+// FieldCleared returns a boolean indicating if a field with the given name was
+// cleared in this mutation.
+func (m *InspectionDisposalItemMutation) FieldCleared(name string) bool {
+ _, ok := m.clearedFields[name]
+ return ok
+}
+
+// ClearField clears the value of the field with the given name. It returns an
+// error if the field is not defined in the schema.
+func (m *InspectionDisposalItemMutation) ClearField(name string) error {
+ switch name {
+ case inspectiondisposalitem.FieldRemark:
+ m.ClearRemark()
+ return nil
+ }
+ return fmt.Errorf("unknown InspectionDisposalItem nullable field %s", name)
+}
+
+// ResetField resets all changes in the mutation for the field with the given name.
+// It returns an error if the field is not defined in the schema.
+func (m *InspectionDisposalItemMutation) ResetField(name string) error {
+ switch name {
+ case inspectiondisposalitem.FieldRecordID:
+ m.ResetRecordID()
+ return nil
+ case inspectiondisposalitem.FieldDisposeType:
+ m.ResetDisposeType()
+ return nil
+ case inspectiondisposalitem.FieldQty:
+ m.ResetQty()
+ return nil
+ case inspectiondisposalitem.FieldRemark:
+ m.ResetRemark()
+ return nil
+ case inspectiondisposalitem.FieldOperator:
+ m.ResetOperator()
+ return nil
+ case inspectiondisposalitem.FieldCreatedAt:
+ m.ResetCreatedAt()
+ return nil
+ }
+ return fmt.Errorf("unknown InspectionDisposalItem field %s", name)
+}
+
+// AddedEdges returns all edge names that were set/added in this mutation.
+func (m *InspectionDisposalItemMutation) AddedEdges() []string {
+ edges := make([]string, 0, 0)
+ return edges
+}
+
+// AddedIDs returns all IDs (to other nodes) that were added for the given edge
+// name in this mutation.
+func (m *InspectionDisposalItemMutation) AddedIDs(name string) []ent.Value {
+ return nil
+}
+
+// RemovedEdges returns all edge names that were removed in this mutation.
+func (m *InspectionDisposalItemMutation) RemovedEdges() []string {
+ edges := make([]string, 0, 0)
+ return edges
+}
+
+// RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
+// the given name in this mutation.
+func (m *InspectionDisposalItemMutation) RemovedIDs(name string) []ent.Value {
+ return nil
+}
+
+// ClearedEdges returns all edge names that were cleared in this mutation.
+func (m *InspectionDisposalItemMutation) ClearedEdges() []string {
+ edges := make([]string, 0, 0)
+ return edges
+}
+
+// EdgeCleared returns a boolean which indicates if the edge with the given name
+// was cleared in this mutation.
+func (m *InspectionDisposalItemMutation) EdgeCleared(name string) bool {
+ return false
+}
+
+// ClearEdge clears the value of the edge with the given name. It returns an error
+// if that edge is not defined in the schema.
+func (m *InspectionDisposalItemMutation) ClearEdge(name string) error {
+ return fmt.Errorf("unknown InspectionDisposalItem unique edge %s", name)
+}
+
+// ResetEdge resets all changes to the edge with the given name in this mutation.
+// It returns an error if the edge is not defined in the schema.
+func (m *InspectionDisposalItemMutation) ResetEdge(name string) error {
+ return fmt.Errorf("unknown InspectionDisposalItem edge %s", name)
+}
+
// InspectionRecordMutation represents an operation that mutates the InspectionRecord nodes in the graph.
type InspectionRecordMutation struct {
config
@@ -9529,9 +10251,6 @@ type InspectionRecordMutation struct {
disposal_status *string
parent_record_id *int64
addparent_record_id *int64
- disposal_type *string
- disposal_remark *string
- return_tracking_no *string
remark *string
created_at *int64
addcreated_at *int64
@@ -10768,140 +11487,6 @@ func (m *InspectionRecordMutation) ResetParentRecordID() {
m.addparent_record_id = nil
}
-// SetDisposalType sets the "disposal_type" field.
-func (m *InspectionRecordMutation) SetDisposalType(s string) {
- m.disposal_type = &s
-}
-
-// DisposalType returns the value of the "disposal_type" field in the mutation.
-func (m *InspectionRecordMutation) DisposalType() (r string, exists bool) {
- v := m.disposal_type
- if v == nil {
- return
- }
- return *v, true
-}
-
-// OldDisposalType returns the old "disposal_type" field's value of the InspectionRecord entity.
-// If the InspectionRecord object wasn't provided to the builder, the object is fetched from the database.
-// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *InspectionRecordMutation) OldDisposalType(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDisposalType is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDisposalType requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDisposalType: %w", err)
- }
- return oldValue.DisposalType, nil
-}
-
-// ResetDisposalType resets all changes to the "disposal_type" field.
-func (m *InspectionRecordMutation) ResetDisposalType() {
- m.disposal_type = nil
-}
-
-// SetDisposalRemark sets the "disposal_remark" field.
-func (m *InspectionRecordMutation) SetDisposalRemark(s string) {
- m.disposal_remark = &s
-}
-
-// DisposalRemark returns the value of the "disposal_remark" field in the mutation.
-func (m *InspectionRecordMutation) DisposalRemark() (r string, exists bool) {
- v := m.disposal_remark
- if v == nil {
- return
- }
- return *v, true
-}
-
-// OldDisposalRemark returns the old "disposal_remark" field's value of the InspectionRecord entity.
-// If the InspectionRecord object wasn't provided to the builder, the object is fetched from the database.
-// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *InspectionRecordMutation) OldDisposalRemark(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldDisposalRemark is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldDisposalRemark requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldDisposalRemark: %w", err)
- }
- return oldValue.DisposalRemark, nil
-}
-
-// ClearDisposalRemark clears the value of the "disposal_remark" field.
-func (m *InspectionRecordMutation) ClearDisposalRemark() {
- m.disposal_remark = nil
- m.clearedFields[inspectionrecord.FieldDisposalRemark] = struct{}{}
-}
-
-// DisposalRemarkCleared returns if the "disposal_remark" field was cleared in this mutation.
-func (m *InspectionRecordMutation) DisposalRemarkCleared() bool {
- _, ok := m.clearedFields[inspectionrecord.FieldDisposalRemark]
- return ok
-}
-
-// ResetDisposalRemark resets all changes to the "disposal_remark" field.
-func (m *InspectionRecordMutation) ResetDisposalRemark() {
- m.disposal_remark = nil
- delete(m.clearedFields, inspectionrecord.FieldDisposalRemark)
-}
-
-// SetReturnTrackingNo sets the "return_tracking_no" field.
-func (m *InspectionRecordMutation) SetReturnTrackingNo(s string) {
- m.return_tracking_no = &s
-}
-
-// ReturnTrackingNo returns the value of the "return_tracking_no" field in the mutation.
-func (m *InspectionRecordMutation) ReturnTrackingNo() (r string, exists bool) {
- v := m.return_tracking_no
- if v == nil {
- return
- }
- return *v, true
-}
-
-// OldReturnTrackingNo returns the old "return_tracking_no" field's value of the InspectionRecord entity.
-// If the InspectionRecord object wasn't provided to the builder, the object is fetched from the database.
-// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
-func (m *InspectionRecordMutation) OldReturnTrackingNo(ctx context.Context) (v string, err error) {
- if !m.op.Is(OpUpdateOne) {
- return v, errors.New("OldReturnTrackingNo is only allowed on UpdateOne operations")
- }
- if m.id == nil || m.oldValue == nil {
- return v, errors.New("OldReturnTrackingNo requires an ID field in the mutation")
- }
- oldValue, err := m.oldValue(ctx)
- if err != nil {
- return v, fmt.Errorf("querying old value for OldReturnTrackingNo: %w", err)
- }
- return oldValue.ReturnTrackingNo, nil
-}
-
-// ClearReturnTrackingNo clears the value of the "return_tracking_no" field.
-func (m *InspectionRecordMutation) ClearReturnTrackingNo() {
- m.return_tracking_no = nil
- m.clearedFields[inspectionrecord.FieldReturnTrackingNo] = struct{}{}
-}
-
-// ReturnTrackingNoCleared returns if the "return_tracking_no" field was cleared in this mutation.
-func (m *InspectionRecordMutation) ReturnTrackingNoCleared() bool {
- _, ok := m.clearedFields[inspectionrecord.FieldReturnTrackingNo]
- return ok
-}
-
-// ResetReturnTrackingNo resets all changes to the "return_tracking_no" field.
-func (m *InspectionRecordMutation) ResetReturnTrackingNo() {
- m.return_tracking_no = nil
- delete(m.clearedFields, inspectionrecord.FieldReturnTrackingNo)
-}
-
// SetRemark sets the "remark" field.
func (m *InspectionRecordMutation) SetRemark(s string) {
m.remark = &s
@@ -11097,7 +11682,7 @@ func (m *InspectionRecordMutation) Type() string {
// order to get all numeric fields that were incremented/decremented, call
// AddedFields().
func (m *InspectionRecordMutation) Fields() []string {
- fields := make([]string, 0, 30)
+ fields := make([]string, 0, 27)
if m.target_type != nil {
fields = append(fields, inspectionrecord.FieldTargetType)
}
@@ -11170,15 +11755,6 @@ func (m *InspectionRecordMutation) Fields() []string {
if m.parent_record_id != nil {
fields = append(fields, inspectionrecord.FieldParentRecordID)
}
- if m.disposal_type != nil {
- fields = append(fields, inspectionrecord.FieldDisposalType)
- }
- if m.disposal_remark != nil {
- fields = append(fields, inspectionrecord.FieldDisposalRemark)
- }
- if m.return_tracking_no != nil {
- fields = append(fields, inspectionrecord.FieldReturnTrackingNo)
- }
if m.remark != nil {
fields = append(fields, inspectionrecord.FieldRemark)
}
@@ -11244,12 +11820,6 @@ func (m *InspectionRecordMutation) Field(name string) (ent.Value, bool) {
return m.DisposalStatus()
case inspectionrecord.FieldParentRecordID:
return m.ParentRecordID()
- case inspectionrecord.FieldDisposalType:
- return m.DisposalType()
- case inspectionrecord.FieldDisposalRemark:
- return m.DisposalRemark()
- case inspectionrecord.FieldReturnTrackingNo:
- return m.ReturnTrackingNo()
case inspectionrecord.FieldRemark:
return m.Remark()
case inspectionrecord.FieldCreatedAt:
@@ -11313,12 +11883,6 @@ func (m *InspectionRecordMutation) OldField(ctx context.Context, name string) (e
return m.OldDisposalStatus(ctx)
case inspectionrecord.FieldParentRecordID:
return m.OldParentRecordID(ctx)
- case inspectionrecord.FieldDisposalType:
- return m.OldDisposalType(ctx)
- case inspectionrecord.FieldDisposalRemark:
- return m.OldDisposalRemark(ctx)
- case inspectionrecord.FieldReturnTrackingNo:
- return m.OldReturnTrackingNo(ctx)
case inspectionrecord.FieldRemark:
return m.OldRemark(ctx)
case inspectionrecord.FieldCreatedAt:
@@ -11502,27 +12066,6 @@ func (m *InspectionRecordMutation) SetField(name string, value ent.Value) error
}
m.SetParentRecordID(v)
return nil
- case inspectionrecord.FieldDisposalType:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDisposalType(v)
- return nil
- case inspectionrecord.FieldDisposalRemark:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetDisposalRemark(v)
- return nil
- case inspectionrecord.FieldReturnTrackingNo:
- v, ok := value.(string)
- if !ok {
- return fmt.Errorf("unexpected type %T for field %s", value, name)
- }
- m.SetReturnTrackingNo(v)
- return nil
case inspectionrecord.FieldRemark:
v, ok := value.(string)
if !ok {
@@ -11706,12 +12249,6 @@ func (m *InspectionRecordMutation) ClearedFields() []string {
if m.FieldCleared(inspectionrecord.FieldReportNo) {
fields = append(fields, inspectionrecord.FieldReportNo)
}
- if m.FieldCleared(inspectionrecord.FieldDisposalRemark) {
- fields = append(fields, inspectionrecord.FieldDisposalRemark)
- }
- if m.FieldCleared(inspectionrecord.FieldReturnTrackingNo) {
- fields = append(fields, inspectionrecord.FieldReturnTrackingNo)
- }
if m.FieldCleared(inspectionrecord.FieldRemark) {
fields = append(fields, inspectionrecord.FieldRemark)
}
@@ -11762,12 +12299,6 @@ func (m *InspectionRecordMutation) ClearField(name string) error {
case inspectionrecord.FieldReportNo:
m.ClearReportNo()
return nil
- case inspectionrecord.FieldDisposalRemark:
- m.ClearDisposalRemark()
- return nil
- case inspectionrecord.FieldReturnTrackingNo:
- m.ClearReturnTrackingNo()
- return nil
case inspectionrecord.FieldRemark:
m.ClearRemark()
return nil
@@ -11851,15 +12382,6 @@ func (m *InspectionRecordMutation) ResetField(name string) error {
case inspectionrecord.FieldParentRecordID:
m.ResetParentRecordID()
return nil
- case inspectionrecord.FieldDisposalType:
- m.ResetDisposalType()
- return nil
- case inspectionrecord.FieldDisposalRemark:
- m.ResetDisposalRemark()
- return nil
- case inspectionrecord.FieldReturnTrackingNo:
- m.ResetReturnTrackingNo()
- return nil
case inspectionrecord.FieldRemark:
m.ResetRemark()
return nil
diff --git a/bj_power_wms/ent/predicate/predicate.go b/bj_power_wms/ent/predicate/predicate.go
index 2fdc99f..0e7b596 100644
--- a/bj_power_wms/ent/predicate/predicate.go
+++ b/bj_power_wms/ent/predicate/predicate.go
@@ -33,6 +33,9 @@ type InboundDetail func(*sql.Selector)
// InboundOrder is the predicate function for inboundorder builders.
type InboundOrder func(*sql.Selector)
+// InspectionDisposalItem is the predicate function for inspectiondisposalitem builders.
+type InspectionDisposalItem func(*sql.Selector)
+
// InspectionRecord is the predicate function for inspectionrecord builders.
type InspectionRecord func(*sql.Selector)
diff --git a/bj_power_wms/ent/runtime.go b/bj_power_wms/ent/runtime.go
index 094891a..f9c0cde 100644
--- a/bj_power_wms/ent/runtime.go
+++ b/bj_power_wms/ent/runtime.go
@@ -12,6 +12,7 @@ import (
"bj_power_wms/ent/eventlog"
"bj_power_wms/ent/inbounddetail"
"bj_power_wms/ent/inboundorder"
+ "bj_power_wms/ent/inspectiondisposalitem"
"bj_power_wms/ent/inspectionrecord"
"bj_power_wms/ent/inventory"
"bj_power_wms/ent/inventorylock"
@@ -332,6 +333,20 @@ func init() {
inboundorderDescCreatedAt := inboundorderFields[23].Descriptor()
// inboundorder.DefaultCreatedAt holds the default value on creation for the created_at field.
inboundorder.DefaultCreatedAt = inboundorderDescCreatedAt.Default.(func() int64)
+ inspectiondisposalitemFields := schema.InspectionDisposalItem{}.Fields()
+ _ = inspectiondisposalitemFields
+ // inspectiondisposalitemDescQty is the schema descriptor for qty field.
+ inspectiondisposalitemDescQty := inspectiondisposalitemFields[2].Descriptor()
+ // inspectiondisposalitem.QtyValidator is a validator for the "qty" field. It is called by the builders before save.
+ inspectiondisposalitem.QtyValidator = inspectiondisposalitemDescQty.Validators[0].(func(int) error)
+ // inspectiondisposalitemDescOperator is the schema descriptor for operator field.
+ inspectiondisposalitemDescOperator := inspectiondisposalitemFields[4].Descriptor()
+ // inspectiondisposalitem.DefaultOperator holds the default value on creation for the operator field.
+ inspectiondisposalitem.DefaultOperator = inspectiondisposalitemDescOperator.Default.(string)
+ // inspectiondisposalitemDescCreatedAt is the schema descriptor for created_at field.
+ inspectiondisposalitemDescCreatedAt := inspectiondisposalitemFields[5].Descriptor()
+ // inspectiondisposalitem.DefaultCreatedAt holds the default value on creation for the created_at field.
+ inspectiondisposalitem.DefaultCreatedAt = inspectiondisposalitemDescCreatedAt.Default.(func() int64)
inspectionrecordFields := schema.InspectionRecord{}.Fields()
_ = inspectionrecordFields
// inspectionrecordDescInspectionType is the schema descriptor for inspection_type field.
@@ -374,16 +389,12 @@ func init() {
inspectionrecordDescParentRecordID := inspectionrecordFields[23].Descriptor()
// inspectionrecord.DefaultParentRecordID holds the default value on creation for the parent_record_id field.
inspectionrecord.DefaultParentRecordID = inspectionrecordDescParentRecordID.Default.(int64)
- // inspectionrecordDescDisposalType is the schema descriptor for disposal_type field.
- inspectionrecordDescDisposalType := inspectionrecordFields[24].Descriptor()
- // inspectionrecord.DefaultDisposalType holds the default value on creation for the disposal_type field.
- inspectionrecord.DefaultDisposalType = inspectionrecordDescDisposalType.Default.(string)
// inspectionrecordDescCreatedAt is the schema descriptor for created_at field.
- inspectionrecordDescCreatedAt := inspectionrecordFields[28].Descriptor()
+ inspectionrecordDescCreatedAt := inspectionrecordFields[25].Descriptor()
// inspectionrecord.DefaultCreatedAt holds the default value on creation for the created_at field.
inspectionrecord.DefaultCreatedAt = inspectionrecordDescCreatedAt.Default.(func() int64)
// inspectionrecordDescUpdatedAt is the schema descriptor for updated_at field.
- inspectionrecordDescUpdatedAt := inspectionrecordFields[29].Descriptor()
+ inspectionrecordDescUpdatedAt := inspectionrecordFields[26].Descriptor()
// inspectionrecord.DefaultUpdatedAt holds the default value on creation for the updated_at field.
inspectionrecord.DefaultUpdatedAt = inspectionrecordDescUpdatedAt.Default.(func() int64)
inventoryFields := schema.Inventory{}.Fields()
diff --git a/bj_power_wms/ent/tx.go b/bj_power_wms/ent/tx.go
index 56fb6a8..7de10ec 100644
--- a/bj_power_wms/ent/tx.go
+++ b/bj_power_wms/ent/tx.go
@@ -30,6 +30,8 @@ type Tx struct {
InboundDetail *InboundDetailClient
// InboundOrder is the client for interacting with the InboundOrder builders.
InboundOrder *InboundOrderClient
+ // InspectionDisposalItem is the client for interacting with the InspectionDisposalItem builders.
+ InspectionDisposalItem *InspectionDisposalItemClient
// InspectionRecord is the client for interacting with the InspectionRecord builders.
InspectionRecord *InspectionRecordClient
// Inventory is the client for interacting with the Inventory builders.
@@ -206,6 +208,7 @@ func (tx *Tx) init() {
tx.EventLog = NewEventLogClient(tx.config)
tx.InboundDetail = NewInboundDetailClient(tx.config)
tx.InboundOrder = NewInboundOrderClient(tx.config)
+ tx.InspectionDisposalItem = NewInspectionDisposalItemClient(tx.config)
tx.InspectionRecord = NewInspectionRecordClient(tx.config)
tx.Inventory = NewInventoryClient(tx.config)
tx.InventoryLock = NewInventoryLockClient(tx.config)
diff --git a/bj_power_wms/frontend/src/components/InboundEntry.vue b/bj_power_wms/frontend/src/components/InboundEntry.vue
index 1fb3691..85e4c0d 100644
--- a/bj_power_wms/frontend/src/components/InboundEntry.vue
+++ b/bj_power_wms/frontend/src/components/InboundEntry.vue
@@ -331,7 +331,7 @@ onMounted(() => loadZones())
-
未找到对应的工单,请确认产品工号是否正确
+
未在 MES 找到该产品工号对应的工单;产品工号可留空,不影响入库,如手填请核对是否与 MES 工单号一致
网络异常,未能校验工单号,请稍后确认
diff --git a/bj_power_wms/frontend/src/help.js b/bj_power_wms/frontend/src/help.js
index 5605be5..058e613 100644
--- a/bj_power_wms/frontend/src/help.js
+++ b/bj_power_wms/frontend/src/help.js
@@ -34,12 +34,12 @@ export const helpInspection = Q('来料检验', '判定一旦写下去就不能
{ q: '判定之后还能改结论吗?', a: '不能。复检是新增一条记录覆盖判定,原记录保留可查。' },
{ q: '「清空」会丢什么?', a: '会丢已经选好但还没送检的清单;切换入库单时也会清空已选。选好了就别中途切单。' },
{ q: '一次能送多少?', a: '单次上限 100 条,多了分批送。待检明细的条数是动态生成的,按实际件数来。' },
- { q: '部分入库到底怎么记?', a: '一次部分入库只能针对单批次。不合格的那部分会自动拆成带 -NG 后缀的待处置行,跟合格部分不是同一条账;要先想清楚「处置方式」再提交,不然不合格品会悬在那里没有去向。' }
+ { q: '不合格部分怎么处置?', a: '2026-11-16 起处置按明细行记:判「不合格」后逐行填退货 / 返修 / 报废并拆数量,多行数量合计必须等于不合格数;备注可空,退货的物流单号等信息填备注。提交时按行执行库存动作(退货→待退、返修→不合格隔离、报废→报废)。' }
], ['判定合格/不合格会直接改变这批货能不能出库。'], [
{ t: '功能定位', text: 'WMS 只做来料检验;过程检、完工检属于 MES,两边不要互相找记录。' },
{ t: '必填与选填', items: [
- '必填 11 项:至少 1 条待检项;目标类型(批次 / SN / 其他);归属类型;归属编号(归属为合同号 / 科技项目时必填);每条待检编号;记录人;处置方式(有不合格时必填);退货运单号(处置=退货时必填);第几批 / 共几件(批次行、序列号=否,均 ≥1);合格数守恒(≤ 检验数,判合格时相等);部分入库限单批次。',
- '选填 5 项:检测单号、报检单号、生产厂家、相关标准、相关标准说明,表单里都标了「可空」。'
+ '必填:至少 1 条待检项;目标类型(批次 / SN / 其他);归属类型;归属编号(归属为合同号 / 科技项目时必填);每条待检编号;记录人;处置明细行(有不合格时必填,退货 / 返修 / 报废按数量拆分,多行合计=不合格数);合格数守恒(≤ 检验数,判合格时相等)。',
+ '选填:检测单号、报检单号、生产厂家、相关标准、相关标准说明、处置备注,表单里都标了「可空」;退货运单号概念已废除,物流信息填备注。'
] },
{ t: '异常场景', text: '检验结论还没录机、系统里查不到检测单号时不会报错,实物检验责任仍在库管;记录补进来之后会自动关联。' }
], [
diff --git a/bj_power_wms/frontend/src/pages/DefectReturn.vue b/bj_power_wms/frontend/src/pages/DefectReturn.vue
index 4349085..8da58f6 100644
--- a/bj_power_wms/frontend/src/pages/DefectReturn.vue
+++ b/bj_power_wms/frontend/src/pages/DefectReturn.vue
@@ -224,7 +224,7 @@ onMounted(() => {
- 已出库/已消耗的物料,产线使用中发现不良 → 在此登记退回。系统会重建隔离库存行(质量=不合格),随后到「库存查询→库位明细」按质量筛选「不合格」找到该行,走「在库处置」(退货/换修/报废)完成闭环。
+ 已出库/已消耗的物料,产线使用中发现不良 → 在此登记退回。系统会重建隔离库存行(质量=不合格),随后到「库存查询→库位明细」按质量筛选「不合格」找到该行,走「在库处置」(退货/返修/报废)完成闭环。
序列号=是(按 产品序号(SN) 记账)请逐行录入 产品序号(SN);序列号=否(按批次记账)可填批次号,留空系统自动生成。
diff --git a/bj_power_wms/frontend/src/pages/Inspection.vue b/bj_power_wms/frontend/src/pages/Inspection.vue
index 5115b69..23f65cd 100644
--- a/bj_power_wms/frontend/src/pages/Inspection.vue
+++ b/bj_power_wms/frontend/src/pages/Inspection.vue
@@ -36,8 +36,6 @@ const ownershipType = ref('other')
const ownershipNo = ref('')
const relatedStandard = ref('')
const manufacturer = ref('')
-const disposalType = ref('NONE')
-const returnTrackingNo = ref('')
// 待检编号列表(逐个判定:每条独立结论/检验数/合格数)
const items = ref([]) // { targetId, status, inspectQty, passQty, snMode, batchSeq, batchTotal }
@@ -113,7 +111,7 @@ function addItem(targetId, qty, materialCode = '', materialName = '', inboundNo
if (!targetId) return
if (items.value.some((i) => i.targetId === targetId)) return
const iq = Number(snMode) !== 1 ? (Number(qty) || 1) : 1
- items.value.push({ targetId, materialCode, materialName, inboundNo, snMode, status: '合格', inspectQty: iq, passQty: iq, batchSeq: null, batchTotal: null })
+ items.value.push({ targetId, materialCode, materialName, inboundNo, snMode, status: '合格', inspectQty: iq, passQty: iq, disposals: [], batchSeq: null, batchTotal: null })
}
async function addFromInput() {
if (sourceInboundNo.value) {
@@ -163,7 +161,19 @@ function clearAll() {
items.value = []
sourceInboundNo.value = '' // 解除入库单绑定,回到自由录入模式
}
-// 结论变化:SN/其他 自动定检验数=1、合格数随结论;批次合格时合格数=检验数
+// 结论变化:SN/其他 自动定检验数=1、合格数随结论;批次合格时合格数=检验数。
+// 2026-11-16 拍板:处置下放明细行——行判「不合格」时初始化一条处置明细(默认全量退货),
+// 可按数量拆分为退货/返修/报废多行;运单号概念废除,物流信息填备注。
+function rejectQtyOfRow(row) {
+ return Math.max(0, (Number(row.inspectQty) || 0) - (Number(row.passQty) || 0))
+}
+function disposalSum(row) {
+ return (row.disposals || []).reduce((s, d) => s + (Number(d.qty) || 0), 0)
+}
+function addDisposalLine(row) {
+ if (!row.disposals) row.disposals = []
+ row.disposals.push({ type: 'RETURN', qty: Math.max(1, rejectQtyOfRow(row) - disposalSum(row)), remark: '' })
+}
function onItemStatus(row) {
if (!isRowBatch(row)) {
row.inspectQty = 1
@@ -171,6 +181,13 @@ function onItemStatus(row) {
} else if (row.status === '合格') {
row.passQty = row.inspectQty
}
+ if (row.status === '不合格') {
+ if (!row.disposals || !row.disposals.length) {
+ row.disposals = [{ type: 'RETURN', qty: rejectQtyOfRow(row) || 1, remark: '' }]
+ }
+ } else {
+ row.disposals = []
+ }
}
function onTargetTypeChange() {
clearAll()
@@ -232,18 +249,24 @@ async function submitInspection() {
ElMessage.warning('请填写记录人')
return
}
- const hasFail = items.value.some((i) => i.status === '不合格')
- if (hasFail && disposalType.value === 'NONE') {
- ElMessage.warning('有不合格项时必须选择处置方式(退货 / 换修 / 报废 / 部分入库)')
- return
- }
- if (hasFail && disposalType.value === 'RETURN' && !returnTrackingNo.value.trim()) {
- ElMessage.warning('退货处置必须填写货运单号')
- return
- }
- if (hasFail && disposalType.value === 'PARTIAL' && (items.value.length !== 1 || !isRowBatch(items[0]))) {
- ElMessage.warning('「部分入库」一次只能处理 1 个批次,请分开提交')
- return
+ // 处置明细校验(2026-11-16 拍板):不合格行必须带处置明细,Σqty=不合格数,逐行数量>0;
+ // 运单号概念废除,退货物流信息填备注(可空)
+ for (const it of items.value) {
+ if (it.status !== '不合格') continue
+ if (!it.disposals || !it.disposals.length) {
+ ElMessage.warning(`批次/SN「${it.targetId}」判定不合格,请至少填写一条处置明细(退货 / 返修 / 报废)`)
+ return
+ }
+ const rq = rejectQtyOfRow(it)
+ const sum = disposalSum(it)
+ if (it.disposals.some((d) => (Number(d.qty) || 0) <= 0)) {
+ ElMessage.warning(`批次/SN「${it.targetId}」处置明细行数量必须大于 0`)
+ return
+ }
+ if (sum !== rq) {
+ ElMessage.warning(`批次/SN「${it.targetId}」处置明细数量合计(${sum})必须等于不合格数量(${rq})`)
+ return
+ }
}
// 报检数守恒校验(批次:合格数 ≤ 检验数;合格时两者相等)
for (const it of items.value) {
@@ -265,9 +288,9 @@ async function submitInspection() {
status: it.status,
inspectQty: Number(it.inspectQty) || 0,
passQty: Number(it.passQty) || 0,
- disposalType: it.status === '不合格' ? disposalType.value : 'NONE',
- returnTrackingNo: returnTrackingNo.value.trim(),
- disposalRemark: '',
+ disposals: it.status === '不合格'
+ ? (it.disposals || []).map((d) => ({ type: d.type, qty: Number(d.qty) || 0, remark: (d.remark || '').trim() }))
+ : [],
ownershipType: ownershipType.value,
ownershipNo: ownershipNo.value.trim(),
relatedStandard: relatedStandard.value.trim(),
@@ -286,17 +309,15 @@ async function submitInspection() {
if (!allPass) {
// 2026-11-14:文案统一取规则表第 19 条,菜单路径按对象域「物料 → 通用出库」。
showNextStep(manualPayload(19, {
- title: `已登记 ${n} 条检验记录,不合格部分挂「待处置」`,
+ title: `已登记 ${n} 条检验记录,不合格部分已按处置明细隔离`,
primaryNo: passedNo || '',
- tip: '处置为退货时再去「物料 → 通用出库」按退货运单号出库;刷新本页后此提示消失。'
+ tip: '退货明细的物料随后在「物料 → 通用出库」按批次出库退回供应商;刷新本页后此提示消失。'
}))
}
clearAll()
checkDesc.value = ''
reportNo.value = ''
inspectionNo.value = ''
- disposalType.value = 'NONE'
- returnTrackingNo.value = ''
ownershipType.value = 'other'
ownershipNo.value = ''
relatedStandard.value = ''
@@ -435,24 +456,20 @@ function sendSelectedFromDrawer() {
}
/* ===================== 不合格处置 ===================== */
-const disposeDialog = reactive({ visible: false, row: null, type: 'RETURN', remark: '', trackingNo: '' })
+const disposeDialog = reactive({ visible: false, row: null, type: 'RETURN', remark: '' })
function openDispose(row) {
if (row.status !== '不合格') {
ElMessage.warning('仅「不合格」记录可执行处置')
return
}
- Object.assign(disposeDialog, { visible: true, row, type: 'RETURN', remark: '', trackingNo: '' })
+ Object.assign(disposeDialog, { visible: true, row, type: 'RETURN', remark: '' })
}
async function submitDispose() {
- if (disposeDialog.type === 'RETURN' && !disposeDialog.trackingNo.trim()) {
- ElMessage.warning('退货必须填写货运单号')
- return
- }
await request.post('/inspection/dispose', {
recordId: disposeDialog.row.id,
disposalType: disposeDialog.type,
disposalRemark: disposeDialog.remark.trim(),
- returnTrackingNo: disposeDialog.trackingNo.trim(),
+ operator: getRealName(),
})
ElMessage.success('处置完成')
disposeDialog.visible = false
@@ -497,9 +514,14 @@ function targetTypeLabel(t) {
return t === 'SN' ? '序列号' : t === 'BATCH' ? '批次' : t === 'OTHER' ? '其他' : (t || '-')
}
function disposalLabel(t) {
- const m = { RETURN: '退货', SCRAP: '报废', PARTIAL: '部分入库', REWORK: '换修' }
+ const m = { RETURN: '退货', SCRAP: '报废', REWORK: '返修' }
return m[t] || '未处置'
}
+// 2026-11-16 拍板:处置明细子表行文本(后端 query/export 附加 disposalLines:"退货×5(备注);返修×5")
+function disposalLinesText(row) {
+ if (!row || !row.disposalLines) return ''
+ return String(row.disposalLines)
+}
// 三维度之三:不合格品处置状态(独立于检验结论与数量拆分)
function rejectQtyOf(row) {
if (!row) return 0
@@ -692,17 +714,6 @@ onMounted(() => {
其他 (辅料·工装·试验设备)
-
-
- 退货
- 换修
- 报废
- 部分入库
-
-
-
-
-
@@ -801,6 +812,30 @@ onMounted(() => {
{{ (Number(row.inspectQty)||0) - (Number(row.passQty)||0) }}
+
+
+
+
+
+
+
+
+
+
+
+
+ 删
+
+
+ + 添加处置行
+
+ 已拆 {{ disposalSum(row) }}/{{ rejectQtyOfRow(row) }},需等于不合格数
+
+
+
+ -
+
+
移除
@@ -890,9 +925,9 @@ onMounted(() => {
{{ row.status || '未检' }}
-
+
- {{ disposalLabel(row.disposalType) }}
+ {{ disposalLinesText(row) }}
-
@@ -946,8 +981,8 @@ onMounted(() => {
- 处置
- 处理结果
+ 处置
+ 处理结果
附件
@@ -1010,7 +1045,7 @@ onMounted(() => {
-
+
@@ -1024,7 +1059,7 @@ onMounted(() => {
- = 检验数 − 合格数;这部分不会进入合格库存,需在本弹窗完成处置
+ = 检验数 − 合格数;这部分不会进入合格库存,本弹窗一次性完成处置
@@ -1034,16 +1069,14 @@ onMounted(() => {
退货
- 换修
+ 返修
报废
- 部分入库
-
-
+
+
-
取消
@@ -1052,15 +1085,19 @@ onMounted(() => {
-
+
{{ resultDlg.row.targetId }}
{{ resultDlg.row.materialCode }}
-
- {{ disposalLabel(resultDlg.row.disposalType) }}
+
+
+ {{ disposalStatusLabel(resultDlg.row.disposalStatus) }}
+
+
+
+ {{ disposalLinesText(resultDlg.row) }}
+ -
- {{ resultDlg.row.returnTrackingNo || '-' }}
- {{ resultDlg.row.disposalRemark || '-' }}
{{ fmtTime(resultDlg.row.createdAt) }}
diff --git a/bj_power_wms/frontend/src/pages/Inventory.vue b/bj_power_wms/frontend/src/pages/Inventory.vue
index 2cbf576..f7e1ccf 100644
--- a/bj_power_wms/frontend/src/pages/Inventory.vue
+++ b/bj_power_wms/frontend/src/pages/Inventory.vue
@@ -338,7 +338,8 @@ function gotoInbound(no) {
}
// ---- 在库不合格处置(POST /inspection/inventory-dispose,inventoryId=库存行 id) ----
-const disposeDlg = reactive({ show: false, saving: false, id: 0, label: '', disposalType: '', returnTrackingNo: '', disposalRemark: '', qty: 0, quantity: 0, snMode: 0 })
+// 2026-11-16 拍板:运单号概念废除,退货物流信息填处置说明(可空)
+const disposeDlg = reactive({ show: false, saving: false, id: 0, label: '', disposalType: '', disposalRemark: '', qty: 0, quantity: 0, snMode: 0 })
// 序列号=否(按批次记账)且处置方式=退货/返修/报废时支持部分数量处置(序列号=是 单件,不显示)
const showDisposeQty = computed(() => disposeDlg.snMode === 2 && ['RETURN', 'REWORK', 'SCRAP'].includes(disposeDlg.disposalType))
@@ -347,16 +348,13 @@ function openDispose(row) {
const label = `${detailId(row) || row.id} · ${row.materialCode || ''} ${row.materialName || ''}`
Object.assign(disposeDlg, {
show: true, saving: false, id: row.id, label,
- disposalType: '', returnTrackingNo: '', disposalRemark: '',
+ disposalType: '', disposalRemark: '',
snMode: row.snMode || 0, quantity: row.quantity || 0, qty: row.quantity || 0
})
}
async function submitDispose() {
if (!disposeDlg.disposalType) return ElMessage.warning('请选择处置方式')
- if (disposeDlg.disposalType === 'RETURN' && !disposeDlg.returnTrackingNo.trim()) {
- return ElMessage.warning('退货处置必须填写退货运单号')
- }
if (showDisposeQty.value && (!disposeDlg.qty || disposeDlg.qty < 1 || disposeDlg.qty > disposeDlg.quantity)) {
return ElMessage.warning('处置数量须在 1 与行数量之间')
}
@@ -365,7 +363,6 @@ async function submitDispose() {
await request.post('/inspection/inventory-dispose', {
inventoryId: disposeDlg.id,
disposalType: disposeDlg.disposalType,
- returnTrackingNo: disposeDlg.returnTrackingNo.trim(),
disposalRemark: disposeDlg.disposalRemark,
qty: showDisposeQty.value ? disposeDlg.qty : 0,
operator: ''
@@ -378,30 +375,26 @@ async function submitDispose() {
}
}
-// ---- 复检(换修闭环):针对「在库 + 不合格」库存行重新判定,闭合换修 / 不合格处置后续 ----
-const reinspectDlg = reactive({ show: false, saving: false, id: 0, label: '', result: 'pass', disposalType: 'RETURN', returnTrackingNo: '', remark: '' })
+// ---- 复检(返修闭环):针对「在库 + 不合格」库存行重新判定,闭合返修 / 不合格处置后续 ----
+const reinspectDlg = reactive({ show: false, saving: false, id: 0, label: '', result: 'pass', disposalType: 'RETURN', remark: '' })
function openReinspect(row) {
const label = `${detailId(row) || row.id} · ${row.materialCode || ''} ${row.materialName || ''}`
Object.assign(reinspectDlg, {
show: true, saving: false, id: row.id, label,
- result: 'pass', disposalType: 'RETURN', returnTrackingNo: '', remark: ''
+ result: 'pass', disposalType: 'RETURN', remark: ''
})
}
async function submitReinspect() {
if (!reinspectDlg.result) return ElMessage.warning('请选择复检结果')
if (reinspectDlg.result === 'fail' && !reinspectDlg.disposalType) return ElMessage.warning('请选择不合格处置方式')
- if (reinspectDlg.result === 'fail' && reinspectDlg.disposalType === 'RETURN' && !reinspectDlg.returnTrackingNo.trim()) {
- return ElMessage.warning('退货处置必须填写退货运单号')
- }
reinspectDlg.saving = true
try {
const res = await request.post('/inspection/reinspect', {
inventoryId: reinspectDlg.id,
result: reinspectDlg.result,
disposalType: reinspectDlg.result === 'fail' ? reinspectDlg.disposalType : '',
- returnTrackingNo: reinspectDlg.returnTrackingNo.trim(),
remark: reinspectDlg.remark,
operator: ''
})
@@ -863,7 +856,7 @@ onMounted(() => {
{{ fmtTime(row.createdAt) }}
-
+
@@ -891,7 +884,7 @@ onMounted(() => {
退货
- 换修
+ 返修
报废
@@ -906,10 +899,11 @@ onMounted(() => {
-
-
+
+
-
+
@@ -919,8 +913,8 @@ onMounted(() => {
-
-
+
+
@@ -938,12 +932,10 @@ onMounted(() => {
报废
-
-
-
-
+
diff --git a/bj_power_wms/frontend/src/utils/nextStepRules.js b/bj_power_wms/frontend/src/utils/nextStepRules.js
index feb9b14..c23bc2d 100644
--- a/bj_power_wms/frontend/src/utils/nextStepRules.js
+++ b/bj_power_wms/frontend/src/utils/nextStepRules.js
@@ -22,7 +22,7 @@ export const NEXT_STEP_RULES = [
no: 19, scene: '入库作业 → 来料检验', action: '检验判定提交', method: 'POST', api: '/inspection/batch-flip',
kind: '单据', cross: false, manual: true, next: '入库作业 → 来料检验(不合格品处置)',
title: '已登记检验记录',
- text: '下一步:本页「不合格品处置」对不合格部分选退货 / 换修 / 返修 / 报废;合格部分才进合格库存。',
+ text: '下一步:本页按处置明细行对不合格部分拆退货 / 返修 / 报废(多行合计=不合格数);合格部分才进合格库存。',
tip: '本条由页面按合格/不合格分支生成文案,不走自动触发;刷新页面后此提示消失。',
noField: '', noFrom: 'resp'
},
@@ -30,7 +30,7 @@ export const NEXT_STEP_RULES = [
no: 20, scene: '入库作业 → 来料检验', action: '不合格品处置', method: 'POST', api: '/inspection/dispose',
kind: '单据', cross: false, manual: false, next: '入库作业 → 来料入库',
title: '不合格品已处置',
- text: '下一步:处置为退货时到「出库与配送 → 通用出库」按退货运单号出库;合格部分到「入库作业 → 来料入库」办理入库。',
+ text: '下一步:处置为退货的物料到「出库与配送 → 通用出库」按批次办理退供应商出库;合格部分到「入库作业 → 来料入库」办理入库。',
tip: '不合格部分不会进入合格库存;刷新页面后此提示消失。',
noField: '', noFrom: 'resp'
},
diff --git a/bj_power_wms/frontend/vite.config.js b/bj_power_wms/frontend/vite.config.js
index 9129e68..c8ea6cd 100644
--- a/bj_power_wms/frontend/vite.config.js
+++ b/bj_power_wms/frontend/vite.config.js
@@ -1,5 +1,23 @@
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 apiPort = backendPort('../etc/bj_power_wms-api.yaml', 8890)
+const apiTarget = `http://localhost:${apiPort}`
// 构建产物直接写入 Go 网关的嵌入静态目录(go:embed all:web/static)
export default defineConfig({
@@ -13,14 +31,14 @@ export default defineConfig({
port: 5173,
proxy: {
'/api': {
- target: 'http://localhost:8890',
+ target: apiTarget,
changeOrigin: true
},
// 附件静态文件(PDF/图片预览):与 API 同源,避免开发态下 /uploads 打到 Vite 而 404
'/uploads': {
- target: 'http://localhost:8890',
+ target: apiTarget,
changeOrigin: true
}
}
}
-})
\ No newline at end of file
+})
diff --git a/bj_power_wms/internal/db/db.go b/bj_power_wms/internal/db/db.go
index 4c51c17..0ac56ed 100644
--- a/bj_power_wms/internal/db/db.go
+++ b/bj_power_wms/internal/db/db.go
@@ -191,10 +191,8 @@ func applyColumnPatches(ctx context.Context) {
// 2026-11-13 用户拍板:历史数据可以直接清空,代码里绝不自作主张改写业务历史状态。
// 原「让步接收→合格」「reject_qty 历史回填」两条 UPDATE 已删除;清空由用户手工执行
// migrations/20261113_clear_inspection_history.sql,本补丁只做幂等 ADD COLUMN / 结构迁移。
- // P0-2 不合格品处置(问题记录 L135-145)
- `ALTER TABLE inspection_records ADD COLUMN IF NOT EXISTS disposal_type text NOT NULL DEFAULT 'NONE'`,
- `ALTER TABLE inspection_records ADD COLUMN IF NOT EXISTS disposal_remark text`,
- `ALTER TABLE inspection_records ADD COLUMN IF NOT EXISTS return_tracking_no text`,
+ // 2026-11-16 拍板:处置下放明细子表 inspection_disposal_items,单头 disposal_type /
+ // disposal_remark / return_tracking_no 三列废止(见下方 DROP 补丁),不再 ADD 回来。
// D5 区域库位:货架号 / 第几层 / 位置号(手填)
`ALTER TABLE zones ADD COLUMN IF NOT EXISTS shelf_no text`,
`ALTER TABLE zones ADD COLUMN IF NOT EXISTS layer_no text`,
@@ -272,6 +270,12 @@ func applyColumnPatches(ctx context.Context) {
`ALTER TABLE materials DROP COLUMN IF EXISTS drawing_no`,
// 「简称」已按 2026-09-19 用户裁决整体删除(新增/编辑表单不再出现),存量库丢弃旧列
`ALTER TABLE materials DROP COLUMN IF EXISTS short_name`,
+ // 2026-11-16 拍板:检验处置下放明细子表 inspection_disposal_items(按数量分退货/返修/报废、
+ // 各行自带备注),单头 disposal_type / disposal_remark / return_tracking_no 三列废止并 DROP;
+ // 退货物流信息统一填子表行备注(非必填)。历史处置值已随行留存在子表/事件日志中。
+ `ALTER TABLE inspection_records DROP COLUMN IF EXISTS disposal_type`,
+ `ALTER TABLE inspection_records DROP COLUMN IF EXISTS disposal_remark`,
+ `ALTER TABLE inspection_records DROP COLUMN IF EXISTS return_tracking_no`,
// 批次号/SN 唯一约束(P2-1/P2-2):并发导入防撞号。部分唯一索引只约束非空值——
// 空串/NULL(序列号=否无SN、序列号=是有批次)不参与唯一性。
// 批次唯一索引 ux_inventories_batch_no 已改按 sn_mode=2 约束(见下方 2026-09-30 解耦补丁:先回填再重建)。
diff --git a/bj_power_wms/internal/handler/inbound.go b/bj_power_wms/internal/handler/inbound.go
index ae6c960..a0f8274 100644
--- a/bj_power_wms/internal/handler/inbound.go
+++ b/bj_power_wms/internal/handler/inbound.go
@@ -253,7 +253,8 @@ func createInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
// 质量状态自动带出(客户诉求 问题记录 L129:入库记录增加 合格/不合格 列)
- // 按检测单号查最近一次检验结论:合格→合格;不合格且部分入库→部分;不合格→不合格;无记录→空(未关联)
+ // 按检测单号查最近一次检验结论:合格→合格;不合格→不合格;无记录→空(未关联)。
+ // 2026-11-16 拍板:处置下放明细子表、「部分入库」不再是人工处置选项(送检判定即拆行)。
qualityStatus := ""
if req.InspectionNo != "" {
if rec, qerr := ctx.EntClient.InspectionRecord.Query().
@@ -261,9 +262,6 @@ func createInboundHandler(ctx *svc.ServiceContext) http.HandlerFunc {
Order(ent.Desc("created_at"), ent.Desc("id")).
First(ctx0()); qerr == nil && rec != nil {
qualityStatus = rec.Status
- if rec.Status == "不合格" && rec.DisposalType == "PARTIAL" {
- qualityStatus = "部分"
- }
}
}
diff --git a/bj_power_wms/internal/handler/inspection.go b/bj_power_wms/internal/handler/inspection.go
index 7ed2f42..94175a9 100644
--- a/bj_power_wms/internal/handler/inspection.go
+++ b/bj_power_wms/internal/handler/inspection.go
@@ -12,14 +12,16 @@
package handler
import (
+ "encoding/json"
"fmt"
"net/http"
- "strings"
"strconv"
+ "strings"
"time"
"bj_power_wms/ent"
"bj_power_wms/ent/inboundorder"
+ "bj_power_wms/ent/inspectiondisposalitem"
"bj_power_wms/ent/inspectionrecord"
"bj_power_wms/ent/inventory"
"bj_power_wms/ent/material"
@@ -44,36 +46,39 @@ func resolveInspectionTarget(ctx *svc.ServiceContext, targetId string) (*ent.Inv
}
// batchFlipInspectionHandler 逐个判定批量翻转检验状态(问题记录 L150 三问题之三)
-// body: { items: [ { targetId, status, inspectQty, passQty, disposalType,
+// body: { items: [ { targetId, status, inspectQty, passQty, disposals: [{type, qty, remark}],
//
-// returnTrackingNo, disposalRemark, ownershipType, ownershipNo,
-// relatedStandard, manufacturer, checkDesc, inspector, reportNo, inspectionNo,
-// batchSeq, batchTotal } ] }
+// ownershipType, ownershipNo, relatedStandard, manufacturer, checkDesc, inspector,
+// reportNo, inspectionNo, batchSeq, batchTotal } ] }
//
// 每个对象按自身数量写记录、按自身结论翻库存状态(修复旧版"所有记录同数量"的 bug)。
// reject_qty 后端复核 = inspectQty - passQty,不信任前端传入值。
-// batchSeq/batchTotal(第几批/共几件):序列号=否(sn_mode=2)必填且均≥1;序列号=是忽略传值、落库 0=未填。
+// 2026-11-16 拍板:处置方式下放明细子表——不合格项必须带 disposals 明细行
+// (退货/返修/报废按数量拆分,Σqty=不合格数;备注非必填,退货物流信息也填备注),
+// 提交时写子表并按行执行库存动作。运单号概念废除。
func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
Items []struct {
- TargetId string `json:"targetId"`
- Status string `json:"status"` // 合格/不合格
- InspectQty int `json:"inspectQty"`
- PassQty int `json:"passQty"`
- DisposalType string `json:"disposalType"`
- ReturnTrackingNo string `json:"returnTrackingNo"`
- DisposalRemark string `json:"disposalRemark"`
- OwnershipType string `json:"ownershipType"`
- OwnershipNo string `json:"ownershipNo"`
- RelatedStandard string `json:"relatedStandard"`
- Manufacturer string `json:"manufacturer"`
- CheckDesc string `json:"checkDesc"`
- Inspector string `json:"inspector"`
- ReportNo string `json:"reportNo"`
- InspectionNo string `json:"inspectionNo"`
- BatchSeq int `json:"batchSeq"`
- BatchTotal int `json:"batchTotal"`
+ TargetId string `json:"targetId"`
+ Status string `json:"status"` // 合格/不合格
+ InspectQty int `json:"inspectQty"`
+ PassQty int `json:"passQty"`
+ Disposals []struct {
+ Type string `json:"type"` // RETURN/REWORK/SCRAP
+ Qty int `json:"qty"` // >0
+ Remark string `json:"remark"` // 非必填(退货物流信息也填此处)
+ } `json:"disposals"`
+ OwnershipType string `json:"ownershipType"`
+ OwnershipNo string `json:"ownershipNo"`
+ RelatedStandard string `json:"relatedStandard"`
+ Manufacturer string `json:"manufacturer"`
+ CheckDesc string `json:"checkDesc"`
+ Inspector string `json:"inspector"`
+ ReportNo string `json:"reportNo"`
+ InspectionNo string `json:"inspectionNo"`
+ BatchSeq int `json:"batchSeq"`
+ BatchTotal int `json:"batchTotal"`
} `json:"items"`
}
if err := parseJSON(r, &req); err != nil {
@@ -86,6 +91,11 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
// 预校验:每条必须含 targetId 且结论合法、能定位到库存行;任意一条失败整体拒绝(避免部分成功假闭环)
+ type disposalLine struct {
+ dt string
+ qty int
+ remark string
+ }
type item struct {
id string
inv *ent.Inventory
@@ -95,9 +105,7 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
inspectQty int
passQty int
rejectQty int
- disposal string
- retTrack string
- dispRemark string
+ disposals []disposalLine
ownType string
ownNo string
relStd string
@@ -144,12 +152,34 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
// 后端复核不合格数 = 检验数 - 合格数(不信任前端)
rejectQty := inspectQty - passQty
+ // 2026-11-16 拍板:不合格必须有处置明细行,Σqty = 不合格数,逐行归一化校验
+ disposals := make([]disposalLine, 0, len(it.Disposals))
+ if rejectQty > 0 {
+ sum := 0
+ for _, d := range it.Disposals {
+ dt := disposalTypeOrNone(d.Type)
+ if dt == "NONE" {
+ fail(w, http.StatusBadRequest, fmt.Sprintf("「%s」处置明细行方式无效(仅 退货/返修/报废): %s", it.TargetId, d.Type))
+ return
+ }
+ if d.Qty <= 0 {
+ fail(w, http.StatusBadRequest, fmt.Sprintf("「%s」处置明细行数量必须大于 0", it.TargetId))
+ return
+ }
+ sum += d.Qty
+ disposals = append(disposals, disposalLine{dt: dt, qty: d.Qty, remark: strings.TrimSpace(d.Remark)})
+ }
+ if sum != rejectQty {
+ fail(w, http.StatusBadRequest, fmt.Sprintf("「%s」处置明细数量合计(%d)必须等于不合格数量(%d):按数量分别填退货/返修/报废", it.TargetId, sum, rejectQty))
+ return
+ }
+ }
// 第几批/共几件已下线(2026-11-08):前端不再采集,字段保留落库 0(schema Default(0) 不动)
batchSeq, batchTotal := 0, 0
items = append(items, item{
id: it.TargetId, inv: inv, targetType: tt, material: inv.MaterialCode,
status: it.Status, inspectQty: inspectQty, passQty: passQty, rejectQty: rejectQty,
- disposal: disposalTypeOrNone(it.DisposalType), retTrack: it.ReturnTrackingNo, dispRemark: it.DisposalRemark,
+ disposals: disposals,
ownType: it.OwnershipType, ownNo: it.OwnershipNo, relStd: it.RelatedStandard, mfr: it.Manufacturer,
checkDesc: it.CheckDesc, inspector: it.Inspector, reportNo: it.ReportNo, inspNo: it.InspectionNo,
batchSeq: batchSeq, batchTotal: batchTotal, pw: inv.ProductWorkNo,
@@ -207,12 +237,12 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
// 2026-11-13 拍板「来料检验三维度正交重构」:
// ① 检验结论 inspection_conclusion(只答判定成什么)
// ② 数量拆分(inspectQty/passQty/rejectQty)——提交时【自动拆库存行】,不再等人工二次点处置
- // ③ 不合格品处置 disposal_status 独立状态机:不合格部分一律先挂「待处置」
+ // ③ 不合格品处置:2026-11-16 拍板下放明细子表,提交时写处置行并按行执行库存动作
dispStatus := ""
if it.rejectQty > 0 {
- dispStatus = "待处置"
+ dispStatus = "已处置"
}
- if _, err = tx.InspectionRecord.Create().
+ rec, err := tx.InspectionRecord.Create().
SetTargetType(it.targetType).
SetTargetID(it.id).
SetMaterialCode(it.material).
@@ -234,17 +264,26 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
SetNillableInspector(strPtr(it.inspector)).
SetNillableReportNo(strPtr(it.reportNo)).
SetNillableInspectionNo(strPtr(it.inspNo)).
- SetDisposalType(it.disposal).
- SetNillableDisposalRemark(strPtr(it.dispRemark)).
- SetNillableReturnTrackingNo(strPtr(it.retTrack)).
SetNillableProductWorkNo(strPtr(it.pw)).
- Save(ctx0()); err != nil {
+ Save(ctx0())
+ if err != nil {
fail(w, http.StatusInternalServerError, "创建检验记录失败: "+err.Error())
return
}
- // 自动拆分:原行保留「合格数 + 未检数」,不合格数单独生成 -NG 隔离行并挂「待处置」。
- // 未检件不再被算成不合格(旧 dispose 用 total-passQty 的口径已废止)。
- // -NG 行本身不会再进待检清单,故用后缀判断即可防重复拆分,无需额外 import。
+ // 处置明细行:逐行写子表(qty 按行、备注非必填)
+ for _, d := range it.disposals {
+ if _, err = tx.InspectionDisposalItem.Create().
+ SetRecordID(int64(rec.ID)).SetDisposeType(d.dt).SetQty(d.qty).
+ SetNillableRemark(strPtr(d.remark)).
+ SetNillableOperator(strPtr(it.inspector)).
+ Save(ctx0()); err != nil {
+ fail(w, http.StatusInternalServerError, "创建处置明细失败: "+err.Error())
+ return
+ }
+ }
+ // 库存动作:自动拆分。原行保留「合格数 + 未检数」;不合格数按处置明细行拆分——
+ // 批次行按处置生成多条 -NG 隔离行(退货=待退/返修=不合格在库/报废=不合格报废);
+ // SN/其他类单件行按唯一处置行直接翻状态。处置明细行存在时一律不再挂「待处置」。
if it.rejectQty > 0 && it.inv.SnMode == snModeBatch && !strings.HasSuffix(it.inv.BatchNo, "-NG") {
kept := it.passQty + (it.inv.Quantity - it.inspectQty)
if kept < 0 {
@@ -259,22 +298,57 @@ func batchFlipInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusInternalServerError, "拆分合格/未检数量失败: "+err.Error())
return
}
- if _, err = tx.Inventory.Create().
- SetManageMode(it.inv.ManageMode).SetSnMode(it.inv.SnMode).SetCategory(it.inv.Category).
- SetMaterialCode(it.inv.MaterialCode).
- SetNillableMaterialName(strPtr(it.inv.MaterialName)).
- SetBatchNo(it.inv.BatchNo + "-NG").
- SetQuantity(it.rejectQty).SetLockedQty(0).
- SetQualityStatus("不合格").SetStatus("待处置").
- SetNillableZoneCode(strPtr(it.inv.ZoneCode)).
- SetNillableInboundNo(strPtr(it.inv.InboundNo)).
- SetRemark("检验自动拆分:不合格部分(待处置)").
- Save(ctx0()); err != nil {
- fail(w, http.StatusInternalServerError, "生成不合格隔离行失败: "+err.Error())
+ // 按处置行拆 -NG 隔离行:批次号 -NG、-NG-2、-NG-3…(处置动作不同、物理同隔离区)
+ for di, d := range it.disposals {
+ ngBatch := it.inv.BatchNo + "-NG"
+ if di > 0 {
+ ngBatch = fmt.Sprintf("%s-NG-%d", it.inv.BatchNo, di+1)
+ }
+ ngQuality, ngStatus := "不合格", "在库"
+ ngLabel := ""
+ switch d.dt {
+ case "RETURN":
+ ngQuality, ngStatus = "待退", "待处置"
+ ngLabel = "退货处置"
+ case "SCRAP":
+ ngQuality, ngStatus = "不合格", "报废"
+ ngLabel = "报废处置"
+ case "REWORK":
+ ngQuality, ngStatus = "不合格", "在库"
+ ngLabel = "返修处置"
+ }
+ remark := fmt.Sprintf("检验自动拆分:%s×%d", ngLabel, d.qty)
+ if d.remark != "" {
+ remark += ";" + d.remark
+ }
+ if _, err = tx.Inventory.Create().
+ SetManageMode(it.inv.ManageMode).SetSnMode(it.inv.SnMode).SetCategory(it.inv.Category).
+ SetMaterialCode(it.inv.MaterialCode).
+ SetNillableMaterialName(strPtr(it.inv.MaterialName)).
+ SetBatchNo(ngBatch).
+ SetQuantity(d.qty).SetLockedQty(0).
+ SetQualityStatus(ngQuality).SetStatus(ngStatus).
+ SetNillableZoneCode(strPtr(it.inv.ZoneCode)).
+ SetNillableInboundNo(strPtr(it.inv.InboundNo)).
+ SetRemark(remark).
+ Save(ctx0()); err != nil {
+ fail(w, http.StatusInternalServerError, "生成不合格隔离行失败: "+err.Error())
+ return
+ }
+ }
+ } else if it.rejectQty > 0 {
+ // SN / 其他类单件行:处置明细只有一行(qty=1),直接翻库存行状态
+ d := it.disposals[0]
+ upd := tx.Inventory.UpdateOneID(it.inv.ID).SetQualityStatus(qualityAfterInspection(it.status, d.dt))
+ if d.dt == "SCRAP" {
+ upd = upd.SetStatus("报废")
+ }
+ if _, err = upd.Save(ctx0()); err != nil {
+ fail(w, http.StatusInternalServerError, "同步库存检验状态失败: "+err.Error())
return
}
} else if _, err = tx.Inventory.UpdateOneID(it.inv.ID).
- SetQualityStatus(qualityAfterInspection(it.status, it.disposal)).Save(ctx0()); err != nil {
+ SetQualityStatus(qualityAfterInspection(it.status, "NONE")).Save(ctx0()); err != nil {
fail(w, http.StatusInternalServerError, "同步库存检验状态失败: "+err.Error())
return
}
@@ -378,9 +452,19 @@ func queryInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return
}
+ // 处置明细汇总(2026-11-16 处置下放明细子表):列表/历史直接展示,前端无需二次查询
+ dispMap := inspectionDisposalTextMap(ctx, list)
+ rows := make([]map[string]any, 0, len(list))
+ for _, rec := range list {
+ b, _ := json.Marshal(rec)
+ m := map[string]any{}
+ _ = json.Unmarshal(b, &m)
+ m["disposalLines"] = dispMap[rec.ID]
+ rows = append(rows, m)
+ }
ok(w, map[string]any{
"total": total,
- "list": list,
+ "list": rows,
"page": page,
"pageSize": pageSize,
})
@@ -468,7 +552,9 @@ func exportInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
if r.URL.Query().Get("format") == "xlsx" {
// 列名按客户口径(问题记录 L150):检验说明→相关标准、检验员→记录人、检验日期→记录日期、增加归属;
// 图号=物料编码(L18 合并裁决)。2026-11-08 移除「第几批/共几件」两列(字段仍落库 0)。
- headers := []string{"ID", "对象", "批次/SN", "图号", "名称", "检验类型", "结论", "检验数", "合格数", "不合格数", "相关标准", "报检单号", "检测单号", "归属单号", "生产厂家", "记录人", "备注", "记录日期"}
+ // 2026-11-16 增加「处置明细」列(处置下放明细子表,按行汇总退货/返修/报废数量与备注)。
+ headers := []string{"ID", "对象", "批次/SN", "图号", "名称", "检验类型", "结论", "检验数", "合格数", "不合格数", "相关标准", "报检单号", "检测单号", "归属单号", "生产厂家", "记录人", "备注", "记录日期", "处置明细"}
+ dispMap := inspectionDisposalTextMap(ctx, list)
matrix := make([][]any, 0, len(list))
for _, rec := range list {
obj := rec.TargetType
@@ -482,7 +568,7 @@ func exportInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
inspectionTypeLabel(rec.InspectionType), rec.Status,
rec.InspectQty, rec.PassQty, rec.RejectQty, rec.RelatedStandard, rec.ReportNo,
rec.InspectionNo, rec.OwnershipNo, rec.Manufacturer, rec.Inspector, rec.Remark,
- unixFmt(rec.CreatedAt),
+ unixFmt(rec.CreatedAt), dispMap[rec.ID],
})
}
sendExcel(w, xlsxFilename("检验记录"), headers, matrix)
@@ -505,16 +591,54 @@ func materialCodesBySpec(ctx *svc.ServiceContext, spec string) []string {
return codes
}
-// disposalTypeOrNone 处置方式归一化(需求23:不合格可转退货 / 换修(返修)/ 报废 / 部分入库)
+// disposalTypeOrNone 处置方式归一化(2026-11-16 拍板:处置下放明细子表,仅 退货/返修/报废 三种;
+// 「部分入库」由送检判定即拆行自动完成,不再作为人工处置选项)
func disposalTypeOrNone(v string) string {
switch v {
- case "RETURN", "SCRAP", "PARTIAL", "REWORK":
+ case "RETURN", "SCRAP", "REWORK":
return v
default:
return "NONE"
}
}
+// inspectionDisposalTextMap 处置明细汇总文本(2026-11-16 处置下放明细子表):
+// 每条检验记录拼接「退货×5;返修×5」,供列表/历史/导出直接展示,无需前端二次查询。
+func inspectionDisposalTextMap(ctx *svc.ServiceContext, list []*ent.InspectionRecord) map[int]string {
+ out := map[int]string{}
+ if len(list) == 0 {
+ return out
+ }
+ ids := make([]int64, 0, len(list))
+ for _, r := range list {
+ ids = append(ids, int64(r.ID))
+ }
+ lines, err := ctx.EntClient.InspectionDisposalItem.Query().
+ Where(inspectiondisposalitem.RecordIDIn(ids...)).All(ctx0())
+ if err != nil {
+ return out
+ }
+ typeName := map[string]string{"RETURN": "退货", "REWORK": "返修", "SCRAP": "报废"}
+ byRec := map[int][]*ent.InspectionDisposalItem{}
+ for _, l := range lines {
+ byRec[int(l.RecordID)] = append(byRec[int(l.RecordID)], l)
+ }
+ for _, r := range list {
+ parts := make([]string, 0, 3)
+ for _, l := range byRec[r.ID] {
+ seg := typeName[l.DisposeType] + "×" + strconv.Itoa(l.Qty)
+ if l.Remark != "" {
+ seg += "(" + l.Remark + ")"
+ }
+ parts = append(parts, seg)
+ }
+ if len(parts) > 0 {
+ out[r.ID] = strings.Join(parts, ";")
+ }
+ }
+ return out
+}
+
// qualityAfterInspection 检验后的库存质量状态:
// 合格 → 合格(可出库);
// 退货(RETURN) → 待退(隔离);返修(REWORK)/报废/其余不合格 → 不合格(隔离,禁止上线)。
@@ -529,20 +653,22 @@ func qualityAfterInspection(status, disposalType string) string {
return "不合格"
}
-// disposeInspectionHandler 不合格品处置(退货 / 报废 / 部分入库)
-// POST /api/inspection/dispose body: { recordId, disposalType, disposalRemark, returnTrackingNo, operator }
+// disposeInspectionHandler 不合格品处置(退货 / 返修 / 报废)——历史「待处置」记录的补处置入口。
+// POST /api/inspection/dispose body: { recordId, disposalType, disposalRemark, operator }
//
// RETURN 退货 → 库存置「待退」隔离(保持数量,等待退货运单确认后出库)
+// REWORK 返修 → 库存置「不合格」隔离,备注标返修,返修后走复检入口
// SCRAP 报废 → 库存置「不合格」且生命周期「报废」,退出可用库存
-// PARTIAL 部分入库 → 仅批次管理:按合格数拆行(合格行入库 + 差额行隔离),数量守恒
+//
+// 2026-11-16 拍板:处置写明细子表 inspection_disposal_items(qty=记录不合格数、备注非必填,
+// 运单号概念废除、物流信息统一填备注);单头不再存处置方式(列已 DROP)。
func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
- RecordID int `json:"recordId"`
- DisposalType string `json:"disposalType"`
- DisposalRemark string `json:"disposalRemark"`
- ReturnTrackingNo string `json:"returnTrackingNo"`
- Operator string `json:"operator"`
+ RecordID int `json:"recordId"`
+ DisposalType string `json:"disposalType"`
+ DisposalRemark string `json:"disposalRemark"`
+ Operator string `json:"operator"`
}
if err := parseJSON(r, &req); err != nil || req.RecordID <= 0 {
fail(w, http.StatusBadRequest, "参数错误:recordId 必填")
@@ -550,7 +676,7 @@ func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
dt := disposalTypeOrNone(req.DisposalType)
if dt == "NONE" {
- fail(w, http.StatusBadRequest, "请选择处置方式(退货/报废/部分入库)")
+ fail(w, http.StatusBadRequest, "请选择处置方式(退货/返修/报废)")
return
}
rec, err := ctx.EntClient.InspectionRecord.Get(ctx0(), req.RecordID)
@@ -567,10 +693,6 @@ func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, err.Error())
return
}
- if dt == "RETURN" && req.ReturnTrackingNo == "" {
- fail(w, http.StatusBadRequest, "退货处置必须填写货运单号")
- return
- }
tx, err := ctx.EntClient.Tx(ctx0())
if err != nil {
@@ -585,16 +707,26 @@ func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}()
// 2026-11-13 拍板:三维度正交——处置状态与检验结论、数量拆分互不混用。
- // 退货/换修/报废/部分入库四种处置统一推进「已处置」,不再只有 PARTIAL 推进。
+ // 2026-11-16 拍板:处置方式/备注下放明细子表,单头只推进处置状态。
if _, err = tx.InspectionRecord.UpdateOneID(rec.ID).
- SetDisposalType(dt).
SetDisposalStatus("已处置").
- SetNillableDisposalRemark(strPtr(req.DisposalRemark)).
- SetNillableReturnTrackingNo(strPtr(req.ReturnTrackingNo)).
Save(ctx0()); err != nil {
fail(w, http.StatusInternalServerError, "更新处置信息失败: "+err.Error())
return
}
+ // 处置明细行(qty=记录不合格数;SN 单件时不合格数=1)
+ dispQty := rec.RejectQty
+ if dispQty <= 0 {
+ dispQty = 1
+ }
+ if _, err = tx.InspectionDisposalItem.Create().
+ SetRecordID(int64(rec.ID)).SetDisposeType(dt).SetQty(dispQty).
+ SetNillableRemark(strPtr(req.DisposalRemark)).
+ SetNillableOperator(strPtr(req.Operator)).
+ Save(ctx0()); err != nil {
+ fail(w, http.StatusInternalServerError, "创建处置明细失败: "+err.Error())
+ return
+ }
switch dt {
case "RETURN":
@@ -613,44 +745,6 @@ func disposeInspectionHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusInternalServerError, "更新库存状态失败: "+err.Error())
return
}
- case "PARTIAL":
- // 2026-11-13:处置状态已在上方统一推进;此处只做数量拆分兼容分支
- // (送检判定时已自动拆分并生成隔离行,避免重复拆行 / 旧口径把未检件算成不合格)。
- if rec.DisposalStatus == "待处置" {
- break
- }
- if inv.SnMode != snModeBatch {
- fail(w, http.StatusBadRequest, "部分入库仅适用于序列号=否(按数量管理)")
- return
- }
- total := inv.Quantity
- if rec.PassQty <= 0 || rec.PassQty >= total {
- fail(w, http.StatusBadRequest, fmt.Sprintf("部分入库:合格数须在 0 与批次数量(%d) 之间", total))
- return
- }
- bad := total - rec.PassQty
- if _, err = tx.Inventory.UpdateOneID(inv.ID).
- SetQuantity(rec.PassQty).SetQualityStatus("合格").Save(ctx0()); err != nil {
- fail(w, http.StatusInternalServerError, "拆分合格批次失败: "+err.Error())
- return
- }
- if _, err = tx.Inventory.Create().
- SetManageMode(inv.ManageMode).
- SetSnMode(inv.SnMode).
- SetCategory(inv.Category).
- SetMaterialCode(inv.MaterialCode).
- SetNillableMaterialName(strPtr(inv.MaterialName)).
- SetBatchNo(inv.BatchNo + "-NG").
- SetQuantity(bad).SetLockedQty(0).
- SetQualityStatus("不合格").
- SetNillableZoneCode(strPtr(inv.ZoneCode)).
- SetStatus("在库").
- SetNillableInboundNo(strPtr(inv.InboundNo)).
- SetRemark("不合格隔离(部分入库差额)").
- Save(ctx0()); err != nil {
- fail(w, http.StatusInternalServerError, "生成不合格隔离行失败: "+err.Error())
- return
- }
}
if err = tx.Commit(); err != nil {
@@ -685,10 +779,11 @@ func applyInventoryDispose(tx *ent.Tx, inv *ent.Inventory, dt string) error {
return fmt.Errorf("不支持的处置方式: %s", dt)
}
-// createDisposeTraceRecord 处置留痕:自动生成一条「不合格」检验记录
+// createDisposeTraceRecord 处置留痕:自动生成一条「不合格」检验记录 + 处置明细子表行
// (复用 batchFlipInspectionHandler 的创建模式:targetId=库存行编号、后端复核不合格数)。
// source 写入 remark 标记留痕来源(在库处置 / MES 联动),便于与来料检记录区分。
-func createDisposeTraceRecord(tx *ent.Tx, inv *ent.Inventory, dt, remark, trackNo, operator, source string) error {
+// 2026-11-16 拍板:处置方式/备注下放明细子表,运单号概念废除(退货物流信息填备注)。
+func createDisposeTraceRecord(tx *ent.Tx, inv *ent.Inventory, dt, remark, operator, source string) error {
targetType := "BATCH"
targetId := inv.BatchNo
qty := inv.Quantity
@@ -700,7 +795,7 @@ func createDisposeTraceRecord(tx *ent.Tx, inv *ent.Inventory, dt, remark, trackN
if qty <= 0 {
qty = 1
}
- _, err := tx.InspectionRecord.Create().
+ rec, err := tx.InspectionRecord.Create().
SetTargetType(targetType).
SetTargetID(targetId).
SetMaterialCode(inv.MaterialCode).
@@ -709,47 +804,49 @@ func createDisposeTraceRecord(tx *ent.Tx, inv *ent.Inventory, dt, remark, trackN
SetInspectQty(qty).
SetPassQty(0).
SetRejectQty(qty).
- SetDisposalType(dt).
- SetNillableDisposalRemark(strPtr(remark)).
- SetNillableReturnTrackingNo(strPtr(trackNo)).
+ SetDisposalStatus("已处置").
SetNillableInspector(strPtr(operator)).
SetNillableRemark(strPtr(source)).
Save(ctx0())
+ if err != nil {
+ return err
+ }
+ _, err = tx.InspectionDisposalItem.Create().
+ SetRecordID(int64(rec.ID)).SetDisposeType(dt).SetQty(qty).
+ SetNillableRemark(strPtr(remark)).
+ SetNillableOperator(strPtr(operator)).
+ Save(ctx0())
return err
}
// inventoryDisposeHandler 在库处置:合格入库后的物料在使用中发现不合格,
// 直接从在库库存行发起处置,不再绕道补录检验记录(缺口 A)。
-// POST /api/inspection/inventory-dispose body: { inventoryId, disposalType, returnTrackingNo, disposalRemark, operator, qty }
+// POST /api/inspection/inventory-dispose body: { inventoryId, disposalType, disposalRemark, operator, qty }
//
-// 仅接受 RETURN/REWORK/SCRAP;在库不存在部分入库场景,PARTIAL 直接报错
+// 仅接受 RETURN/REWORK/SCRAP
// qty 缺省 0=整行处置(向后兼容);序列号=否 0 inv.Quantity {
fail(w, http.StatusBadRequest, "处置数量不能超过该行库存数量")
return
@@ -842,7 +935,7 @@ func inventoryDisposeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
splitID = split.ID
// 留痕/单据以拆分行为数量载体(按 qty 口径,inventoryId 关联拆分行)
splitInv := *split
- if err = createDisposeTraceRecord(tx, &splitInv, dt, traceRemark, req.ReturnTrackingNo, operator, "在库处置留痕"); err != nil {
+ if err = createDisposeTraceRecord(tx, &splitInv, dt, traceRemark, operator, "在库处置留痕"); err != nil {
fail(w, http.StatusInternalServerError, "创建留痕检验记录失败: "+err.Error())
return
}
@@ -854,7 +947,7 @@ func inventoryDisposeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
}
} else {
- if err = createDisposeTraceRecord(tx, inv, dt, req.DisposalRemark, req.ReturnTrackingNo, operator, "在库处置留痕"); err != nil {
+ if err = createDisposeTraceRecord(tx, inv, dt, req.DisposalRemark, operator, "在库处置留痕"); err != nil {
fail(w, http.StatusInternalServerError, "创建留痕检验记录失败: "+err.Error())
return
}
@@ -898,22 +991,21 @@ func inventoryDisposeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
// internalInventoryDisposeHandler MES 质量检验(过程检/完工检)判不合格 → 联动 WMS 在库处置
// (X-API-TOKEN 内部接口,缺口 B;路由经 /api/internal/ 前缀注册,免 JWT、靠写死 token 保护)。
// POST /api/internal/inventory/dispose
-// body: { materialCode, sn, batchNo, disposalType(RETURN/REWORK/SCRAP), returnTrackingNo, remark, operator }
+// body: { materialCode, sn, batchNo, disposalType(RETURN/REWORK/SCRAP), remark, operator }
//
// 定位:SN 料(序列号=是 sn_mode=1)按 material_code+序列号精确唯一;批次料(序列号=否 sn_mode=2)按
// material_code+批次号定位(同批次可能多行,全部置状态)。仅操作「在库」行,0 行返回明确错误。
// 动作与在库处置同语义:RETURN→待退、REWORK→不合格、SCRAP→不合格+报废,
-// 并同样生成留痕检验记录 + 事件日志。
+// 并同样生成留痕检验记录+处置明细子表行 + 事件日志。2026-11-16:运单号概念废除。
func internalInventoryDisposeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
- MaterialCode string `json:"materialCode"`
- Sn string `json:"sn"`
- BatchNo string `json:"batchNo"`
- DisposalType string `json:"disposalType"`
- ReturnTrackingNo string `json:"returnTrackingNo"`
- Remark string `json:"remark"`
- Operator string `json:"operator"`
+ MaterialCode string `json:"materialCode"`
+ Sn string `json:"sn"`
+ BatchNo string `json:"batchNo"`
+ DisposalType string `json:"disposalType"`
+ Remark string `json:"remark"`
+ Operator string `json:"operator"`
}
if err := parseJSON(r, &req); err != nil {
fail(w, http.StatusBadRequest, "参数错误: "+err.Error())
@@ -934,10 +1026,6 @@ func internalInventoryDisposeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, "处置方式仅支持 RETURN/REWORK/SCRAP")
return
}
- if dt == "RETURN" && req.ReturnTrackingNo == "" {
- fail(w, http.StatusBadRequest, "退货处置必须填写退货运单号")
- return
- }
// 定位在库库存行:sn 优先(序列号=是单件),否则按批次(序列号=否,可多行)
var rows []*ent.Inventory
@@ -976,7 +1064,7 @@ func internalInventoryDisposeHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}()
for _, inv := range rows {
- if err = createDisposeTraceRecord(tx, inv, dt, req.Remark, req.ReturnTrackingNo, req.Operator, "MES检验联动留痕"); err != nil {
+ if err = createDisposeTraceRecord(tx, inv, dt, req.Remark, req.Operator, "MES检验联动留痕"); err != nil {
fail(w, http.StatusInternalServerError, "创建留痕检验记录失败: "+err.Error())
return
}
diff --git a/bj_power_wms/internal/handler/reinspect.go b/bj_power_wms/internal/handler/reinspect.go
index 09d4fed..b2ba31f 100644
--- a/bj_power_wms/internal/handler/reinspect.go
+++ b/bj_power_wms/internal/handler/reinspect.go
@@ -62,7 +62,7 @@ func createSupplierReturnOutbound(ctx *svc.ServiceContext, tx *ent.Tx, inv *ent.
// reinspectHandler 复检(换修闭环):针对「在库 + 不合格」的库存行重新判定,闭合换修 / 不合格处置的后续。
// POST /api/inspection/reinspect
-// body: { inventoryId, result(pass/fail), disposalType(RETURN|SCRAP,仅 fail 时生效), returnTrackingNo, remark, operator }
+// body: { inventoryId, result(pass/fail), disposalType(RETURN|SCRAP,仅 fail 时生效), remark, operator }
//
// pass → 质量置「合格」,回可用(换修 / 隔离品修复后重新上线)
// fail + RETURN → 质量置「待退」+ 自动退供应商出库(与 inventoryDisposeHandler 退货同闭环)
@@ -72,12 +72,11 @@ func createSupplierReturnOutbound(ctx *svc.ServiceContext, tx *ent.Tx, inv *ent.
func reinspectHandler(ctx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req struct {
- InventoryID int `json:"inventoryId"`
- Result string `json:"result"`
- DisposalType string `json:"disposalType"`
- ReturnTrackingNo string `json:"returnTrackingNo"`
- Remark string `json:"remark"`
- Operator string `json:"operator"`
+ InventoryID int `json:"inventoryId"`
+ Result string `json:"result"`
+ DisposalType string `json:"disposalType"`
+ Remark string `json:"remark"`
+ Operator string `json:"operator"`
}
if err := parseJSON(r, &req); err != nil || req.InventoryID <= 0 {
fail(w, http.StatusBadRequest, "参数错误:inventoryId 必填")
@@ -106,10 +105,7 @@ func reinspectHandler(ctx *svc.ServiceContext) http.HandlerFunc {
fail(w, http.StatusBadRequest, "复检不合格时必须选择处置方式(退货/报废)")
return
}
- if dt == "RETURN" && req.ReturnTrackingNo == "" {
- fail(w, http.StatusBadRequest, "退货处置必须填写退货运单号")
- return
- }
+ // 2026-11-16 拍板:运单号概念废除,退货物流信息统一填备注(非必填)
}
operator := r.Header.Get("X-Username")
if operator == "" {
@@ -128,26 +124,44 @@ func reinspectHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
}()
- var recStatus, recDisposal, targetQuality string
- switch req.Result {
- case "pass":
- recStatus = "合格"
- recDisposal = ""
- targetQuality = "合格"
- case "fail":
- dt := disposalTypeOrNone(req.DisposalType)
- recStatus = "不合格"
- recDisposal = dt
- if dt == "RETURN" {
- targetQuality = "待退"
- } else {
- targetQuality = "不合格"
- }
+ var recStatus, recDisposal, targetQuality string
+ switch req.Result {
+ case "pass":
+ recStatus = "合格"
+ recDisposal = ""
+ targetQuality = "合格"
+ case "fail":
+ dt := disposalTypeOrNone(req.DisposalType)
+ recStatus = "不合格"
+ recDisposal = dt
+ if dt == "RETURN" {
+ targetQuality = "待退"
+ } else {
+ targetQuality = "不合格"
}
- if err = createReinspectTraceRecord(tx, inv, recStatus, recDisposal, req.Remark, operator); err != nil {
- fail(w, http.StatusInternalServerError, "创建复检留痕记录失败: "+err.Error())
+ }
+ traceRec, err := createReinspectTraceRecord(tx, inv, recStatus, recDisposal, req.Remark, operator)
+ if err != nil {
+ fail(w, http.StatusInternalServerError, "创建复检留痕记录失败: "+err.Error())
+ return
+ }
+ // 2026-11-16 拍板:处置方式下放明细子表——复检不合格留痕同步写处置行(qty=整行数量)
+ if recDisposal != "" {
+ qty := inv.Quantity
+ if inv.SnMode == snModeSN {
+ qty = 1
+ }
+ if qty <= 0 {
+ qty = 1
+ }
+ if _, err = tx.InspectionDisposalItem.Create().
+ SetRecordID(int64(traceRec.ID)).SetDisposeType(recDisposal).SetQty(qty).
+ SetNillableRemark(strPtr(req.Remark)).SetNillableOperator(strPtr(operator)).
+ Save(ctx0()); err != nil {
+ fail(w, http.StatusInternalServerError, "创建处置明细失败: "+err.Error())
return
}
+ }
upd := tx.Inventory.UpdateOneID(inv.ID)
switch targetQuality {
case "合格":
@@ -191,8 +205,9 @@ func reinspectHandler(ctx *svc.ServiceContext) http.HandlerFunc {
}
// createReinspectTraceRecord 复检留痕:生成一条与复检结果一致的检验记录
-// (合格→合格记录;不合格→不合格记录并带处置方式),便于与来料检 / 在库处置记录区分。
-func createReinspectTraceRecord(tx *ent.Tx, inv *ent.Inventory, status, disposal, remark, operator string) error {
+// (合格→合格记录;不合格→不合格记录,处置方式写明细子表),便于与来料检 / 在库处置记录区分。
+// 返回创建的记录(供处置子表行挂 record_id)。
+func createReinspectTraceRecord(tx *ent.Tx, inv *ent.Inventory, status, disposal, remark, operator string) (*ent.InspectionRecord, error) {
targetType := "BATCH"
targetId := inv.BatchNo
qty := inv.Quantity
@@ -221,9 +236,5 @@ func createReinspectTraceRecord(tx *ent.Tx, inv *ent.Inventory, status, disposal
SetRejectQty(rejectQty).
SetNillableInspector(strPtr(operator)).
SetNillableRemark(strPtr("复检留痕 " + remark))
- if disposal != "" {
- b = b.SetNillableDisposalType(strPtr(disposal))
- }
- _, err := b.Save(ctx0())
- return err
+ return b.Save(ctx0())
}
diff --git a/bj_power_wms/internal/mesclient/client.go b/bj_power_wms/internal/mesclient/client.go
index 6bfcfa3..39b5812 100644
--- a/bj_power_wms/internal/mesclient/client.go
+++ b/bj_power_wms/internal/mesclient/client.go
@@ -36,7 +36,7 @@ func New(baseURL, token string) *Client {
baseURL: baseURL,
initialBaseURL: baseURL,
token: token,
- hc: &http.Client{Timeout: 6 * time.Second},
+ hc: &http.Client{Timeout: 6 * time.Second, Transport: newLoggingTransport()},
}
}
@@ -66,7 +66,7 @@ func (c *Client) Ping(ctx context.Context) error {
return err
}
req.Header.Set("X-API-TOKEN", c.token)
- cli := &http.Client{Timeout: 4 * time.Second}
+ cli := &http.Client{Timeout: 4 * time.Second, Transport: newLoggingTransport()}
resp, err := cli.Do(req)
if err != nil {
return fmt.Errorf("无法连接 MES(%s):%v", c.BaseURL(), err)
diff --git a/bj_power_wms/internal/mesclient/transport_logging.go b/bj_power_wms/internal/mesclient/transport_logging.go
new file mode 100644
index 0000000..9ac4d47
--- /dev/null
+++ b/bj_power_wms/internal/mesclient/transport_logging.go
@@ -0,0 +1,65 @@
+// transport_logging.go WMS→MES 全量 HTTP 交互日志(2026-11-16 联调)。
+// http.RoundTripper 装饰器:挂在 Client.hc 与 Ping 临时 client 上,
+// 所有出口(getJSON/postJSON/Ping/LookupFinishedBySN/ListMaterialRequests 等)自动全覆盖。
+// 记录:请求方法/完整URL/请求体(截断)、响应状态码/响应体(截断)、传输错误。
+// 前缀 [WMS→MES]。
+package mesclient
+
+import (
+ "bytes"
+ "context"
+ "fmt"
+ "io"
+ "net/http"
+
+ "github.com/zeromicro/go-zero/core/logx"
+)
+
+// loggingTransport 日志装饰 transport。
+type loggingTransport struct{ base http.RoundTripper }
+
+// FailHook MES 通讯失败钩子(2026-11-16):仅【传输层失败】(连不上/超时/断连)触发,
+// HTTP 非 2xx 与业务码非 0 属正常业务响应不触发。main 启动时装配(落预警中心),
+// 去重由回调实现方负责(窗口去重),本层只负责在错误发生时通知。
+var FailHook func(ctx context.Context, method, url string, err error)
+
+func newLoggingTransport() *loggingTransport {
+ return &loggingTransport{base: http.DefaultTransport}
+}
+
+func (t *loggingTransport) RoundTrip(req *http.Request) (*http.Response, error) {
+ u := req.URL.String()
+ var reqBody []byte
+ if req.Body != nil {
+ reqBody, _ = io.ReadAll(req.Body)
+ _ = req.Body.Close()
+ req.Body = io.NopCloser(bytes.NewReader(reqBody))
+ }
+ logx.WithContext(req.Context()).Infof("[WMS→MES] --> %s %s body=%s", req.Method, u, truncateLogBytes(reqBody))
+
+ resp, err := t.base.RoundTrip(req)
+ if err != nil {
+ logx.WithContext(req.Context()).Errorf("[WMS→MES] <-- transport error %s err=%v", u, err)
+ if FailHook != nil {
+ FailHook(req.Context(), req.Method, u, err)
+ }
+ return resp, err
+ }
+ raw, rerr := io.ReadAll(resp.Body)
+ _ = resp.Body.Close()
+ if rerr != nil {
+ logx.WithContext(req.Context()).Errorf("[WMS→MES] <-- read body error %s status=%d err=%v", u, resp.StatusCode, rerr)
+ }
+ resp.Body = io.NopCloser(bytes.NewReader(raw))
+ logx.WithContext(req.Context()).Infof("[WMS→MES] <-- HTTP %d %s body=%s", resp.StatusCode, u, truncateLogBytes(raw))
+ return resp, nil
+}
+
+// truncateLogBytes 日志防刷爆:超 2000 字节截断。
+func truncateLogBytes(b []byte) string {
+ const max = 2000
+ if len(b) <= max {
+ return string(b)
+ }
+ return string(b[:max]) + fmt.Sprintf("...(截断,共%d字节)", len(b))
+}
diff --git a/bj_power_wms/schema/inspection_disposal_item.go b/bj_power_wms/schema/inspection_disposal_item.go
new file mode 100644
index 0000000..c22ba1b
--- /dev/null
+++ b/bj_power_wms/schema/inspection_disposal_item.go
@@ -0,0 +1,39 @@
+package schema
+
+import (
+ "entgo.io/ent"
+ "entgo.io/ent/dialect/entsql"
+ "entgo.io/ent/schema"
+ "entgo.io/ent/schema/field"
+ "entgo.io/ent/schema/index"
+)
+
+// InspectionDisposalItem 不合格品处置明细子表(2026-11-16 用户拍板:处置下放明细行)。
+// 一条不合格检验记录可对应多条处置行(如 10 个不合格 = 5 退货 + 5 返修,各自带数量与备注)。
+// 送检判定提交时写入并即时执行库存动作(拆行/翻状态);历史「待处置」记录经 /inspection/dispose
+// 补处置时也写入本表。处置方式 RETURN=退货 / REWORK=返修 / SCRAP=报废;运单号概念已废除,
+// 退货物流信息统一填 remark(非必填)。
+type InspectionDisposalItem struct {
+ ent.Schema
+}
+
+func (InspectionDisposalItem) Annotations() []schema.Annotation {
+ return []schema.Annotation{entsql.Annotation{Table: "inspection_disposal_items"}, entsql.WithComments(true), schema.Comment("InspectionDisposalItem 不合格品处置明细(按数量分退货/返修/报废)")}
+}
+
+func (InspectionDisposalItem) Fields() []ent.Field {
+ return []ent.Field{
+ field.Int64("record_id").Comment("父检验记录ID(inspection_records.id)"),
+ field.String("dispose_type").Comment("处置方式 RETURN/REWORK/SCRAP"),
+ field.Int("qty").Positive().Comment("本行处置数量(合计=记录不合格数)"),
+ field.String("remark").Optional().Comment("处置备注(非必填;退货物流信息也填此处)"),
+ field.String("operator").Default("").Comment("操作人"),
+ field.Int64("created_at").DefaultFunc(nowUnix),
+ }
+}
+
+func (InspectionDisposalItem) Indexes() []ent.Index {
+ return []ent.Index{
+ index.Fields("record_id"),
+ }
+}
diff --git a/bj_power_wms/schema/inspection_record.go b/bj_power_wms/schema/inspection_record.go
index 90d9fb2..19e3d54 100644
--- a/bj_power_wms/schema/inspection_record.go
+++ b/bj_power_wms/schema/inspection_record.go
@@ -54,15 +54,13 @@ func (InspectionRecord) Fields() []ent.Field {
// 2026-11-13 拍板:处置维度与「检验结论」「数量拆分」正交拆开,废除特采/让步接收。
// ① 检验结论 inspection_conclusion:合格/不合格/待检/挑选(只答"这批判定成什么")
// ② 数量拆分 inspect_qty / pass_qty / reject_qty:提交时自动拆行,不合格部分生成隔离库存行
- // ③ 不合格品处置 disposal_type/disposal_status:只作用于不合格部分,独立状态机
+ // ③ 不合格品处置 disposal_status:只作用于不合格部分,独立状态机
+ // 2026-11-16 拍板(用户):处置方式下放明细子表 inspection_disposal_items(按数量分退货/返修/报废、
+ // 各行自带备注),本表不再有 disposal_type / disposal_remark / return_tracking_no 单头字段(已 DROP);
+ // 退货物流信息统一填子表行备注(非必填)。
field.String("inspection_conclusion").Default("").Comment("检验结论 合格/不合格/待检/挑选(与处置方式正交)"),
- field.String("disposal_status").Default("").Comment("不合格品处置状态 待处置/退货中/已退货/返修中/已返修/已报废/已处置"),
+ field.String("disposal_status").Default("").Comment("不合格品处置状态 待处置/已处置"),
field.Int64("parent_record_id").Default(0).Comment("拆行来源检验记录ID(不合格隔离行回挂原单)"),
- // NONE=不适用(合格或未判定) / RETURN=退货 / SCRAP=报废 / PARTIAL=部分入库 / REWORK=返修
- // 注意:本字段只描述「不合格那部分怎么处置」,不再兼任整批结论。
- field.String("disposal_type").Default("NONE").Comment("不合格部分处置 NONE/RETURN/SCRAP/PARTIAL/REWORK"),
- field.String("disposal_remark").Optional().Comment("处置说明(报废/退货原因)"),
- field.String("return_tracking_no").Optional().Comment("退货货运单号"),
field.String("remark").Optional().Comment("备注"),
field.Int64("created_at").DefaultFunc(nowUnix),
field.Int64("updated_at").DefaultFunc(nowUnix),
diff --git a/bj_power_wms/web/static/index.html b/bj_power_wms/web/static/index.html
index 6f40a6d..e713be9 100644
--- a/bj_power_wms/web/static/index.html
+++ b/bj_power_wms/web/static/index.html
@@ -6,7 +6,7 @@
WMS库房管理
-
+
diff --git a/bj_power_workstation/frontend/src/views/panels/OnlinePanel.vue b/bj_power_workstation/frontend/src/views/panels/OnlinePanel.vue
index 082fec5..9c8bf8e 100644
--- a/bj_power_workstation/frontend/src/views/panels/OnlinePanel.vue
+++ b/bj_power_workstation/frontend/src/views/panels/OnlinePanel.vue
@@ -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) {
diff --git a/bj_power_workstation/frontend/src/views/panels/WorkPanel.vue b/bj_power_workstation/frontend/src/views/panels/WorkPanel.vue
index 6a722b9..715bd3f 100644
--- a/bj_power_workstation/frontend/src/views/panels/WorkPanel.vue
+++ b/bj_power_workstation/frontend/src/views/panels/WorkPanel.vue
@@ -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 已在本工位直接开干;否则提示去"上料/取料"
diff --git a/bj_power_workstation/frontend/vite.config.js b/bj_power_workstation/frontend/vite.config.js
index 939aa88..df3d0b0 100644
--- a/bj_power_workstation/frontend/vite.config.js
+++ b/bj_power_workstation/frontend/vite.config.js
@@ -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
}
}
-})
\ No newline at end of file
+})
diff --git a/bj_power_workstation/internal/handler/workpiece.go b/bj_power_workstation/internal/handler/workpiece.go
index 9095690..a3f615b 100644
--- a/bj_power_workstation/internal/handler/workpiece.go
+++ b/bj_power_workstation/internal/handler/workpiece.go
@@ -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)
}
diff --git a/bj_power_workstation/internal/mes/client.go b/bj_power_workstation/internal/mes/client.go
index 864793f..6372079 100644
--- a/bj_power_workstation/internal/mes/client.go
+++ b/bj_power_workstation/internal/mes/client.go
@@ -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)
diff --git a/bj_power_workstation/web/static/index.html b/bj_power_workstation/web/static/index.html
index f5828c7..9999ed6 100644
--- a/bj_power_workstation/web/static/index.html
+++ b/bj_power_workstation/web/static/index.html
@@ -6,7 +6,7 @@
工位终端
-
+
diff --git a/问题临时.md b/问题临时.md
index 0a713eb..efd52ea 100644
--- a/问题临时.md
+++ b/问题临时.md
@@ -1,25 +1,6 @@
4、日排产有透视,他想历史的也能透视,日排产和历史的他还想导出、还有对比。当前日排产显示是还没有生产的东西,客户希望历史的内容也能看到,也能有透视 排产表。而且他希望导出来日排产的这些规划和历史的规划,然后做对比
7、工位终端重新捋一下,他不知道自己干完了没有,最主要是,工人不知道自己应该不应该下线完工,或者是上线建档。他不清楚这个。 并且上料建档右边显示的物料,这个物料是个什么东西?为什么要显示这个?你把定位中端这些东西定义清楚,这个工位中心的页面,你在操作方便不方便?这个页签到底是定位是什么
-8、库房加1234红色小角标,并加声音提示,还是总结有哪一项需要提示。:::: 客户希望WMS和MES左边的菜单可以加红色的提示小角标,如果有待办事项就提示他,你首先得捋捋,哪些东西需要提示,哪些东西不需要提示。通知类的都需要提示,比如说较量库管这边就需要提示的,这个触发互动类的消息都需要提示,而且要有一个类似于是否未读未处理这样的标识。
-9、看板最上面一行(今日产量、产量达成、在制工件、)可以选择显示内容。你再推荐一些模块。MES能不能像WMS一样,右上角有一个免登录大屏,MES免登录大屏,打开就是生产看板
-11、库房免登录大屏,备料叫料池、滚动的内容。客户希望 “待出库”置顶?这能做吗?也就是带出库的是不滚动的,下面一送达的滚动,大家都在滚动列表里面
-
-
-
-
-1、mes 工艺 工艺列表,筛选条件 产品工艺,应该是下拉框选择,不是让手动输入。
-
-3、mes 工艺 产品工艺列表,某条数据是只读的时候,你也应该让他看详情,现在没办法看详情。
-4、每道可改,改后后续工序的候选自动更新。 查看产品工艺。”查看产品工艺“ ,跳转的时候,应该带上这个产品工艺的搜索条件
-5、mes 日排产 执行状态 为什么默认选择 ”未完成(排除已完成/已取消)“ 我没理解,你这几个状态,我在帮助文档里面也没看到,帮助文档净写些没用的东西。 送达接驳台 显示也不对,全项目的都捋一遍,显示
-工位左右、库房接驳台,中文。 送达接驳台(派生),同理,显示中文不要再出现 DOCK 。 “显示历史”我没看到数据,帮我造一些数据,帮助文档里面也没说这个按钮是什么意思,跟状态有什么关系。
-15、工位终端: 待流转在制品,MES 实时查询。已建档、尚未分配到工位的工件。看清已建档待流转的工件,防止重复建档 ??? 这个功能太奇葩了,重复建档就重复建档,重复建档你就提醒他没有必要单独去展示这么一个模块。 工位终端的帮助文档,你写得太烂了,废弃在这种格式吧,太烂了。字段说明的格式,这些字段没必要一个一个说明,影响范围说明清楚,怎么样流转,怎么操作,你个傻逼,以前跟你聊过,你咋给忘了。 上线建的“工单信息”,去掉吧,好像你展示的都是些没用的信息,这个页面如果没有这么多功能,不要硬挤,你做完工单以后,下面不是已经有一些工单的基本详情了吗?比如数量,你就把它写到那儿就行了,不用占这么大地方。 刷新工单,去除这个按钮,实时从后台读,并且这个下拉框也不要展示过多,防止内存炸弹,展示10条几条就行了,如果有太多的话,搜索的时候实时从后台图,如果展示词条不够,也可以是滚动式分页,但是不要一下子把数据全拉过来,且工单的状态,你要过虑清楚。
-16、工位终端,作业,我测试时登录的是工位一,问:当时显示的是 “当前工件” 没有选择,为什么“当前任务” 流程步骤,是不是逻辑有问题,当然你也可以说没问题,比如说当前工位已经确定好它的工艺流程步骤了,所以没有工件它的步骤也是确定的。但是为什么又只有一个芯片安装呢?这个工艺节点对应的好多步骤。 好好捋捋。
-17、工位终端,所有列表可能出现很多数据的地方都应该滚动翻页,不能用页码分页,因为操作不方便,滚动分页往下一滚一滚一滚拉更多数据,你考虑一下。
-
-18、工位终端 "巡检 / 异常" 标记上小红点1,但是你去并不知道具体要干什么
-
@@ -33,15 +14,11 @@
-2、wms “未找到对应的工单,请确认产品工号是否正确” 分析一下,这个对应的什么需求,随提出来的。
3、wms 批量导入 错误提示: 请先选择 .xlsx 文件 。。实际上,我已经选择了模板
4、wms 来料检验,处置方式,重新梳理、特别是:部分入库,那部分不入库 不合格的,没有处理方式,所以 跟前面的保修,等,好像不是同一个维度。 客户还提出了其它需求,咨询我一起头脑风暴
5、来料检: 质量检验记录 ,id 10 ,图号 Jiao001 , 明明是部分入库,但是库存,合格数量显示0,应该是1,因为合格了 一个。
6、现状:越看 图号、批次/产品序号(SN)、处置方式、复检、不合格品处置 弹窗 是不是乱。找我核对业务细节,弄清楚了,再改。 客户说,成品 没有“图号” ,那么成品入库、mes的物料档案都需要改,Mes的物料档案改成 成品档案 。 还有WMS的物料档案中的物料编码,成品档案也没有,虽然共用一张表,但是业务层面页面上显示不要一样,你捋一捋。
-7、wms 成品入库,应该根据sN自动带出工单,里面的图号、产品名称归属都不需要再改了,都是固定的。产品状态,不对了,重新捋一捋参考上面的问题描述。并且 记录员 不允许修改,不仅仅要记录名称,也要记录当前登录人的ID。 mes 新增物料档案 因为时成品,类型,客户说类型也不需要选择,表肯定还是要统一表,就是页面上,如果在页面有个区分,涉及到出入库、档案、生产配送、选物料 等这些地方。
-8、wms 生产退不良、退库确认、成品入库、入库管理 , 当前系统,我想把有些功能流程串起来比较难,比如我就很疑惑,生产退出员和退出车子都有什么区别,你有没有什么行业里面更好的版本,让流程更清晰,不仅仅是所有相似的菜单、帮助文档。例如,在制品管理,又变成了一个菜单,里面包含了入库、出库,那刚才前面的产品为什么只有成品入库,整体风格不统一,流程不清晰,各个菜单关联不上,看不出来。 又比如:mes 转产退料,我根本不知道它的来龙去脉,从哪里来,到哪里去,整条流程是什么,产生什么影响,如果 “说明文字:“工位故障转产流程(两步)””,画出来树状流程图,并且允许点击跳转到相关菜单? 你不要局限我的描述。 跟我讨论清楚,再做定论。
-9、bug “暂无载货台账(取货/卸货确认或人工维护后生成)” ,这个页面,应该分页。
-10、工艺,工艺配置,物料清单,是不是不跟工艺编辑混合 比较好,因为保存 物料清单时,会再保存一遍工艺,并且,有可能工艺的更改 和 物料的更改 ,限制条件不一样。
+
11、mes 新建工单,产品工艺,没有数据时,现状显示0,应该显示,请选择。并且每次点击应该实时去请求API,避免管理后台维护了,这边还显示的不出来
12、mes 、生成工位模板、 当前流水线:尚未勾选工位 ??? 逻辑无法闭环,什么时候选工位,谁指挥谁,没有定义清楚职责
13、生成工位模板 时,提示: “工位1同时被多个产品工艺(Dx-101 跳闸(成品) 工艺、DX-100 电表箱(成品) 工艺)要求,套用后这些产品共用此绑定;工位2同时被多个产品工艺(Dx-101 跳闸(成品) 工艺、DX-100 电表箱(成品) 工艺)要求,套用后这些产品共用此绑定;工位3同时被多个产品工艺(Dx-101 跳闸(成品) 工艺、DX-100 电表箱(成品) 工艺)要求,套用后这些产品共用此绑定;工位4同时被多个产品工艺(Dx-101 跳闸(成品) 工艺、DX-100 电表箱(成品) 工艺)要求,套用后这些产品共用此绑定” 这个描述太啰嗦。 你看看数据库数据,竟然保存成功了。 并且 在 mes工位管理工位模板 工位 → 绑定工艺,没有显示 哪个工位能干哪个成品。 并且“本次要生产的产品(用于产品一致性校验): ” 什么意思,看不到,并且,“预检并应用” 按钮功能不变,名称改为 “应用”,前面再加一个“预检” 。套用前检查 ,也没说清楚哪个工位能生产哪个成品。预检,我有新疑问,不能直接预检 并 说明原因吗? 搞得操作步骤多并且乱。并且,我问,“生成工位模板”时,没有检查吗?这里再检查一次是什么特殊情况。并且我还有问题,如果,产线没有清理干净(有托盘、工位有物料、plc有未完成的任务),能改工位工艺吗? 整个功能都不够顺畅,请 跟我讨论清楚,行业标准做法是什么。
@@ -138,3 +115,26 @@ wms:
+
+
+
+1、成品档案:图号(唯一码)由系统自动生成,类型与序列号由系统固定,无需填写;成品没有物料编码。? 图号为必填项(创建后不可改)?
+补充:成品里面不要再出现图号这个东西也不要再出现物料编码,不管是说明文字还是列表。 MeS系统保存的时候报错了“图号为必填项(创建后不可改)”
+导入你也看一眼。 既然图号是自动生成的:那么统一前缀叫什么好呢? 组成方式: 前缀-年月日-001 递增。 物料编码统一为空 “” 空字符串
+2、日排产有透视,历史的也能透视,对比。 再详细地跟我说一下它的逻辑,因为我提到过,排产是实时算出来的,会根据工艺等变动,历史数据是工单,实际生产完以后每天落的数据跟排产的实时计算还不一样,这一块你是怎么做的
+3、“该产品未选择「序列号(是/否)」:请先在 MES 产品型号/物料档案设置,否则无法建档上线。” ,工位中断,这个说明要改一下了,上线建档只针对成品,不要再出现任何物料相关的描述
+4、工位终端上线建档,警察执行AI取证,有一个特殊的场景,他如果完完成某一个东西,全部想在虚拟工位,也就是不上线儿,应该怎么做,还是说所有的虚拟都不应该跟上线建档工位的物料相关呢?如果真是这样,现在的虚拟工位也是用的工位终端,这套东西又怎么办呢?AI取证给建议,主控AI给方案,想想清楚
+5、库房加1234红色小角标,并加声音提示???原来客户提出的这个需求,现在是什么样的一个状况,能不能提示清楚到底应该怎么操作。
+6、所有的下拉选择框(wms、mes、工位终端),检查一遍,要求:可以模糊搜索,滚动分页,显示排序跟对应的列表一样。你把所有下拉框捋一捋,不同情况分不同说,我只是建议,把我说的话当成唯一标准。同时也提醒你,捋一捋所有的列表,看他的排序符合人的要求吗?执行AI取证,主控AI以人的角度分析
+7、mes 工艺列表,只有编辑,没有详情?因为菜单按钮是分开的,有的人能查看详情,有的人能编辑,你现在有编辑的时候就没有详情权限,怎么分。mes和wms两个系统,你都看一下,还有这种情况没有?不要再干这种傻事儿。
+8、mes 日排产 执行状态 ”未完成(排除已完成/已取消)“,可以默认选择这个,上次只是问你为什么,你怎么又把他给删了,像这些状态类的东西,在帮助文档一定要写清楚对应的意思是什么
+9、工位终端,作业。因为一个工位只能配一个工艺,所以,当这个工位有工艺配置的时候,这个工位,即便是没有安排排产,即便是没有干活儿,也要能看到他的各个步骤。并且有个疑问或者说觉得不妥的地方:工单号?需要在作业这个页面选择工单号吗?工艺?如果这个页面只显示一条工艺名称,那这个页面有什么意义, 是不是“步骤采集”就能代替他。AI取证主控AI以人的角度分析分析
+10、当前代码逻辑取证:产线允许工单混产,同一个工位工位允许不同步骤吗?不同工单吗?它的物料和较量又是怎么算的?你搞搞清楚,讨论讨论,以人的角度。我们以前讨论这个问题,但是我忘了当时的结果是什么了,你可以提出更合理的。为中断,我提过滑动分页,你看看是否已实现。还有工位终端选择的所有的工单他的状态是不是都应该是进行中的呢,或者日排产呢?你清
+11、mes PLC管理 强制清零,帮助文档的这个描述可能需要更人性化一点,看了以后不知道他是在改PLC内存,而且改这个应该很危险吧,我不了解,不清楚这个有多危险,你说它的影响范围会不会把整个运行程序给弄坏了,你建议这么改吗?这个页面到底是说管控系统的内存标识和PlC不一致,还是说Plc在途时间太长,矫正的时候,是要矫正控制产线的go程序的数据库,还是矫正PlC?你好好捋捋。什么影响
+12、wms “未找到对应的工单,请确认产品工号是否正确” 分析一下,这个对应的什么需求,谁提出来的? 这是以前讨论过的一个,我忘了当时的答案是什么了
+13、wms 来料检验 处置方式 货运单号。奇怪的地方,1、选择不合格,还需要返回到上面去填这些东西,2、货运单号不应该必填,其他几个选项 没有写说明的地方,3、同一个来料检查的所有的不合格,用的是同样的处理方式,会不会有一些是要返修的,有一些是要退货的,有不同的处理方式呢?他也不是整批退,也可能是部分退,部分返修,这一部分返修,那一部分退。你捋捋。原来我记得个bug,就是我选择部分的时候,结果全部没有入库,你再捋一捋。
+
+
+
+
+