From 3cc783b5ff3e4d2c24d9f154d5921342671dd8f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=87=E7=9D=BF=20=E5=BC=A0?= Date: Wed, 14 Oct 2026 16:05:36 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E6=95=B0=E6=8D=AE=E8=BF=81?= =?UTF-8?q?=E7=A7=BB=EF=BC=8C=E5=B9=B6=E8=AE=A9=E6=AF=8F=E4=B8=AA=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E8=87=AA=E5=B8=A6=E9=BB=98=E8=AE=A4=E5=8D=95=E4=BD=8D?= =?UTF-8?q?=E4=B8=8E=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 数据迁移(北京 / 武汉两个 SQLite 物料库 → wmms) - 北京进默认组织、武汉单独建组织:两套分类编码完全相同但含义不同(北京 A01=标准件, 武汉 A01=机加工件),共存会撞 material_categories 的组织内编码唯一约束 - 199 条物料、37 个企业、45 条变更日志,以及各分类的 code_rules.next_sequence (对齐到已导入的最大序号 +1,否则用户新增物料会撞上已有编码) - 迁移段并入 scripts/init.sql 末尾,空库初始化即得完整数据 公司默认数据 - 新建公司时种入 32 个物料单位 + 默认仓库 + 主库位,与建公司同事务, 种一半失败会整体回滚(否则留下一个没单位、又占着公司编码的组织) - 单位在后端按公司隔离(MaterialRepo.IsActiveUnit 要求物料引用的单位属于本公司), 此前新建的公司连单位下拉都是空的,物料的 base_unit_id 也无处可指 - init.sql 的单位段补齐「块」「Pcs」,与代码里的清单保持逐条一致 默认组织更名:默认公司组织 → 北京 --- internal/repository/organization.go | 19 +- internal/repository/organization_defaults.go | 82 + .../repository/organization_defaults_test.go | 137 ++ scripts/init.sql | 1953 ++++++++++++++++- 4 files changed, 2187 insertions(+), 4 deletions(-) create mode 100644 internal/repository/organization_defaults.go create mode 100644 internal/repository/organization_defaults_test.go diff --git a/internal/repository/organization.go b/internal/repository/organization.go index 0e323d8e..3d690872 100644 --- a/internal/repository/organization.go +++ b/internal/repository/organization.go @@ -34,13 +34,28 @@ func (r *OrganizationRepository) List() ([]model.Organization, error) { return organizations, rows.Err() } +// Create 建公司并同时种上默认主数据(物料单位、默认仓库与主库位)。两者放在一个 +// 事务里:只建成公司却没种上单位,新公司连物料单位下拉都是空的,而用户重试还会 +// 撞上公司编码的唯一键。 func (r *OrganizationRepository) Create(item *model.Organization) error { - result, err := database.DB.Exec(`INSERT INTO organizations (code, name, status, default_timezone) VALUES (?, ?, ?, ?)`, item.Code, item.Name, item.Status, item.DefaultTimezone) + tx, err := database.DB.Begin() + if err != nil { + return err + } + defer func() { _ = tx.Rollback() }() + + result, err := tx.Exec(`INSERT INTO organizations (code, name, status, default_timezone) VALUES (?, ?, ?, ?)`, item.Code, item.Name, item.Status, item.DefaultTimezone) if err != nil { return err } item.ID, err = result.LastInsertId() - return err + if err != nil { + return err + } + if err := seedOrganizationDefaultsTx(tx, item.ID); err != nil { + return err + } + return tx.Commit() } func (r *OrganizationRepository) Update(item *model.Organization) error { diff --git a/internal/repository/organization_defaults.go b/internal/repository/organization_defaults.go new file mode 100644 index 00000000..98444693 --- /dev/null +++ b/internal/repository/organization_defaults.go @@ -0,0 +1,82 @@ +package repository + +import ( + "database/sql" + + "github.com/wmms/wmms/internal/model" +) + +// defaultMaterialUnits 是每个公司开箱可用的物料单位,与 scripts/init.sql 里给默认 +// 组织种的那套逐条一致(含后补的「块」与「Pcs」)。 +// +// 单位在后端是按公司隔离的:MasterDataRepository.ListUnits 按 organization_id +// 过滤,MaterialRepo.IsActiveUnit 还要求物料引用的单位必须属于同一 +// 公司。所以新建公司时必须把这份清单一起种下去,否则新公司连单位下拉都是空的, +// 物料的 base_unit_id 也无处可指。 +var defaultMaterialUnits = []model.Unit{ + {Code: "个", Name: "个"}, + {Code: "件", Name: "件"}, + {Code: "只", Name: "只"}, + {Code: "支", Name: "支"}, + {Code: "根", Name: "根"}, + {Code: "条", Name: "条"}, + {Code: "片", Name: "片"}, + {Code: "张", Name: "张"}, + {Code: "套", Name: "套"}, + {Code: "台", Name: "台"}, + {Code: "对", Name: "对"}, + {Code: "双", Name: "双"}, + {Code: "包", Name: "包"}, + {Code: "袋", Name: "袋"}, + {Code: "盒", Name: "盒"}, + {Code: "箱", Name: "箱"}, + {Code: "瓶", Name: "瓶"}, + {Code: "罐", Name: "罐"}, + {Code: "桶", Name: "桶"}, + {Code: "卷", Name: "卷"}, + {Code: "块", Name: "块"}, + {Code: "Pcs", Name: "件"}, + // 重量、容量、长度、面积保留 3 位小数,计数类单位是整数。 + {Code: "g", Name: "克", PrecisionScale: 3}, + {Code: "kg", Name: "千克", PrecisionScale: 3}, + {Code: "t", Name: "吨", PrecisionScale: 3}, + {Code: "mL", Name: "毫升", PrecisionScale: 3}, + {Code: "L", Name: "升", PrecisionScale: 3}, + {Code: "m³", Name: "立方米", PrecisionScale: 3}, + {Code: "mm", Name: "毫米", PrecisionScale: 3}, + {Code: "cm", Name: "厘米", PrecisionScale: 3}, + {Code: "m", Name: "米", PrecisionScale: 3}, + {Code: "m²", Name: "平方米", PrecisionScale: 3}, +} + +// seedOrganizationDefaultsTx 给新公司种上开箱可用的主数据:上面那份物料单位, +// 外加一个默认仓库和一个主库位。仓库与库位各只允许一个(init.sql 里有对应的唯一键 +// uk_warehouses_organization / uk_warehouse_locations_warehouse),所以固定给一对。 +// +// 走事务是为了和 organizations 的插入同生共死:种一半失败会留下一个既没单位、 +// 又已经占用了公司编码的组织,用户重试还会撞 uk_organizations_code。 +func seedOrganizationDefaultsTx(tx *sql.Tx, organizationID int64) error { + for _, unit := range defaultMaterialUnits { + if _, err := tx.Exec( + `INSERT INTO units (organization_id, code, name, precision_scale, status) VALUES (?, ?, ?, ?, 'active')`, + organizationID, unit.Code, unit.Name, unit.PrecisionScale); err != nil { + return err + } + } + + result, err := tx.Exec( + `INSERT INTO warehouses (organization_id, code, name, status) VALUES (?, 'DEFAULT', '默认仓库', 'active')`, + organizationID) + if err != nil { + return err + } + warehouseID, err := result.LastInsertId() + if err != nil { + return err + } + + _, err = tx.Exec( + `INSERT INTO warehouse_locations (warehouse_id, code, name, status) VALUES (?, 'MAIN', '主库位', 'active')`, + warehouseID) + return err +} diff --git a/internal/repository/organization_defaults_test.go b/internal/repository/organization_defaults_test.go new file mode 100644 index 00000000..b3557cf0 --- /dev/null +++ b/internal/repository/organization_defaults_test.go @@ -0,0 +1,137 @@ +package repository + +import ( + "errors" + "os" + "path/filepath" + "regexp" + "testing" + + "github.com/DATA-DOG/go-sqlmock" + "github.com/wmms/wmms/internal/model" + "github.com/wmms/wmms/pkg/database" +) + +// 与 organization.go / organization_defaults.go 里的语句逐字一致。 +const ( + createOrganizationSQL = `INSERT INTO organizations (code, name, status, default_timezone) VALUES (?, ?, ?, ?)` + seedUnitSQL = `INSERT INTO units (organization_id, code, name, precision_scale, status) VALUES (?, ?, ?, ?, 'active')` + seedWarehouseSQL = `INSERT INTO warehouses (organization_id, code, name, status) VALUES (?, 'DEFAULT', '默认仓库', 'active')` + seedLocationSQL = `INSERT INTO warehouse_locations (warehouse_id, code, name, status) VALUES (?, 'MAIN', '主库位', 'active')` +) + +func newOrganizationSeedMock(t *testing.T) sqlmock.Sqlmock { + t.Helper() + db, mock, err := sqlmock.New() + if err != nil { + t.Fatalf("open sql mock: %v", err) + } + t.Cleanup(func() { database.DB = nil; db.Close() }) + database.DB = db + return mock +} + +// 单位是按公司隔离的,新公司没种单位的话,物料单位下拉是空的,base_unit_id 也无处可指。 +func TestCreateOrganizationSeedsUnitsWarehouseAndLocation(t *testing.T) { + mock := newOrganizationSeedMock(t) + mock.ExpectBegin() + mock.ExpectExec(regexp.QuoteMeta(createOrganizationSQL)). + WithArgs("WUHAN", "武汉", "active", "Asia/Shanghai"). + WillReturnResult(sqlmock.NewResult(7, 1)) + for _, unit := range defaultMaterialUnits { + mock.ExpectExec(regexp.QuoteMeta(seedUnitSQL)). + WithArgs(int64(7), unit.Code, unit.Name, unit.PrecisionScale). + WillReturnResult(sqlmock.NewResult(1, 1)) + } + mock.ExpectExec(regexp.QuoteMeta(seedWarehouseSQL)). + WithArgs(int64(7)). + WillReturnResult(sqlmock.NewResult(3, 1)) + mock.ExpectExec(regexp.QuoteMeta(seedLocationSQL)). + WithArgs(int64(3)). + WillReturnResult(sqlmock.NewResult(5, 1)) + mock.ExpectCommit() + + item := &model.Organization{Code: "WUHAN", Name: "武汉", Status: "active", DefaultTimezone: "Asia/Shanghai"} + if err := NewOrganizationRepository().Create(item); err != nil { + t.Fatalf("Create: %v", err) + } + if item.ID != 7 { + t.Fatalf("回填的组织 ID = %d,期望 7", item.ID) + } + if err := mock.ExpectationsWereMet(); err != nil { + t.Fatalf("有期望未被满足(漏种或多给了语句): %v", err) + } +} + +// 种子失败必须整体回滚:留下一个没有单位的公司,用户重试还会撞公司编码的唯一键。 +func TestCreateOrganizationRollsBackWhenSeedingFails(t *testing.T) { + mock := newOrganizationSeedMock(t) + mock.ExpectBegin() + mock.ExpectExec(regexp.QuoteMeta(createOrganizationSQL)). + WithArgs("WUHAN", "武汉", "active", "Asia/Shanghai"). + WillReturnResult(sqlmock.NewResult(7, 1)) + // 第一个单位就失败 + mock.ExpectExec(regexp.QuoteMeta(seedUnitSQL)). + WithArgs(int64(7), defaultMaterialUnits[0].Code, defaultMaterialUnits[0].Name, defaultMaterialUnits[0].PrecisionScale). + WillReturnError(errors.New("boom")) + mock.ExpectRollback() + + err := NewOrganizationRepository().Create(&model.Organization{ + Code: "WUHAN", Name: "武汉", Status: "active", DefaultTimezone: "Asia/Shanghai", + }) + if err == nil { + t.Fatal("种子失败时 Create 应当返回错误") + } + if err := mock.ExpectationsWereMet(); err != nil { + t.Fatalf("有期望未被满足: %v", err) + } +} + +// 单位表有 uk_units_org_code 唯一键,清单里出现重复编码会让建公司直接失败。 +func TestDefaultMaterialUnitsHaveNoDuplicateCodes(t *testing.T) { + seen := make(map[string]bool, len(defaultMaterialUnits)) + for _, unit := range defaultMaterialUnits { + if seen[unit.Code] { + t.Fatalf("默认单位清单里编码重复:%q", unit.Code) + } + seen[unit.Code] = true + } +} + +// 新建公司种下的单位,必须和 scripts/init.sql 给默认组织种的那套一致; +// 两份清单各改各的,空库初始化与界面上新建的公司就会拿到不同的单位表。 +func TestDefaultMaterialUnitsMatchInitSQL(t *testing.T) { + raw, err := os.ReadFile(filepath.Join("..", "..", "scripts", "init.sql")) + if err != nil { + t.Fatalf("读取 init.sql: %v", err) + } + // units 段的行形如 (1,'个','个',0,'active');这个五字段模式在 init.sql 里 + // 只匹配单位表(分类是四字段、仓库是五字段但首列是数字)。 + row := regexp.MustCompile(`\(1,'([^']+)','[^']*',(\d+),'active'\)`) + fromSQL := make(map[string]bool) + for _, m := range row.FindAllStringSubmatch(string(raw), -1) { + fromSQL[m[1]] = true + } + if len(fromSQL) == 0 { + t.Fatalf("没从 init.sql 里解析出默认组织的单位,正则可能已失效") + } + + fromGo := make(map[string]model.Unit, len(defaultMaterialUnits)) + for _, unit := range defaultMaterialUnits { + fromGo[unit.Code] = unit + } + + for code := range fromGo { + if !fromSQL[code] { + t.Errorf("Go 默认单位清单里有 %q,init.sql 里没有", code) + } + } + for code := range fromSQL { + if _, ok := fromGo[code]; !ok { + t.Errorf("init.sql 里有单位 %q,Go 默认清单里没有", code) + } + } + if len(fromGo) != len(fromSQL) { + t.Errorf("单位数量不一致:Go %d 个,init.sql %d 个", len(fromGo), len(fromSQL)) + } +} diff --git a/scripts/init.sql b/scripts/init.sql index 0caa722b..ee8d3875 100644 --- a/scripts/init.sql +++ b/scripts/init.sql @@ -75,8 +75,9 @@ INSERT INTO schema_migrations(version,status,completed_at,details) VALUES('2026- INSERT INTO schema_migrations(version,status,completed_at,details) VALUES('2026-10-14-material-log-operator-id','completed',NOW(),JSON_OBJECT('version','2026-10-14-material-log-operator-id','source','fresh-init')); -INSERT INTO organizations (id,code,name,status) VALUES (1,'DEFAULT','默认公司组织','active'); --- 常用计量单位归属默认公司;计数、包装使用整数,重量、容量、长度、面积保留 3 位小数。 +INSERT INTO organizations (id,code,name,status) VALUES (1,'DEFAULT','北京','active'); +-- 每个公司各有一整套物料单位(单位在后端按公司隔离,物料只能引用本公司的单位)。 +-- 计数、包装使用整数,重量、容量、长度、面积保留 3 位小数。 INSERT INTO units (organization_id,code,name,precision_scale,status) VALUES (1,'个','个',0,'active'), (1,'件','件',0,'active'), @@ -98,6 +99,8 @@ INSERT INTO units (organization_id,code,name,precision_scale,status) VALUES (1,'罐','罐',0,'active'), (1,'桶','桶',0,'active'), (1,'卷','卷',0,'active'), + (1,'块','块',0,'active'), + (1,'Pcs','件',0,'active'), (1,'g','克',3,'active'), (1,'kg','千克',3,'active'), (1,'t','吨',3,'active'), @@ -289,3 +292,1949 @@ WHERE op.organization_id = @demo_organization_id ORDER BY op.partner_code; DROP TEMPORARY TABLE tmp_demo_partners_20261008; + + +-- ============================================================================ +-- 北京 / 武汉 物料数据(由 sqlite-to-mysql-migration/migrate_to_mysql.py 生成) +-- +-- 两个源库的分类体系编码相同但含义不同(北京 A01=标准件,武汉 A01=机加工件), +-- 因此北京数据落在默认组织、武汉单独占一个组织,各自带自己的分类树。 +-- +-- 段落幂等:重复执行不会产生重复数据,也不会覆盖已改过的字段(物料走 +-- ON DUPLICATE KEY UPDATE,其余走 NOT EXISTS)。 +-- ============================================================================ + +-- ============================================================ +-- 数据迁移:北京 / 武汉 两个 SQLite 物料库 → wmms +-- 由 migrate_to_mysql.py 生成,幂等,可重复执行。 +-- 前提:目标库已用 warehouse-mms/scripts/init.sql 建好结构与基础配置。 +-- 导入请务必带 --default-character-set=utf8mb4,否则中文会乱码。 +-- ============================================================ +SET NAMES utf8mb4; + +-- ---------- 目标组织 ---------- +INSERT INTO organizations (code, name, status) +SELECT 'WUHAN', '武汉', 'active' FROM DUAL +WHERE NOT EXISTS (SELECT 1 FROM organizations WHERE code='WUHAN'); +SET @org_bj = (SELECT id FROM organizations WHERE code='DEFAULT' LIMIT 1); +SET @org_wh = (SELECT id FROM organizations WHERE code='WUHAN' LIMIT 1); + +-- ---------- 分类树(只补目标组织里缺的)---------- + +-- 武汉:24 个分类 +DROP TEMPORARY TABLE IF EXISTS tmp_cat_wh; +CREATE TEMPORARY TABLE tmp_cat_wh ( + code VARCHAR(50) NOT NULL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + description VARCHAR(1000) NOT NULL DEFAULT '', + parent_code VARCHAR(50) NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +INSERT INTO tmp_cat_wh (code, name, description, parent_code) VALUES + ('A', '外协件类', '', NULL), + ('B', '外购件类', '', NULL), + ('C', '软件类', '', NULL), + ('D', '试剂及耗材类', '', NULL), + ('E', '包装材料类', '', NULL), + ('F', '成品/半成品类', '成品、半成品', NULL), + ('A01', '机加工件', '', 'A'), + ('A02', '钣金件', '', 'A'), + ('A03', '塑胶件', '', 'A'), + ('A04', '治具类', '', 'A'), + ('A05', '其它类', '', 'A'), + ('B01', '电子类', '', 'B'), + ('B02', '机械类', '', 'B'), + ('B03', '其他类', '', 'B'), + ('C01', '软件', '', 'C'), + ('D01', '理化试剂类', '', 'D'), + ('D02', '耗材类', '', 'D'), + ('E01', '内包装材料类', '', 'E'), + ('E02', '外包装材料类', '', 'E'), + ('E03', '标签类', '', 'E'), + ('E04', '说明书类', '', 'E'), + ('E05', '其他类', '', 'E'), + ('F01', '半成品', '', 'F'), + ('F02', '成品', '', 'F'); +-- 先建分类(parent 留空),再回填 parent_id。 +-- 不能一条 INSERT…SELECT 里 JOIN 目标表:查不到同一语句刚插入的大类。 +INSERT INTO material_categories (organization_id, code, name, description) +SELECT @org_wh, t.code, t.name, t.description +FROM tmp_cat_wh t +WHERE NOT EXISTS ( + SELECT 1 FROM material_categories e + WHERE e.organization_id = @org_wh AND e.code = t.code +); +UPDATE material_categories c +JOIN tmp_cat_wh t ON t.code = c.code +JOIN material_categories p + ON p.organization_id = c.organization_id AND p.code = t.parent_code +SET c.parent_id = p.id +WHERE c.organization_id = @org_wh AND t.parent_code IS NOT NULL; +DROP TEMPORARY TABLE tmp_cat_wh; + +-- ---------- 物料单位 ---------- +-- 单位在后端按公司隔离:物料引用的单位必须属于同一公司(MaterialRepo.IsActiveUnit)。 +-- 所以每个公司都要有自己的一整套,不能几个公司共用一份。已有的跳过。 +DROP TEMPORARY TABLE IF EXISTS tmp_units; +CREATE TEMPORARY TABLE tmp_units ( + code VARCHAR(50) NOT NULL PRIMARY KEY, + name VARCHAR(100) NOT NULL, + precision_scale TINYINT NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +INSERT INTO tmp_units (code, name, precision_scale) VALUES + ('个', '个', 0), + ('件', '件', 0), + ('只', '只', 0), + ('支', '支', 0), + ('根', '根', 0), + ('条', '条', 0), + ('片', '片', 0), + ('张', '张', 0), + ('套', '套', 0), + ('台', '台', 0), + ('对', '对', 0), + ('双', '双', 0), + ('包', '包', 0), + ('袋', '袋', 0), + ('盒', '盒', 0), + ('箱', '箱', 0), + ('瓶', '瓶', 0), + ('罐', '罐', 0), + ('桶', '桶', 0), + ('卷', '卷', 0), + ('块', '块', 0), + ('Pcs', '件', 0), + ('g', '克', 3), + ('kg', '千克', 3), + ('t', '吨', 3), + ('mL', '毫升', 3), + ('L', '升', 3), + ('m³', '立方米', 3), + ('mm', '毫米', 3), + ('cm', '厘米', 3), + ('m', '米', 3), + ('m²', '平方米', 3); +INSERT INTO units (organization_id, code, name, precision_scale, status) +SELECT o.id, t.code, t.name, t.precision_scale, 'active' +FROM tmp_units t +CROSS JOIN organizations o +WHERE o.code IN ('DEFAULT', 'WUHAN') + AND NOT EXISTS ( + SELECT 1 FROM units u WHERE u.organization_id = o.id AND u.code = t.code + ); +DROP TEMPORARY TABLE tmp_units; + +-- ---------- 各单位 id ---------- +SET @u_bj_pcs = (SELECT id FROM units WHERE organization_id=@org_bj AND code='Pcs' LIMIT 1); -- Pcs +SET @u_bj_ge = (SELECT id FROM units WHERE organization_id=@org_bj AND code='个' LIMIT 1); -- 个 +SET @u_bj_jian = (SELECT id FROM units WHERE organization_id=@org_bj AND code='件' LIMIT 1); -- 件 +SET @u_bj_g = (SELECT id FROM units WHERE organization_id=@org_bj AND code='g' LIMIT 1); -- g +SET @u_bj_cm = (SELECT id FROM units WHERE organization_id=@org_bj AND code='cm' LIMIT 1); -- cm +SET @u_bj_tai = (SELECT id FROM units WHERE organization_id=@org_bj AND code='台' LIMIT 1); -- 台 +SET @u_bj_kuai = (SELECT id FROM units WHERE organization_id=@org_bj AND code='块' LIMIT 1); -- 块 +SET @u_bj_tao = (SELECT id FROM units WHERE organization_id=@org_bj AND code='套' LIMIT 1); -- 套 +SET @u_bj_gen = (SELECT id FROM units WHERE organization_id=@org_bj AND code='根' LIMIT 1); -- 根 +SET @u_bj_ml = (SELECT id FROM units WHERE organization_id=@org_bj AND code='mL' LIMIT 1); -- mL +SET @u_bj_m = (SELECT id FROM units WHERE organization_id=@org_bj AND code='m' LIMIT 1); -- m +SET @u_wh_pcs = (SELECT id FROM units WHERE organization_id=@org_wh AND code='Pcs' LIMIT 1); -- Pcs +SET @u_wh_ge = (SELECT id FROM units WHERE organization_id=@org_wh AND code='个' LIMIT 1); -- 个 +SET @u_wh_jian = (SELECT id FROM units WHERE organization_id=@org_wh AND code='件' LIMIT 1); -- 件 +SET @u_wh_g = (SELECT id FROM units WHERE organization_id=@org_wh AND code='g' LIMIT 1); -- g +SET @u_wh_cm = (SELECT id FROM units WHERE organization_id=@org_wh AND code='cm' LIMIT 1); -- cm +SET @u_wh_tai = (SELECT id FROM units WHERE organization_id=@org_wh AND code='台' LIMIT 1); -- 台 +SET @u_wh_kuai = (SELECT id FROM units WHERE organization_id=@org_wh AND code='块' LIMIT 1); -- 块 +SET @u_wh_tao = (SELECT id FROM units WHERE organization_id=@org_wh AND code='套' LIMIT 1); -- 套 +SET @u_wh_gen = (SELECT id FROM units WHERE organization_id=@org_wh AND code='根' LIMIT 1); -- 根 +SET @u_wh_ml = (SELECT id FROM units WHERE organization_id=@org_wh AND code='mL' LIMIT 1); -- mL +SET @u_wh_m = (SELECT id FROM units WHERE organization_id=@org_wh AND code='m' LIMIT 1); -- m + +-- ---------- 默认仓库与主库位 ---------- +-- 每个公司一对:仓库与库位在 init.sql 里各有一个「每公司/每仓库只能有一个」的唯一键。 +INSERT INTO warehouses (organization_id, code, name, status) +SELECT o.id, 'DEFAULT', '默认仓库', 'active' +FROM organizations o +WHERE o.code IN ('DEFAULT', 'WUHAN') + AND NOT EXISTS (SELECT 1 FROM warehouses w + WHERE w.organization_id = o.id AND w.code = 'DEFAULT'); +INSERT INTO warehouse_locations (warehouse_id, code, name, status) +SELECT w.id, 'MAIN', '主库位', 'active' +FROM warehouses w +JOIN organizations o ON o.id = w.organization_id +WHERE o.code IN ('DEFAULT', 'WUHAN') + AND NOT EXISTS (SELECT 1 FROM warehouse_locations l + WHERE l.warehouse_id = w.id AND l.code = 'MAIN'); + +-- ---------- 分类 id ---------- +SET @c_bj_A = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A' LIMIT 1); -- 机械结构类 +SET @c_bj_B = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B' LIMIT 1); -- 电气元器件类 +SET @c_bj_C = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='C' LIMIT 1); -- 产品工艺耗材类 +SET @c_bj_D = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='D' LIMIT 1); -- 软件&固件&授权类 +SET @c_bj_E = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='E' LIMIT 1); -- 半成品&成品类 +SET @c_bj_F = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='F' LIMIT 1); -- 包材类 +SET @c_bj_A01 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A01' LIMIT 1); -- 标准件 +SET @c_bj_A02 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A02' LIMIT 1); -- 成品件 +SET @c_bj_A03 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A03' LIMIT 1); -- 简易加工件 +SET @c_bj_A04 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A04' LIMIT 1); -- 精密加工件 +SET @c_bj_A05 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A05' LIMIT 1); -- 钣金件 +SET @c_bj_A06 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A06' LIMIT 1); -- 塑胶件 +SET @c_bj_A07 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='A07' LIMIT 1); -- 其他 +SET @c_bj_B01 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B01' LIMIT 1); -- 成品件 +SET @c_bj_B02 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B02' LIMIT 1); -- 简易加工件 +SET @c_bj_B03 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B03' LIMIT 1); -- PCB硬板 +SET @c_bj_B04 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B04' LIMIT 1); -- FPC软板 +SET @c_bj_B05 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B05' LIMIT 1); -- 线束 +SET @c_bj_B06 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B06' LIMIT 1); -- 组装组件 +SET @c_bj_B07 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='B07' LIMIT 1); -- 其他 +SET @c_bj_C01 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='C01' LIMIT 1); -- 连接耗材 +SET @c_bj_C02 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='C02' LIMIT 1); -- 密封耗材 +SET @c_bj_C03 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='C03' LIMIT 1); -- 其他 +SET @c_bj_D01 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='D01' LIMIT 1); -- 自研程序固件 +SET @c_bj_D02 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='D02' LIMIT 1); -- 外购软件授权 +SET @c_bj_D03 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='D03' LIMIT 1); -- 授权介质 +SET @c_bj_D04 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='D04' LIMIT 1); -- 其他 +SET @c_bj_E01 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='E01' LIMIT 1); -- 成品 +SET @c_bj_E02 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='E02' LIMIT 1); -- 半成品 +SET @c_bj_F01 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='F01' LIMIT 1); -- 资料文档 +SET @c_bj_F02 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='F02' LIMIT 1); -- 标识标牌 +SET @c_bj_F03 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='F03' LIMIT 1); -- 包装物料 +SET @c_bj_F04 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='F04' LIMIT 1); -- 随机工具配件 +SET @c_bj_F05 = (SELECT id FROM material_categories WHERE organization_id=@org_bj AND code='F05' LIMIT 1); -- 其他 +SET @c_wh_A = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='A' LIMIT 1); -- 外协件类 +SET @c_wh_B = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='B' LIMIT 1); -- 外购件类 +SET @c_wh_C = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='C' LIMIT 1); -- 软件类 +SET @c_wh_D = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='D' LIMIT 1); -- 试剂及耗材类 +SET @c_wh_E = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='E' LIMIT 1); -- 包装材料类 +SET @c_wh_F = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='F' LIMIT 1); -- 成品/半成品类 +SET @c_wh_A01 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='A01' LIMIT 1); -- 机加工件 +SET @c_wh_A02 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='A02' LIMIT 1); -- 钣金件 +SET @c_wh_A03 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='A03' LIMIT 1); -- 塑胶件 +SET @c_wh_A04 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='A04' LIMIT 1); -- 治具类 +SET @c_wh_A05 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='A05' LIMIT 1); -- 其它类 +SET @c_wh_B01 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='B01' LIMIT 1); -- 电子类 +SET @c_wh_B02 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='B02' LIMIT 1); -- 机械类 +SET @c_wh_B03 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='B03' LIMIT 1); -- 其他类 +SET @c_wh_C01 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='C01' LIMIT 1); -- 软件 +SET @c_wh_D01 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='D01' LIMIT 1); -- 理化试剂类 +SET @c_wh_D02 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='D02' LIMIT 1); -- 耗材类 +SET @c_wh_E01 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='E01' LIMIT 1); -- 内包装材料类 +SET @c_wh_E02 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='E02' LIMIT 1); -- 外包装材料类 +SET @c_wh_E03 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='E03' LIMIT 1); -- 标签类 +SET @c_wh_E04 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='E04' LIMIT 1); -- 说明书类 +SET @c_wh_E05 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='E05' LIMIT 1); -- 其他类 +SET @c_wh_F01 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='F01' LIMIT 1); -- 半成品 +SET @c_wh_F02 = (SELECT id FROM material_categories WHERE organization_id=@org_wh AND code='F02' LIMIT 1); -- 成品 + +-- ---------- 企业(供应商 / 厂家)---------- +-- 源里只有名字,联系方式等字段留空;partner_code 是本次迁移编的。 +DROP TEMPORARY TABLE IF EXISTS tmp_partner_bj; +CREATE TEMPORARY TABLE tmp_partner_bj ( + partner_code VARCHAR(50) NOT NULL PRIMARY KEY, + legal_name VARCHAR(200) NOT NULL, + is_supplier BOOLEAN NOT NULL, + is_manufacturer BOOLEAN NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +INSERT INTO tmp_partner_bj (partner_code, legal_name, is_supplier, is_manufacturer) VALUES + ('BJ-P001', '上海鸣志', TRUE, TRUE), + ('BJ-P002', '博通', FALSE, TRUE), + ('BJ-P003', '鑫拓智能', TRUE, TRUE); +-- 企业档案(按法定名称去重) +INSERT INTO business_partners (legal_name) +SELECT t.legal_name FROM tmp_partner_bj t +WHERE NOT EXISTS (SELECT 1 FROM business_partners b WHERE b.legal_name = t.legal_name); +-- 组织与企业的关联 +INSERT INTO organization_partners + (organization_id, business_partner_id, partner_code, is_supplier, is_manufacturer, + supplier_status, customer_status, settlement_currency, payment_terms) +SELECT @org_bj, b.id, t.partner_code, t.is_supplier, t.is_manufacturer, + CASE WHEN t.is_supplier THEN 'active' ELSE NULL END, NULL, 'CNY', NULL +FROM tmp_partner_bj t +JOIN business_partners b ON b.legal_name = t.legal_name +WHERE NOT EXISTS ( + SELECT 1 FROM organization_partners e + WHERE e.organization_id = @org_bj + AND (e.partner_code = t.partner_code OR e.business_partner_id = b.id) +); +DROP TEMPORARY TABLE tmp_partner_bj; + +DROP TEMPORARY TABLE IF EXISTS tmp_partner_wh; +CREATE TEMPORARY TABLE tmp_partner_wh ( + partner_code VARCHAR(50) NOT NULL PRIMARY KEY, + legal_name VARCHAR(200) NOT NULL, + is_supplier BOOLEAN NOT NULL, + is_manufacturer BOOLEAN NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +INSERT INTO tmp_partner_wh (partner_code, legal_name, is_supplier, is_manufacturer) VALUES + ('WH-P001', '北京亦鑫诚自动化科技有限公司', TRUE, FALSE), + ('WH-P002', '北京研控智诚科技有限公司', TRUE, FALSE), + ('WH-P003', '深圳市维君瑞科技有限公司', TRUE, FALSE), + ('WH-P004', '北京科奥普瑞电气技术有限公司', TRUE, FALSE), + ('WH-P005', '卡川尔流体科技(上海)有限公司', TRUE, FALSE), + ('WH-P006', '北昂流体系统(上海)有限公司', TRUE, FALSE), + ('WH-P007', '北京致远合创电子科技有限公司', TRUE, FALSE), + ('WH-P008', '欧时电子元件(上海)有限公司', TRUE, FALSE), + ('WH-P009', '东莞市纳百智造技术有限公司', TRUE, FALSE), + ('WH-P010', '武汉市普创模型技术有限公司', TRUE, FALSE), + ('WH-P011', '唐山共兴电子有限公司', TRUE, FALSE), + ('WH-P012', '南京润泽流体控制设备有限公司', TRUE, FALSE), + ('WH-P013', '上海红波电器有限公司', TRUE, FALSE), + ('WH-P014', '特耐王重型包装武汉有限公司', TRUE, FALSE), + ('WH-P015', '武汉市江汉区博杰广告印务中心', TRUE, FALSE), + ('WH-P016', '北京恒瑞博远科技有限公司', TRUE, FALSE), + ('WH-P017', '佛山戊实五金有限公司', TRUE, FALSE), + ('WH-P018', '杭州九湃', TRUE, FALSE), + ('WH-P019', '东莞市友联亨达光电有限公司', TRUE, FALSE), + ('WH-P020', '北京天拓四方科技股份有限公司', TRUE, FALSE), + ('WH-P021', '江苏信富盛精密科技有限公司', TRUE, FALSE), + ('WH-P022', '武汉乐普菲克新材料有限公司', TRUE, FALSE), + ('WH-P023', '东莞市臻和电子科技有限公司', TRUE, FALSE), + ('WH-P024', '深圳市福联达电热电器有限公司', TRUE, FALSE), + ('WH-P025', '深圳市德懋塑胶有限公司', TRUE, FALSE), + ('WH-P026', '广东烨嘉光电科技股份有限公司', TRUE, FALSE), + ('WH-P027', '东莞市永盈胶粘制品有限公司', TRUE, FALSE), + ('WH-P028', '深圳市美星新材料科技有限公司', TRUE, FALSE), + ('WH-P029', '昆山聚格电子材料有限公司', TRUE, FALSE), + ('WH-P030', '奥力拓医用包装材料(苏州)有限公司', TRUE, FALSE), + ('WH-P031', '德恩', FALSE, TRUE), + ('WH-P032', '科耐特', FALSE, TRUE), + ('WH-P033', '香橙派', TRUE, FALSE), + ('WH-P034', '海葵星', TRUE, FALSE); +-- 企业档案(按法定名称去重) +INSERT INTO business_partners (legal_name) +SELECT t.legal_name FROM tmp_partner_wh t +WHERE NOT EXISTS (SELECT 1 FROM business_partners b WHERE b.legal_name = t.legal_name); +-- 组织与企业的关联 +INSERT INTO organization_partners + (organization_id, business_partner_id, partner_code, is_supplier, is_manufacturer, + supplier_status, customer_status, settlement_currency, payment_terms) +SELECT @org_wh, b.id, t.partner_code, t.is_supplier, t.is_manufacturer, + CASE WHEN t.is_supplier THEN 'active' ELSE NULL END, NULL, 'CNY', NULL +FROM tmp_partner_wh t +JOIN business_partners b ON b.legal_name = t.legal_name +WHERE NOT EXISTS ( + SELECT 1 FROM organization_partners e + WHERE e.organization_id = @org_wh + AND (e.partner_code = t.partner_code OR e.business_partner_id = b.id) +); +DROP TEMPORARY TABLE tmp_partner_wh; + +-- ---------- 伙伴 id ---------- +SET @p_bj_001 = (SELECT id FROM organization_partners WHERE organization_id=@org_bj AND partner_code='BJ-P001' LIMIT 1); -- 上海鸣志 +SET @p_bj_002 = (SELECT id FROM organization_partners WHERE organization_id=@org_bj AND partner_code='BJ-P002' LIMIT 1); -- 博通 +SET @p_bj_003 = (SELECT id FROM organization_partners WHERE organization_id=@org_bj AND partner_code='BJ-P003' LIMIT 1); -- 鑫拓智能 +SET @p_wh_001 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P001' LIMIT 1); -- 北京亦鑫诚自动化科技有限公司 +SET @p_wh_002 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P002' LIMIT 1); -- 北京研控智诚科技有限公司 +SET @p_wh_003 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P003' LIMIT 1); -- 深圳市维君瑞科技有限公司 +SET @p_wh_004 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P004' LIMIT 1); -- 北京科奥普瑞电气技术有限公司 +SET @p_wh_005 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P005' LIMIT 1); -- 卡川尔流体科技(上海)有限公司 +SET @p_wh_006 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P006' LIMIT 1); -- 北昂流体系统(上海)有限公司 +SET @p_wh_007 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P007' LIMIT 1); -- 北京致远合创电子科技有限公司 +SET @p_wh_008 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P008' LIMIT 1); -- 欧时电子元件(上海)有限公司 +SET @p_wh_009 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P009' LIMIT 1); -- 东莞市纳百智造技术有限公司 +SET @p_wh_010 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P010' LIMIT 1); -- 武汉市普创模型技术有限公司 +SET @p_wh_011 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P011' LIMIT 1); -- 唐山共兴电子有限公司 +SET @p_wh_012 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P012' LIMIT 1); -- 南京润泽流体控制设备有限公司 +SET @p_wh_013 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P013' LIMIT 1); -- 上海红波电器有限公司 +SET @p_wh_014 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P014' LIMIT 1); -- 特耐王重型包装武汉有限公司 +SET @p_wh_015 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P015' LIMIT 1); -- 武汉市江汉区博杰广告印务中心 +SET @p_wh_016 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P016' LIMIT 1); -- 北京恒瑞博远科技有限公司 +SET @p_wh_017 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P017' LIMIT 1); -- 佛山戊实五金有限公司 +SET @p_wh_018 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P018' LIMIT 1); -- 杭州九湃 +SET @p_wh_019 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P019' LIMIT 1); -- 东莞市友联亨达光电有限公司 +SET @p_wh_020 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P020' LIMIT 1); -- 北京天拓四方科技股份有限公司 +SET @p_wh_021 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P021' LIMIT 1); -- 江苏信富盛精密科技有限公司 +SET @p_wh_022 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P022' LIMIT 1); -- 武汉乐普菲克新材料有限公司 +SET @p_wh_023 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P023' LIMIT 1); -- 东莞市臻和电子科技有限公司 +SET @p_wh_024 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P024' LIMIT 1); -- 深圳市福联达电热电器有限公司 +SET @p_wh_025 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P025' LIMIT 1); -- 深圳市德懋塑胶有限公司 +SET @p_wh_026 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P026' LIMIT 1); -- 广东烨嘉光电科技股份有限公司 +SET @p_wh_027 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P027' LIMIT 1); -- 东莞市永盈胶粘制品有限公司 +SET @p_wh_028 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P028' LIMIT 1); -- 深圳市美星新材料科技有限公司 +SET @p_wh_029 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P029' LIMIT 1); -- 昆山聚格电子材料有限公司 +SET @p_wh_030 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P030' LIMIT 1); -- 奥力拓医用包装材料(苏州)有限公司 +SET @p_wh_031 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P031' LIMIT 1); -- 德恩 +SET @p_wh_032 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P032' LIMIT 1); -- 科耐特 +SET @p_wh_033 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P033' LIMIT 1); -- 香橙派 +SET @p_wh_034 = (SELECT id FROM organization_partners WHERE organization_id=@org_wh AND partner_code='WH-P034' LIMIT 1); -- 海葵星 + +-- ---------- 物料 ---------- +-- 源的 type_code 指向分类(如 B01),落到 materials.category_id。 +-- materials.material_type_id 是另一套语义(原材料/半成品/成品),这里留空。 +-- 源里没有 drawing_no 的落点(目标表无此列),两库该字段本来就全空。 +-- spec 与 unit 为空时写空串而不是 NULL:后端把这两列直接 Scan 进 string +-- (不是 sql.NullString),写 NULL 会让物料列表/详情接口 500。 +-- ===== 北京:16 条 ===== +INSERT INTO materials + (organization_id, material_code, name, spec, source, remark, + supplier_id, manufacturer_id, category_id, base_unit_id, unit, + status, version, created_at, updated_at) +VALUES + (@org_bj, 'B010201', 'RCM俯仰-进给-电机', + 'ESF32016H48-S003+I32-2052', '外购', NULL, + @p_bj_001, @p_bj_001, @c_bj_B01, NULL, '', + 'active', 1, '2026-09-15 08:55:12', '2026-09-17 07:05:29'), + (@org_bj, 'B010202', 'RCM进给自由度-多圈绝对值编码器', + 'AS20-M42M-B11', '外购', NULL, + NULL, @p_bj_002, @c_bj_B01, @u_bj_ge, '个', + 'active', 1, '2026-09-16 06:14:37', '2026-09-17 07:04:39'), + (@org_bj, 'A020201', 'RCM俯仰关节-谐波减速器', + 'HD Mini-05', '外购', NULL, + @p_bj_003, @p_bj_003, @c_bj_A02, @u_bj_ge, '个', + 'active', 1, '2026-09-17 01:51:05', '2026-09-17 07:04:23'), + (@org_bj, 'A040201', '旋转件2-1', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-28 06:24:29'), + (@org_bj, 'A040202', '旋转件2-2', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-28 06:24:15'), + (@org_bj, 'A040203', '旋转件1', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-28 06:23:40'), + (@org_bj, 'A040204', '销轴', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-24 06:37:08'), + (@org_bj, 'A040205', '中间件', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-24 06:37:08'), + (@org_bj, 'A030201', 'PTFE垫片', + '', '外协', NULL, + NULL, NULL, @c_bj_A03, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-24 06:37:08'), + (@org_bj, 'A030202', '垫片', + '', '外协', NULL, + NULL, NULL, @c_bj_A03, NULL, '', + 'active', 1, '2026-09-24 06:37:08', '2026-09-24 06:37:08'), + (@org_bj, 'A040206', 'LJJ镊子从端-001', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, @u_bj_pcs, 'Pcs', + 'active', 1, '2026-10-10 07:54:29', '2026-10-10 07:54:29'), + (@org_bj, 'A040207', 'LJJ镊子从端-002', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, @u_bj_pcs, 'Pcs', + 'active', 1, '2026-10-10 07:54:29', '2026-10-10 07:54:29'), + (@org_bj, 'A040208', 'LJJ镊子从端-003', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, @u_bj_pcs, 'Pcs', + 'active', 1, '2026-10-10 07:54:29', '2026-10-10 07:54:29'), + (@org_bj, 'A040209', 'LJJ镊子从端-004', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, @u_bj_pcs, 'Pcs', + 'active', 1, '2026-10-10 07:54:29', '2026-10-10 07:54:29'), + (@org_bj, 'A040210', 'LJJ镊子从端-005', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, @u_bj_pcs, 'Pcs', + 'active', 1, '2026-10-10 07:54:29', '2026-10-10 07:54:29'), + (@org_bj, 'A040211', 'LJJ镊子从端-006', + '', '外协', NULL, + NULL, NULL, @c_bj_A04, @u_bj_pcs, 'Pcs', + 'active', 1, '2026-10-10 07:54:29', '2026-10-10 07:54:57') +AS new +ON DUPLICATE KEY UPDATE + name = new.name, spec = new.spec, source = new.source, remark = new.remark, + supplier_id = new.supplier_id, manufacturer_id = new.manufacturer_id, + category_id = new.category_id, base_unit_id = new.base_unit_id, unit = new.unit, + status = new.status, updated_at = new.updated_at; + +-- ===== 武汉:183 条 ===== +INSERT INTO materials + (organization_id, material_code, name, spec, source, remark, + supplier_id, manufacturer_id, category_id, base_unit_id, unit, + status, version, created_at, updated_at) +VALUES + (@org_wh, 'B010002', '直流开关电源-24V', + 'MPM-30-24ST', NULL, '单台数量:1; 物料等级:A; 存储条件:温度-40°C至85°C,湿度10%至95%RH (无冷凝); 验收准则:检验', + @p_wh_001, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010003', '直流开关电源-12V', + 'MPM-30-12ST', NULL, '单台数量:1; 物料等级:A; 存储条件:温度-40°C至85°C,湿度10%至95%RH (无冷凝); 验收准则:检验', + @p_wh_001, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010004', '直流开关电源-5V', + 'MPM-30-5ST', NULL, '单台数量:1; 物料等级:A; 存储条件:温度-40°C至85°C,湿度10%至95%RH (无冷凝); 验收准则:检验', + @p_wh_001, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010005', '单板电脑', + 'MIO-5152J', NULL, '单台数量:1; 物料等级:A; 存储条件:温度0°C至60°C,湿度40%至95%RH (无冷凝); 验收准则:检验; 备注:配置(8G;128G;WIN10;适配器)', + @p_wh_002, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010010', 'NTC传感器变送器', + 'SAR16-NTC10K-P1-A4', NULL, '单台数量:4; 物料等级:B; 存储条件:温度-40°C至85°C,湿度10%至95%RH(无凝露); 验收准则:检验; 备注:输入:NTC10k,0-45°C', + @p_wh_003, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010011', '继电器模块', + 'PLC-RPT-24DC/21', NULL, '单台数量:3; 物料等级:B; 存储条件:温度-40°C至85°C,湿度10%至95%RH(无凝露); 验收准则:检验', + @p_wh_004, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010012', '直通式接线端子', + 'PT1,5/S-QUATTRO', NULL, '单台数量:8; 物料等级:B; 存储条件:温度-5°C至70°C,湿度30%至70%RH(无凝露); 验收准则:检验', + @p_wh_004, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010013', '接地端子', + 'PT2,5-QUATTRO-PE', NULL, '单台数量:2; 物料等级:B; 存储条件:温度-5°C至70°C,湿度30%至70%RH(无凝露); 验收准则:检验', + @p_wh_004, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010014', '微型隔膜气泵及固定架', + 'KVP04-1.1-24', NULL, '单台数量:2; 物料等级:B; 存储条件:温度-10℃至55℃;湿度<85%RH(无冷凝水); 验收准则:检验', + @p_wh_005, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010015', '微型电磁隔离阀', + 'FV17T24-59-4E-3', NULL, '单台数量:4; 物料等级:B; 存储条件:温度-10℃至55℃;湿度<85%RH(无冷凝水); 验收准则:检验', + @p_wh_006, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010017', '保险丝管', + 'T5AH250VP', NULL, '单台数量:2; 物料等级:B; 存储条件:温度-20°C至60°C,湿度10%至95%RH; 验收准则:检验; 备注:0215005.MXP +陶瓷保险管, 215系列, 5A, 250V 交流, 5×20mm, 熔断速度T', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010019', '电线组件', + 'V3203C+VAC13KS(配60227IEC53 3×1mm2)', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验; 备注:2m电源线, IEC C13转I 型中式插头, 10A,250V, 黑色6051.2032', + @p_wh_007, NULL, @c_wh_B01, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030001', '母座安装板', + 'RM-01-010101', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030002', '母座', + 'RM-01-01010201', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A020001', '母座压板', + 'RM-01-010104', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030003', '主体装配', + 'RM-01-0103', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030004', '导光板', + 'RM-01-010201', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A020002', '电气安装板', + 'RM-01-010401', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A020003', '机壳', + 'RM-01-01040201', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A020004', '机盖', + 'RM-01-01040202', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030005', '后壳装配', + 'RM-01-0105', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A020005', '安装座', + 'RM-01-010601', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030006', '胶塞', + 'RM-01-0107', NULL, '单台数量:6; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_009, NULL, @c_wh_A03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050001', '控制采集板', + 'RM-01-0109', NULL, '单台数量:1; 物料等级:B; 存储条件:温度0°C至40°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_011, NULL, @c_wh_A05, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050002', '弹针PCB板', + 'RM-01-0108', NULL, '单台数量:2; 物料等级:B; 存储条件:温度0°C至40°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_011, NULL, @c_wh_A05, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020001', '细气路管', + 'BFT045-1-2', NULL, '单台数量:170; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:一次性使用治疗头用量7厘米(TPE材质,需要清洗),主机用量170厘米; +内径1/16"外径1/8" +另一BOM单台数量:7; 备注:一次性使用治疗头用量7厘米(TPE材质,需要清洗),主机用量169厘米; +内径1/16"外径1/8"', + @p_wh_006, NULL, @c_wh_B02, @u_wh_cm, '厘米', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020002', '鸭嘴单向阀', + 'RZ-BV018PPS', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_012, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020003', 'T型三通接头', + 'T-024', NULL, '单台数量:6; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_012, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020005', '变径直通接头', + 'BI-024/032', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_012, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020040', '粗气路管', + 'BFT045-2-3', NULL, '单台数量:17; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:96402-16(16#)', + @p_wh_006, NULL, @c_wh_B02, @u_wh_cm, '厘米', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010023', 'USB集线器', + 'USB-HUB-3U-ETH', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验; 备注:去除涂层,自带线缆', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010024', '散热风扇', + 'MF60151V1-1000C-A99', NULL, '单台数量:2; 物料等级:C; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010025', 'LED灯带白色', + 'DC24V 8×8mm', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010026', '金属按钮', + 'HBGQ22F-11ET/ +J/S/220V/G', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验; 备注:接插件HB-T2/4/15CM两个常开脚和两个灯脚插线', + @p_wh_013, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010027', 'RJ45网线', + 'CAT5E-AA-0050', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验; 备注:黑色,超五类屏蔽网\\RJ45\\0.5米', + @p_wh_007, NULL, @c_wh_B01, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010028', '磁环', + 'TC5B RC16*28*8-M2', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010029', '电气导轨', + 'DIN35,L=100mm, +铝制', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010030', '电气导轨', + 'DIN35,L=300mm, +铝制', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020009', '宝塔接头', + 'M4×0.7 插3mm', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010031', '直流电源转无终端接头电源线', + '5521公头,0.3平方, +长度0.5米', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010032', '插拔式桥接件', + 'FBS2-5', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_004, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010033', '插拔式桥接件', + 'FBS 2-3,5 BU', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_004, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020002', '包装箱', + 'RM-01-0201', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020003', '包装箱底托', + 'RM-01-0202', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020004', '底部泡棉', + 'RM-01-0203', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020005', '侧面泡棉', + 'RM-01-0204', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020006', '前部泡棉', + 'RM-01-0205', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020007', '顶部泡棉', + 'RM-01-0206', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020008', '后部泡棉', + 'RM-01-0207', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020009', '包装箱上盖', + 'RM-01-0208', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020010', '打包带', + 'KT89120', NULL, '单台数量:15; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_E02, @u_wh_m, '米', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020011', '打包扣', + 'KT89121', NULL, '单台数量:10; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_E02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E030001', '标签亚银纸', + '100×80mm', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_015, NULL, @c_wh_E03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E030004', '接地标识', + '1×1cm', NULL, '单台数量:5; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_E03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E030005', '防推标识', + '4×4cm', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_E03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E040001', '说明书', + 'A4', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_015, NULL, @c_wh_E04, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010020', '接线公端子', + 'XH2.54', NULL, '单台数量:18; 物料等级:C; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:验收; 备注:HX25002RT', + @p_wh_016, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010021', '接线胶壳母侧2Pin', + 'XH2.54', NULL, '单台数量:9; 物料等级:C; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:验收; 备注:HX25002-2R', + @p_wh_016, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010022', '接线胶壳母侧4Pin', + 'VH3.96', NULL, '单台数量:1; 物料等级:C; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:验收; 备注:HX39600-4R', + @p_wh_016, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010034', '接线公端子', + 'VH3.96', NULL, '单台数量:4; 物料等级:C; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:验收; 备注:HX39600-RT', + @p_wh_016, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020017', '十字沉头螺钉', + 'M2×6', NULL, '单台数量:4; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T818-2000', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020015', '十字槽盘头螺钉', + 'M2×4', NULL, '单台数量:4; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T818-2000', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020019', '十字槽盘头螺钉', + 'M3×20', NULL, '单台数量:12; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T818-2000', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020024', '弹簧垫圈', + '2mm', NULL, '单台数量:4; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T93-1987', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020031', '隔离柱', + 'M3×5+4', NULL, '单台数量:4; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020033', '六角螺母', + 'M3', NULL, '单台数量:7; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T6170-2000', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020034', '外锯齿防松垫片(接地)', + 'M3', NULL, '单台数量:5; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020037', '十字槽小盘头螺钉', + 'M4×14', NULL, '单台数量:6; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T823-2000', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010035', 'IEC滤波插座', + 'DD12-41110-2111-1100', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-20°C至60°C,湿度10%至95%RH; 验收准则:检验; 备注:DD12.4121.111 +C14IEC滤波插座, 额定电压250 V 交流, 额定电流4A, 双保险丝座, 2极开关, 面板安装', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010036', '保险丝座', + '5×20mm, 10A', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-20°C至60°C,湿度10%至95%RH; 验收准则:检验; 备注:Fusedrawer 2 系列, 尺寸 5×20mm, 10A, 面板安装 +制造商编码:4301.1403', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010037', '磁环', + 'FS28.5*6.8*12', NULL, '单台数量:4; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010038', '磁环', + 'UF100', NULL, '单台数量:3; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_007, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020038', '扎带固定座', + '20*20mm,带背胶, +白色', NULL, '单台数量:3; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020041', '节流阀', + '4*2.5mm', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010039', 'USB扬声器', + 'JP200-U', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_018, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010040', '触摸屏显示器', + 'YL-GZYW01Q156TC-V4', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-20°C至60°C,湿度10%至95%RH(最高湿球温度38.7℃); 验收准则:检验', + @p_wh_019, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010041', '中央处理器模组', + '6ES7 214-1AH50-0XB0', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-40°C至70°C,湿度10%至95%RH (无冷凝); 验收准则:检验; 备注:CPU 1214C', + @p_wh_020, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010042', '模拟输入模组', + '6ES7 231-4HF50-0XB0', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-40°C至70°C,湿度10%至95%RH (无冷凝); 验收准则:检验; 备注:ANALOG', + @p_wh_020, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010043', '数字输入/输出模组', + '6ES7 223-7AF50-0XB0', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-40°C至70°C,湿度10%至95%RH (无冷凝); 验收准则:检验; 备注:5V DC', + @p_wh_020, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010044', '模拟输入模组', + '6ES7 231-5PB50-0XB0', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-40°C至70°C,湿度10%至95%RH (无冷凝); 验收准则:检验; 备注:RTD', + @p_wh_020, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050047', '集成线束1#', + '', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_021, NULL, @c_wh_A05, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050048', '集成线束2#', + '', NULL, '单台数量:1; 物料等级:B; 存储条件:温度-25°C至70°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_021, NULL, @c_wh_A05, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020042', '十字槽盘头组合螺钉', + 'M3×6', NULL, '单台数量:16; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:GB/T 9074.4 +材质: +碳钢蓝白锌', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020043', '十字槽盘头组合螺钉', + 'M3×8', NULL, '单台数量:3; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020044', '十字槽盘头组合螺钉', + 'M3×12', NULL, '单台数量:16; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020046', '十字槽盘头组合螺钉', + 'M4×8', NULL, '单台数量:18; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020047', '十字槽盘头组合螺钉', + 'M4×10', NULL, '单台数量:7; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020048', '内六角半圆头组合螺钉', + 'M4×8', NULL, '单台数量:8; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B010045', '终端固定件', + 'E/UK', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_004, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B030002', '低强度螺纹胶', + '乐泰222,容量50ml', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:生产使用前后进行称重 +并记录重量', + @p_wh_022, NULL, @c_wh_B03, @u_wh_ml, '毫升', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B030003', '硅橡胶', + '706', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:生产使用前后进行称重 +并记录重量', + @p_wh_007, NULL, @c_wh_B03, @u_wh_g, '克', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020012', '扎带', + '黑色扎带(实际宽度2.5)3*120MM', NULL, '单台数量:150; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_B02, @u_wh_gen, '根', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'D020001', '毛刷针头', + '3mm,扁口,14-32G', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:10个治疗头损耗1个毛刷', + @p_wh_023, NULL, @c_wh_D02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'D020002', '特氟龙针头', + '无扁痕25G半寸', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:100个治疗头损耗1个特氟龙针头', + NULL, NULL, @c_wh_D02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'D020003', '胶筒', + '10ml +30ml', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:500个治疗头损耗1个胶筒', + NULL, NULL, @c_wh_D02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'D020004', '胶筒适配器', + '10ml +30ml', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收; 备注:500个治疗头损耗1个胶筒适配器', + NULL, NULL, @c_wh_D02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B030005', '液体生胶带', + '50ml', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:生产使用前后进行称重 +并记录重量', + @p_wh_022, NULL, @c_wh_B03, @u_wh_ml, '毫升', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'D020006', '铝箔', + '21.7mm*11.3mm', NULL, '单台数量:20; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + NULL, NULL, @c_wh_D02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050082', 'PI膜', + 'T-01-0111', NULL, '单台数量:1; 物料等级:A; 存储条件:温度0°C至40°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_024, NULL, @c_wh_A05, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050083', '线缆', + 'T-01-0112', NULL, '单台数量:1; 物料等级:B; 存储条件:温度0°C至40°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_021, NULL, @c_wh_A05, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A050084', 'pogopin板', + 'T-01-0113', NULL, '单台数量:1; 物料等级:B; 存储条件:温度0°C至40°C,湿度10%至95%RH; 验收准则:检验', + @p_wh_011, NULL, @c_wh_A05, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020004', 'T型三通接头', + 'T-016', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(聚丙烯PP)', + @p_wh_012, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030007', '治疗头气路接口', + 'T-01-0102', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(聚碳酸酯)', + @p_wh_025, NULL, @c_wh_A03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030008', '插头外壳', + 'T-01-0103', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(聚碳酸酯)', + @p_wh_025, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030009', '可充气气囊', + 'T-01-0104', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(硅胶包裹塑料)', + @p_wh_026, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030010', '眼睑加热器上外壳', + 'T-01-0105', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(聚碳酸酯)', + @p_wh_025, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030011', '眼睑加热器下外壳', + 'T-01-0106', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(聚碳酸酯)', + @p_wh_025, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'A030012', '眼睑加热器外壳', + 'T-01-0107', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(聚碳酸酯)', + @p_wh_025, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020039', '密封圈', + '外径6.5*1.9', NULL, '单台数量:2; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洗(硅胶)', + @p_wh_007, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020013', '圆形隔热层', + 'T-01-0108', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洁(铝箔)', + @p_wh_027, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020010', '异形隔热层', + 'T-01-0109', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洁(铝箔)', + @p_wh_027, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B020014', '限位层', + 'T-01-0110', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:清洁(二氧化硅)', + @p_wh_028, NULL, @c_wh_B02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'B030001', '治疗头外壳胶水', + '乐泰4311 UV胶水', NULL, '单台数量:0.4; 物料等级:B; 存储条件:温度2°C至8°C,冷藏储存; 验收准则:检验', + @p_wh_022, NULL, @c_wh_B03, @u_wh_g, '克', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E010001', '空白包装袋', + '288×198mm 1059B/ +LF-3070A', NULL, '单台数量:1; 物料等级:B; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:洁净物料', + @p_wh_030, NULL, @c_wh_E01, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020001', '治疗头纸包装箱', + 'T-01-04', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验', + @p_wh_014, NULL, @c_wh_E02, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E030002', '标签PET纸', + '120×100mm', NULL, '单台数量:2; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_015, NULL, @c_wh_E03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E030003', '合格证PET纸', + '100×80mm', NULL, '单台数量:3; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_015, NULL, @c_wh_E03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E030007', '辐照灭菌标签', + '25kGy', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:验收', + @p_wh_007, NULL, @c_wh_E03, @u_wh_ge, '个', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'E020012', '灭菌包装', + 'T-01-05', NULL, '单台数量:1; 物料等级:C; 存储条件:存放于室内,湿度≤95%RH; 验收准则:检验; 备注:1个灭菌包装可以装6个治疗头纸包装箱', + @p_wh_014, NULL, @c_wh_E02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:45:24', '2026-09-11 07:45:24'), + (@org_wh, 'F010006', '主机外壳组件', + 'XWRM-02', '外协', NULL, + NULL, NULL, @c_wh_F01, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:44:59', '2026-09-18 05:46:15'), + (@org_wh, 'F010007', '主机外壳组件', + 'XWRM-03', '外协', NULL, + NULL, NULL, @c_wh_F01, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:44:59', '2026-09-18 05:45:31'), + (@org_wh, 'A030013', '治疗头上外壳', + '', '外协', NULL, + NULL, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'A030014', '治疗头下外壳', + '', '外协', NULL, + NULL, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'A030015', '治疗头气囊', + '', '外协', NULL, + NULL, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'A030016', '治疗头插头外壳', + '', '外协', NULL, + NULL, NULL, @c_wh_A03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'F010085', '治疗头线缆组件(二代)', + '', '外协', NULL, + NULL, NULL, @c_wh_F01, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:44:59', '2026-09-23 15:25:12'), + (@org_wh, 'A050086', '治疗头线缆', + '', '外协', NULL, + NULL, NULL, @c_wh_A05, @u_wh_cm, '厘米', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 08:04:03'), + (@org_wh, 'B010046', '电源板', + '', '外协', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-18 06:50:07'), + (@org_wh, 'F010047', '主控板', + '', '外协', NULL, + NULL, NULL, @c_wh_F01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-18 05:46:40'), + (@org_wh, 'B010048', '触摸屏10.1寸', + '10.1寸', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-10-10 11:57:41'), + (@org_wh, 'B010049', '扬声器', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010050', '风扇', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010051', 'USB接口板', + '', '外协', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010052', '按键板', + '', '外协', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010053', '环形灯', + '', '外协', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010054', '电磁阀', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010055', '比例阀', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'F010056', '硬板PI膜(芯片)', + '', '自制', NULL, + NULL, NULL, @c_wh_F01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-23 14:59:35'), + (@org_wh, 'B010057', '计数芯片', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010058', '金手指插座', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010059', '触摸屏8寸', + '8寸', '外购', 'https://item.taobao.com/item.htm?from=cart&id=749116190950&mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU&skuId=5940217905947&spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM&upStre', + NULL, NULL, @c_wh_B01, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-28 08:43:20'), + (@org_wh, 'F010049', '气路组件', + '', '自制', NULL, + NULL, NULL, @c_wh_F01, @u_wh_tao, '套', + 'active', 1, '2026-09-11 07:44:59', '2026-09-18 06:47:57'), + (@org_wh, 'B020050', '航插(母座)', + '', '外购', NULL, + NULL, NULL, @c_wh_B02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B020051', '航插(公头)', + '', '外购', NULL, + NULL, NULL, @c_wh_B02, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B030006', '隔热层', + '', '外购', NULL, + NULL, NULL, @c_wh_B03, @u_wh_jian, '件', + 'active', 1, '2026-09-11 07:44:59', '2026-09-11 07:44:59'), + (@org_wh, 'B010060', '电磁阀(常闭)', + 'D379-1H', NULL, NULL, + NULL, @p_wh_031, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010061', '电磁阀(常开)', + 'D389-1H', NULL, NULL, + NULL, @p_wh_031, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010062', '电磁阀阀岛', + '395-02F', NULL, NULL, + NULL, @p_wh_031, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010063', '气电混装插座', + 'SZCNT02-2PZG1+8H-GG', NULL, NULL, + NULL, @p_wh_032, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010064', '气电混装插头', + 'SZCNT02-2HTG1+8H-G9G', NULL, NULL, + NULL, @p_wh_032, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010065', '气电混装插头', + 'SZCNT07-TGG-2B-10+1HC920', NULL, NULL, + NULL, @p_wh_032, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010066', '气电混装插座', + 'SZCNT07-ZGG-2B-10+1HC', NULL, NULL, + NULL, @p_wh_032, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-15 07:43:36', '2026-09-15 07:43:36'), + (@org_wh, 'B010067', '香橙派CM4底板', + '2G+32G', NULL, NULL, + @p_wh_033, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-17 10:28:02', '2026-10-13 07:56:37'), + (@org_wh, 'B010068', '香橙派CM4核心板', + '2G+32G', NULL, NULL, + @p_wh_033, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-17 10:28:02', '2026-10-13 07:56:31'), + (@org_wh, 'B010069', '功率放大板', + '3.3V高速8路NMOS', NULL, NULL, + @p_wh_034, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-17 10:28:02', '2026-09-17 11:18:58'), + (@org_wh, 'B010070', '功率放大板', + '3.3V低速8路NMOS', NULL, NULL, + @p_wh_034, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-17 10:28:02', '2026-09-17 10:28:02'), + (@org_wh, 'B020052', '微型宝塔接头', + 'PC-6-M5', NULL, NULL, + NULL, NULL, @c_wh_B02, NULL, '', + 'active', 1, '2026-09-18 03:26:33', '2026-09-18 03:26:33'), + (@org_wh, 'F020001', '二代睑板腺治疗仪主机(铂金版)', + 'XWRM-02', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_tai, '台', + 'active', 1, '2026-09-18 06:41:00', '2026-09-18 06:41:00'), + (@org_wh, 'F020002', '二代睑板腺治疗仪主机(精英版)', + 'XWRM-03', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_tai, '台', + 'active', 1, '2026-09-18 06:41:00', '2026-09-18 06:41:00'), + (@org_wh, 'F020003', '一次性使用治疗头', + 'XWT-02', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_ge, '个', + 'active', 1, '2026-09-18 06:41:00', '2026-09-18 06:41:00'), + (@org_wh, 'F020004', '一次性使用治疗头', + 'XWT-03', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_ge, '个', + 'active', 1, '2026-09-18 06:41:00', '2026-09-18 06:41:00'), + (@org_wh, 'F020005', '治疗头线缆', + 'XWL-02', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_gen, '根', + 'active', 1, '2026-09-18 06:41:00', '2026-09-18 06:41:00'), + (@org_wh, 'F020006', '治疗头线缆', + 'XWL-03', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_gen, '根', + 'active', 1, '2026-09-18 06:41:00', '2026-09-18 06:41:00'), + (@org_wh, 'F020007', '一次性使用治疗头线缆', + 'XWT-02', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_jian, '件', + 'active', 1, '2026-09-23 14:38:04', '2026-09-23 14:38:04'), + (@org_wh, 'F020008', '一次性使用治疗头', + 'XWT-03', '自制', NULL, + NULL, NULL, @c_wh_F02, @u_wh_jian, '件', + 'active', 1, '2026-09-23 14:38:04', '2026-09-23 14:38:04'), + (@org_wh, 'B030007', '铝箔', + '', '外购', NULL, + NULL, NULL, @c_wh_B03, @u_wh_ge, '个', + 'active', 1, '2026-09-23 14:46:32', '2026-09-23 14:46:32'), + (@org_wh, 'B010071', '硬板', + '', NULL, NULL, + NULL, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-23 14:48:44', '2026-09-23 14:48:44'), + (@org_wh, 'B010072', 'PI膜(芯片)', + '', NULL, NULL, + NULL, NULL, @c_wh_B01, @u_wh_ge, '个', + 'active', 1, '2026-09-23 14:48:44', '2026-09-23 15:01:47'), + (@org_wh, 'F010001', '硬板PI膜(电阻)', + '', '自制', NULL, + NULL, NULL, @c_wh_F01, NULL, '', + 'active', 1, '2026-09-23 15:00:17', '2026-09-23 15:00:17'), + (@org_wh, 'B010073', 'PI膜(电阻)', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-23 15:02:52', '2026-09-23 15:02:52'), + (@org_wh, 'A050087', '线缆', + '', NULL, NULL, + NULL, NULL, @c_wh_A05, @u_wh_gen, '根', + 'active', 1, '2026-09-23 15:13:12', '2026-09-23 15:13:12'), + (@org_wh, 'B010074', '线缆插头', + '', NULL, NULL, + NULL, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-23 15:13:12', '2026-09-23 15:13:12'), + (@org_wh, 'B010075', '金手指PCB板', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-09-23 15:16:30', '2026-09-23 15:16:30'), + (@org_wh, 'A030017', '金手指插头外壳', + '', '外协', NULL, + NULL, NULL, @c_wh_A03, NULL, '', + 'active', 1, '2026-09-23 15:18:45', '2026-09-23 15:18:45'), + (@org_wh, 'A030018', '气路变径头', + '', '外协', NULL, + NULL, NULL, @c_wh_A03, NULL, '', + 'active', 1, '2026-09-23 15:20:05', '2026-09-23 15:20:05'), + (@org_wh, 'F010002', '治疗头线缆组件(一代)', + '', '外协', NULL, + NULL, NULL, @c_wh_F01, NULL, '', + 'active', 1, '2026-09-23 15:26:31', '2026-09-23 15:28:10'), + (@org_wh, 'B010076', '触摸屏8寸', + '8寸', NULL, 'https://item.taobao.com/item.htm?from=cart&id=749116190950&mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU&skuId=5940217905947&spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM&upStre', + NULL, NULL, @c_wh_B01, NULL, '', + 'obsolete', 1, '2026-09-28 06:17:01', '2026-09-28 06:47:57'), + (@org_wh, 'B010077', '香橙派开发板Pi 5', + 'Orange Pi 5; 4G', NULL, 'https://item.taobao.com/item.htm?from=cart&id=694426579648&isabs=detail&mi_id=0000Yq1EqNjBiWluUgqbKkRAsDDsHWyfCslQH1T9MsFF1Sg&spm=a1z0d.6639537%2F202410.item.d694426579648.34747484e3AbaM', + NULL, NULL, @c_wh_B01, @u_wh_kuai, '块', + 'active', 1, '2026-09-28 06:17:01', '2026-09-28 06:18:49'), + (@org_wh, 'B010078', 'STM32F103VET6开发板', + 'STM32F103VET6', '外购', '【淘宝】7天无理由退货 https://e.tb.cn/h.8EJfDNNHtTAGNt3?tk=D8tJTndQpoE MF287 「STM32F103VET6系统板 核心板 开发板 STM32系统板 工业级 小尺寸」 点击链接直接打开 或者 淘宝搜索直接打开', + NULL, NULL, @c_wh_B01, @u_wh_kuai, '块', + 'active', 1, '2026-09-29 06:24:26', '2026-09-29 06:24:26'), + (@org_wh, 'B010079', '香橙派Pi5', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, NULL, '', + 'obsolete', 1, '2026-10-13 07:09:15', '2026-10-13 07:11:26'), + (@org_wh, 'B010080', '香橙派开发板Pi 3B', + '', '外购', NULL, + NULL, NULL, @c_wh_B01, NULL, '', + 'active', 1, '2026-10-13 07:09:15', '2026-10-13 07:11:13'), + (@org_wh, 'B020053', '硅胶按键', + '', NULL, NULL, + NULL, NULL, @c_wh_B02, @u_wh_jian, '件', + 'active', 1, '2026-10-13 07:26:02', '2026-10-13 07:26:02'), + (@org_wh, 'F010003', '按键模组', + '', NULL, NULL, + NULL, NULL, @c_wh_F01, @u_wh_jian, '件', + 'active', 1, '2026-10-13 07:27:22', '2026-10-13 07:27:22') +AS new +ON DUPLICATE KEY UPDATE + name = new.name, spec = new.spec, source = new.source, remark = new.remark, + supplier_id = new.supplier_id, manufacturer_id = new.manufacturer_id, + category_id = new.category_id, base_unit_id = new.base_unit_id, unit = new.unit, + status = new.status, updated_at = new.updated_at; + +-- ---------- 变更日志 → material_logs ---------- +-- 源表没有操作类型,统一记作 update;修改原因进 description。 +-- 不导用户账号,operator_id 留空,operator 存源里的用户名。 +-- ===== 北京:15 条 ===== +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机","remark":"","source":"外购","spec":"ESF32016H24-S001","supplier":"上海鸣志","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', + 'xianwei', '原型号不带编码器现在更换为带编码器的', '2026-09-15 09:00:32' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-15 09:00:32' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', + 'xianwei', '以电机使用功能命名', '2026-09-17 06:59:33' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 06:59:33' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机-俯仰-进给","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', + 'xianwei', '以电机功能进行命名', '2026-09-17 07:00:16' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:00:16' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"博通","material_code":"B010202","material_name":"博通多圈绝对值编码器","remark":"","source":"外购","spec":"AS20-M42M-B11","supplier":"","type_code":"B01","unit":"个"}', '{"drawing_no":"","manufacturer":"博通","material_code":"B010202","material_name":"进给自由度-博通多圈绝对值编码器","remark":"","source":"外购","spec":"AS20-M42M-B11","supplier":"","type_code":"B01","unit":"个"}', + 'xianwei', '修改名称', '2026-09-17 07:01:13' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010202' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:01:13' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"鑫拓智能","material_code":"A020201","material_name":"鑫拓智能谐波减速器","remark":"","source":"外购","spec":"HD Mini-05","supplier":"鑫拓智能","type_code":"A02","unit":"个"}', '{"drawing_no":"","manufacturer":"鑫拓智能","material_code":"A020201","material_name":"俯仰关节-鑫拓智能谐波减速器","remark":"","source":"外购","spec":"HD Mini-05","supplier":"鑫拓智能","type_code":"A02","unit":"个"}', + 'xianwei', '修改名称', '2026-09-17 07:01:29' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A020201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:01:29' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"鑫拓智能","material_code":"A020201","material_name":"俯仰关节-鑫拓智能谐波减速器","remark":"","source":"外购","spec":"HD Mini-05","supplier":"鑫拓智能","type_code":"A02","unit":"个"}', '{"drawing_no":"","manufacturer":"鑫拓智能","material_code":"A020201","material_name":"RCM俯仰关节-鑫拓智能谐波减速器","remark":"","source":"外购","spec":"HD Mini-05","supplier":"鑫拓智能","type_code":"A02","unit":"个"}', + 'xianwei', '修改名称', '2026-09-17 07:01:54' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A020201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:01:54' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"博通","material_code":"B010202","material_name":"进给自由度-博通多圈绝对值编码器","remark":"","source":"外购","spec":"AS20-M42M-B11","supplier":"","type_code":"B01","unit":"个"}', '{"drawing_no":"","manufacturer":"博通","material_code":"B010202","material_name":"RCM进给自由度-博通多圈绝对值编码器","remark":"","source":"外购","spec":"AS20-M42M-B11","supplier":"","type_code":"B01","unit":"个"}', + 'xianwei', '修改名称', '2026-09-17 07:02:08' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010202' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:02:08' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"鸣志电机-俯仰-进给","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"RCM俯仰-进给-鸣志电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', + 'xianwei', '修改名称', '2026-09-17 07:02:31' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:02:31' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"鑫拓智能","material_code":"A020201","material_name":"RCM俯仰关节-鑫拓智能谐波减速器","remark":"","source":"外购","spec":"HD Mini-05","supplier":"鑫拓智能","type_code":"A02","unit":"个"}', '{"drawing_no":"","manufacturer":"鑫拓智能","material_code":"A020201","material_name":"RCM俯仰关节-谐波减速器","remark":"","source":"外购","spec":"HD Mini-05","supplier":"鑫拓智能","type_code":"A02","unit":"个"}', + 'xianwei', '修改名成', '2026-09-17 07:04:23' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A020201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:04:23' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"博通","material_code":"B010202","material_name":"RCM进给自由度-博通多圈绝对值编码器","remark":"","source":"外购","spec":"AS20-M42M-B11","supplier":"","type_code":"B01","unit":"个"}', '{"drawing_no":"","manufacturer":"博通","material_code":"B010202","material_name":"RCM进给自由度-多圈绝对值编码器","remark":"","source":"外购","spec":"AS20-M42M-B11","supplier":"","type_code":"B01","unit":"个"}', + 'xianwei', '修改名称', '2026-09-17 07:04:39' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010202' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:04:39' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"RCM俯仰-进给-鸣志电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"上海鸣志","material_code":"B010201","material_name":"RCM俯仰-进给-电机","remark":"","source":"外购","spec":"ESF32016H48-S003+I32-2052","supplier":"上海鸣志","type_code":"B01","unit":""}', + 'xianwei', '修改名称', '2026-09-17 07:05:29' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'B010201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 07:05:29' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A040203","material_name":"MX26-0820-1647","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"A040203","material_name":"旋转件1","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":""}', + 'luomabiao', '命名统一', '2026-09-28 06:23:40' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A040203' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:23:40' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A040202","material_name":"MX26-0820-1619","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"A040202","material_name":"旋转件2-2","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":""}', + 'luomabiao', '命名统一', '2026-09-28 06:24:15' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A040202' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:24:15' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A040201","material_name":"MX26-0820-1618","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"A040201","material_name":"旋转件2-1","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":""}', + 'luomabiao', '命名统一', '2026-09-28 06:24:29' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A040201' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:24:29' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A040211","material_name":"LJJ镊子从端-005","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":"Pcs"}', '{"drawing_no":"","manufacturer":"","material_code":"A040211","material_name":"LJJ镊子从端-006","remark":"","source":"外协","spec":"","supplier":"","type_code":"A04","unit":"Pcs"}', + 'luomabiao', '名称重复', '2026-10-10 07:54:57' +FROM materials m +WHERE m.organization_id = @org_bj + AND m.material_code = 'A040211' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-10 07:54:57' + ); + +-- ===== 武汉:30 条 ===== +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A050202","material_name":"治疗头线缆","remark":"","source":"外协","spec":"","supplier":"","type_code":"A05","unit":"米"}', '{"drawing_no":"","manufacturer":"","material_code":"A050202","material_name":"治疗头线缆","remark":"","source":"外协","spec":"","supplier":"","type_code":"A05","unit":"厘米"}', + 'xiongsheng', '修改单位', '2026-09-11 08:04:03' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'A050086' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-11 08:04:03' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010069","material_name":"功率放大板","remark":"","source":"","spec":"3.3V高速8路PMOS","supplier":"海葵星","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010069","material_name":"功率放大板","remark":"","source":"","spec":"3.3V高速8路NMOS","supplier":"海葵星","type_code":"B01","unit":""}', + 'xianwei', '参数填写错误', '2026-09-17 11:18:58' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010069' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-17 11:18:58' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A020007","material_name":"主机外壳组件","remark":"","source":"外协","spec":"XWRM-03","supplier":"","type_code":"A02","unit":"套"}', '{"drawing_no":"","manufacturer":"","material_code":"F010007","material_name":"主机外壳组件","remark":"","source":"外协","spec":"XWRM-03","supplier":"","type_code":"F01","unit":"套"}', + 'xianwei', '外壳组件由物料改为半成品', '2026-09-18 05:45:31' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010007' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-18 05:45:31' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A020006","material_name":"主机外壳组件","remark":"","source":"外协","spec":"XWRM-02","supplier":"","type_code":"A02","unit":"套"}', '{"drawing_no":"","manufacturer":"","material_code":"F010006","material_name":"主机外壳组件","remark":"","source":"外协","spec":"XWRM-02","supplier":"","type_code":"F01","unit":"套"}', + 'xianwei', '主机外壳组件由物料改为半成品', '2026-09-18 05:46:15' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010006' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-18 05:46:15' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010047","material_name":"主控板","remark":"","source":"外协","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"F010047","material_name":"主控板","remark":"","source":"外协","spec":"","supplier":"","type_code":"F01","unit":"件"}', + 'xianwei', '主控板由物料改为半成品', '2026-09-18 05:46:40' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010047' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-18 05:46:40' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A050085","material_name":"治疗头线缆组件","remark":"","source":"外协","spec":"","supplier":"","type_code":"A05","unit":"套"}', '{"drawing_no":"","manufacturer":"","material_code":"F010085","material_name":"治疗头线缆组件","remark":"","source":"外协","spec":"","supplier":"","type_code":"F01","unit":"套"}', + 'xianwei', '治疗头线缆组件由物料改为半成品', '2026-09-18 05:51:12' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010085' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-18 05:51:12' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B020049","material_name":"气路组件","remark":"","source":"自制","spec":"","supplier":"","type_code":"B02","unit":"套"}', '{"drawing_no":"","manufacturer":"","material_code":"F010049","material_name":"气路组件","remark":"","source":"自制","spec":"","supplier":"","type_code":"F01","unit":"套"}', + 'xianwei', '气路组件由物料改为半成品', '2026-09-18 06:47:57' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010049' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-18 06:47:57' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010046","material_name":"通用电源板","remark":"","source":"外协","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010046","material_name":"电源板","remark":"","source":"外协","spec":"","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '通用电源板改为电源板', '2026-09-18 06:50:07' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010046' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-18 06:50:07' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010056","material_name":"硬板PI膜","remark":"","source":"外协","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"F010056","material_name":"硬板PI膜","remark":"","source":"自制","spec":"","supplier":"","type_code":"F01","unit":"件"}', + 'xianwei', '改为中间品', '2026-09-23 14:43:45' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010056' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-23 14:43:45' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"F010056","material_name":"硬板PI膜","remark":"","source":"自制","spec":"","supplier":"","type_code":"F01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"F010056","material_name":"硬板PI膜(芯片)","remark":"","source":"自制","spec":"","supplier":"","type_code":"F01","unit":"件"}', + 'xianwei', '芯片', '2026-09-23 14:59:35' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010056' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-23 14:59:35' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010072","material_name":"PI膜","remark":"","source":"","spec":"","supplier":"","type_code":"B01","unit":"个"}', '{"drawing_no":"","manufacturer":"","material_code":"B010072","material_name":"PI膜(芯片)","remark":"","source":"","spec":"","supplier":"","type_code":"B01","unit":"个"}', + 'xianwei', '芯片', '2026-09-23 15:01:47' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010072' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-23 15:01:47' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"F010085","material_name":"治疗头线缆组件","remark":"","source":"外协","spec":"","supplier":"","type_code":"F01","unit":"套"}', '{"drawing_no":"","manufacturer":"","material_code":"F010085","material_name":"治疗头线缆组件(二代)","remark":"","source":"外协","spec":"","supplier":"","type_code":"F01","unit":"套"}', + 'xianwei', '二代', '2026-09-23 15:25:12' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010085' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-23 15:25:12' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"A010001","material_name":"治疗头线缆组件(一代)","remark":"","source":"外协","spec":"","supplier":"","type_code":"A01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"F010002","material_name":"治疗头线缆组件(一代)","remark":"","source":"外协","spec":"","supplier":"","type_code":"F01","unit":""}', + 'xianwei', '半成品', '2026-09-23 15:28:10' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'F010002' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-23 15:28:10' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010048","material_name":"触摸屏","remark":"","source":"外购","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010048","material_name":"触摸屏10.1寸","remark":"","source":"外购","spec":"10.1寸","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '添加规格', '2026-09-28 06:14:11' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010048' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:14:11' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"数码屏","remark":"","source":"外购","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"10寸数码屏","remark":"","source":"外购","spec":"","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '10寸', '2026-09-28 06:15:03' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010059' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:15:03' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"10寸数码屏","remark":"","source":"外购","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"8寸显示屏","remark":"","source":"外购","spec":"","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '8寸', '2026-09-28 06:15:42' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010059' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:15:42' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010077","material_name":"香橙派开发板Pi 5","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=694426579648\\u0026isabs=detail\\u0026mi_id=0000Yq1EqNjBiWluUgqbKkRAsDDsHWyfCslQH1T9MsFF1Sg\\u0026spm=a1z0d.6639537%2F202410.item.d694426579648.34747484e3AbaM","source":"","spec":"Orange Pi 5","supplier":"","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010077","material_name":"香橙派开发板Pi 5","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=694426579648\\u0026isabs=detail\\u0026mi_id=0000Yq1EqNjBiWluUgqbKkRAsDDsHWyfCslQH1T9MsFF1Sg\\u0026spm=a1z0d.6639537%2F202410.item.d694426579648.34747484e3AbaM","source":"","spec":"Orange Pi 5; 4G","supplier":"","type_code":"B01","unit":"块"}', + 'xianwei', '添加4G参数', '2026-09-28 06:18:49' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010077' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:18:49' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"8寸显示屏","remark":"","source":"外购","spec":"","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"触摸屏8寸","remark":"","source":"外购","spec":"8寸","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '统一屏幕命名风格', '2026-09-28 06:25:51' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010059' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:25:51' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"触摸屏8寸","remark":"","source":"外购","spec":"8寸","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"触摸屏8寸","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=749116190950\\u0026mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU\\u0026skuId=5940217905947\\u0026spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM\\u0026upStreamPrice=28800\\u0026xxc=shop","source":"外购","spec":"8寸","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '增加采购网址', '2026-09-28 06:28:27' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010059' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:28:27' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010076","material_name":"触摸屏8寸","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=749116190950\\u0026mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU\\u0026skuId=5940217905947\\u0026spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM\\u0026upStreamPrice=28800\\u0026xxc=shop","source":"","spec":"8寸","status":"active","supplier":"","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010076","material_name":"触摸屏8寸","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=749116190950\\u0026mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU\\u0026skuId=5940217905947\\u0026spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM\\u0026upStreamPrice=28800\\u0026xxc=shop","source":"","spec":"8寸","status":"voided","supplier":"","type_code":"B01","unit":""}', + 'xianwei', '与B010059重复', '2026-09-28 06:47:57' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010076' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 06:47:57' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"触摸屏8寸","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=749116190950\\u0026mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU\\u0026skuId=5940217905947\\u0026spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM\\u0026upStreamPrice=28800\\u0026xxc=shop","source":"外购","spec":"8寸","status":"active","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010059","material_name":"触摸屏8寸","remark":"https://item.taobao.com/item.htm?from=cart\\u0026id=749116190950\\u0026mi_id=000086DKOQjDf9p_N94ymKsE2dWs-QKiH_b2Om7xRMRWkkU\\u0026skuId=5940217905947\\u0026spm=a1z0d.6639537%2F202410.item.d749116190950.34747484e3AbaM\\u0026upStreamPrice=28800\\u0026xxc=shop","source":"外购","spec":"8寸","status":"active","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '添加规格书', '2026-09-28 08:43:20' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010059' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 08:43:20' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010048","material_name":"触摸屏10.1寸","remark":"","source":"外购","spec":"10.1寸","status":"active","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010048","material_name":"触摸屏10.1寸","remark":"","source":"外购","spec":"10.1寸","status":"active","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '添加规格书', '2026-09-28 08:43:36' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010048' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-09-28 08:43:36' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010048","material_name":"触摸屏10.1寸","remark":"","source":"外购","spec":"10.1寸","status":"active","supplier":"","type_code":"B01","unit":"件"}', '{"drawing_no":"","manufacturer":"","material_code":"B010048","material_name":"触摸屏10.1寸","remark":"","source":"外购","spec":"10.1寸","status":"active","supplier":"","type_code":"B01","unit":"件"}', + 'xianwei', '更新文件', '2026-10-10 11:57:41' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010048' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-10 11:57:41' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010068","material_name":"香橙派CM4核心板","remark":"","source":"","spec":"2G+32G","status":"active","supplier":"香橙派","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010068","material_name":"香橙派CM4核心板","remark":"","source":"","spec":"2G+32G","status":"voided","supplier":"香橙派","type_code":"B01","unit":""}', + 'xianwei', '更换型号', '2026-10-13 07:04:57' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010068' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:04:57' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010067","material_name":"香橙派CM4底板","remark":"","source":"","spec":"2G+32G","status":"active","supplier":"香橙派","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010067","material_name":"香橙派CM4底板","remark":"","source":"","spec":"2G+32G","status":"voided","supplier":"香橙派","type_code":"B01","unit":""}', + 'xianwei', '型号变更', '2026-10-13 07:07:15' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010067' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:07:15' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010080","material_name":"香橙派Pi3B","remark":"","source":"外购","spec":"","status":"active","supplier":"","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010080","material_name":"香橙派Pi 3B","remark":"","source":"外购","spec":"","status":"active","supplier":"","type_code":"B01","unit":""}', + 'xianwei', '名称修改', '2026-10-13 07:10:59' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010080' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:10:59' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010080","material_name":"香橙派Pi 3B","remark":"","source":"外购","spec":"","status":"active","supplier":"","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010080","material_name":"香橙派开发板Pi 3B","remark":"","source":"外购","spec":"","status":"active","supplier":"","type_code":"B01","unit":""}', + 'xianwei', '名称修改', '2026-10-13 07:11:13' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010080' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:11:13' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010079","material_name":"香橙派Pi5","remark":"","source":"外购","spec":"","status":"active","supplier":"","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010079","material_name":"香橙派Pi5","remark":"","source":"外购","spec":"","status":"voided","supplier":"","type_code":"B01","unit":""}', + 'xianwei', '物料重复', '2026-10-13 07:11:26' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010079' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:11:26' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010068","material_name":"香橙派CM4核心板","remark":"","source":"","spec":"2G+32G","status":"voided","supplier":"香橙派","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010068","material_name":"香橙派CM4核心板","remark":"","source":"","spec":"2G+32G","status":"active","supplier":"香橙派","type_code":"B01","unit":""}', + 'xianwei', '恢复物料编码', '2026-10-13 07:56:31' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010068' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:56:31' + ); +INSERT INTO material_logs + (operation_type, material_id, operator_id, old_value, new_value, operator, description, created_at) +SELECT 'update', m.id, NULL, + '{"drawing_no":"","manufacturer":"","material_code":"B010067","material_name":"香橙派CM4底板","remark":"","source":"","spec":"2G+32G","status":"voided","supplier":"香橙派","type_code":"B01","unit":""}', '{"drawing_no":"","manufacturer":"","material_code":"B010067","material_name":"香橙派CM4底板","remark":"","source":"","spec":"2G+32G","status":"active","supplier":"香橙派","type_code":"B01","unit":""}', + 'xianwei', '恢复物料编码', '2026-10-13 07:56:37' +FROM materials m +WHERE m.organization_id = @org_wh + AND m.material_code = 'B010067' + AND NOT EXISTS ( + SELECT 1 FROM material_logs l + WHERE l.material_id = m.id AND l.operation_type = 'update' + AND l.created_at = '2026-10-13 07:56:37' + ); + +-- ---------- 编码规则 ---------- +-- 各分类下一个可用序号 = 已导入物料的最大序号 + 1。 +-- 不更新的话,用户新增物料会撞上已有编码。 +-- 北京 +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A01, 'A01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A02, 'A02', 4, 202, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 202); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A03, 'A03', 4, 203, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 203); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A04, 'A04', 4, 212, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 212); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A05, 'A05', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A06, 'A06', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_A07, 'A07', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B01, 'B01', 4, 203, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 203); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B02, 'B02', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B03, 'B03', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B04, 'B04', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B05, 'B05', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B06, 'B06', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_B07, 'B07', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_C01, 'C01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_C02, 'C02', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_C03, 'C03', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_D01, 'D01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_D02, 'D02', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_D03, 'D03', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_D04, 'D04', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_E01, 'E01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_E02, 'E02', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_F01, 'F01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_F02, 'F02', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_F03, 'F03', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_F04, 'F04', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_bj, @c_bj_F05, 'F05', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); + +-- 武汉 +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_A01, 'A01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_A02, 'A02', 4, 6, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 6); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_A03, 'A03', 4, 19, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 19); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_A04, 'A04', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_A05, 'A05', 4, 88, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 88); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_B01, 'B01', 4, 81, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 81); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_B02, 'B02', 4, 54, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 54); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_B03, 'B03', 4, 8, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 8); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_C01, 'C01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_D01, 'D01', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_D02, 'D02', 4, 7, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 7); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_E01, 'E01', 4, 2, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 2); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_E02, 'E02', 4, 13, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 13); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_E03, 'E03', 4, 8, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 8); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_E04, 'E04', 4, 2, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 2); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_E05, 'E05', 4, 1, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 1); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_F01, 'F01', 4, 86, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 86); +INSERT INTO code_rules (organization_id, category_id, prefix, sequence_length, next_sequence, status) +SELECT @org_wh, @c_wh_F02, 'F02', 4, 9, 'active' +ON DUPLICATE KEY UPDATE next_sequence = GREATEST(next_sequence, 9);