Ver código fonte

fix: 标准BOM物料引用保存改为存在性校验,兼容 legacy org 域物料

ValidateMaterialRefsAsync 原将物料 legacy 数值 org 域(如1000/8010)与标准BOM表单
SysOrg 雪花 id 域(如1329900200001)直接强比较,导致引用真实存在的物料保存被误拦截。
改为只校验父/子物料 Id 真实存在(父或子不存在仍拦截),对齐货源清单 srm 口径。

- 不再用 legacy org 域与 SysOrg 雪花 id 做强比较;
- 仍保留物料 Id 不存在时的拦截(父/子任一不存在→S01002);
- 不做公司/工厂隐藏、不做历史数据回填、不做 legacy↔SysOrg org 域映射治理。

chore: bump version server 1.0.232
YY968XX 13 horas atrás
pai
commit
2d7f603b02

+ 3 - 3
server/Admin.NET.Web.Entry/Admin.NET.Web.Entry.csproj

@@ -11,9 +11,9 @@
     <GenerateSatelliteAssembliesForCore>true</GenerateSatelliteAssembliesForCore>
     <Copyright>Admin.NET</Copyright>
     <Description>Admin.NET ͨ��Ȩ�޿���ƽ̨</Description>
-    <AssemblyVersion>1.0.231</AssemblyVersion>
-    <FileVersion>1.0.231</FileVersion>
-    <Version>1.0.231</Version>
+    <AssemblyVersion>1.0.232</AssemblyVersion>
+    <FileVersion>1.0.232</FileVersion>
+    <Version>1.0.232</Version>
   </PropertyGroup>
 
   <ItemGroup>

+ 10 - 7
server/Plugins/Admin.NET.Plugin.AiDOP/Controllers/S0/Manufacturing/AdoS0ProductStructuresController.cs

@@ -151,7 +151,7 @@ public class AdoS0ProductStructuresController : ControllerBase
         var err = AdoS0ProductStructureRules.ValidateUpsert(dto);
         if (err != null) return BadRequest(new { message = err });
 
-        var fkErr = await ValidateMaterialRefsAsync(dto.CompanyRefId, dto.FactoryRefId, dto.ParentMaterialId, dto.ComponentMaterialId);
+        var fkErr = await ValidateMaterialRefsAsync(dto.ParentMaterialId, dto.ComponentMaterialId);
         if (fkErr != null) return BadRequest(new { message = fkErr });
 
         var (parentItem, componentItem, itemErr) = await ResolveItemNumsAsync(dto.ParentMaterialId, dto.ComponentMaterialId);
@@ -186,7 +186,7 @@ public class AdoS0ProductStructuresController : ControllerBase
         var existing = await _masterRep.GetByIdAsync(id);
         if (existing == null) return NotFound();
 
-        var fkErr = await ValidateMaterialRefsAsync(dto.CompanyRefId, dto.FactoryRefId, dto.ParentMaterialId, dto.ComponentMaterialId);
+        var fkErr = await ValidateMaterialRefsAsync(dto.ParentMaterialId, dto.ComponentMaterialId);
         if (fkErr != null) return BadRequest(new { message = fkErr });
 
         var (parentItem, componentItem, itemErr) = await ResolveItemNumsAsync(dto.ParentMaterialId, dto.ComponentMaterialId);
@@ -317,12 +317,15 @@ public class AdoS0ProductStructuresController : ControllerBase
         return (parentItem, componentItem, null);
     }
 
-    private async Task<string?> ValidateMaterialRefsAsync(long companyRefId, long factoryRefId, long parentId, long componentId)
+    // 物料引用只校验 Id 真实存在:物料主数据用 legacy 数值 org 域(如 1000/8010),而标准 BOM 表单
+    // 公司/工厂来自 SysOrg 雪花 id(如 1329900200001),两域直接强比较恒不成立、会误拦截真实物料引用。
+    // 对齐货源清单 srm 的"引用真实存在即可保存"口径,不再比较物料 CompanyRefId/FactoryRefId。
+    private async Task<string?> ValidateMaterialRefsAsync(long parentId, long componentId)
     {
-        var count = await _materialRep.AsQueryable()
-            .Where(m => (m.Id == parentId || m.Id == componentId)
-                && m.CompanyRefId == companyRefId && m.FactoryRefId == factoryRefId)
+        var ids = parentId == componentId ? new[] { parentId } : new[] { parentId, componentId };
+        var existingCount = await _materialRep.AsQueryable()
+            .Where(m => ids.Contains(m.Id))
             .CountAsync();
-        return count == 2 ? null : "存在无效的物料主数据引用(公司/工厂或 Id 不匹配)";
+        return existingCount == ids.Length ? null : "存在无效的物料主数据引用(公司/工厂或 Id 不匹配)";
     }
 }