diff --git a/FactorySystemApi/Controllers/PackageController.cs b/FactorySystemApi/Controllers/PackageController.cs index 6423a12..53688d5 100644 --- a/FactorySystemApi/Controllers/PackageController.cs +++ b/FactorySystemApi/Controllers/PackageController.cs @@ -100,25 +100,37 @@ namespace FactorySystemApi.Controllers } else { - mainId = PackageBll.UpdatePackageData(inParam); - if (mainId > 0 && inParam.TryGetValue("FChild", out object childStr)) + // 20230422 新增逻辑 + // 包规存在则不允许添加包材 + string fcode = inParam["FCode"].ToString(); + TFS_PackageMain package = PackageBll.GetPackageByFCode(fcode); + + if (package != null) + { + mainId = -2; + } + else { - List childList = JsonConvert.DeserializeObject>(childStr.ToString()); - if (childList.Count > 0) + mainId = PackageBll.UpdatePackageData(inParam); + if (mainId > 0 && inParam.TryGetValue("FChild", out object childStr)) { - if (childList[0].FID <= 0) + List childList = JsonConvert.DeserializeObject>(childStr.ToString()); + if (childList.Count > 0) { - inParam.Remove("FID"); - inParam.Add("FID", mainId); - PackageBll.InsertChildData(inParam, childList); - } - //当都有子项代码的时候则完成 - if (childList.Find(s => string.IsNullOrEmpty(s.FCode)) == null) - { - PackageBll.TaskCompleted(inParam); + if (childList[0].FID <= 0) + { + inParam.Remove("FID"); + inParam.Add("FID", mainId); + PackageBll.InsertChildData(inParam, childList); + } + //当都有子项代码的时候则完成 + if (childList.Find(s => string.IsNullOrEmpty(s.FCode)) == null) + { + PackageBll.TaskCompleted(inParam); + } } } - } + } } apiResult.Data = mainId;