From 79525941a5ce0cfbc667c005a594cab6dd77c45b Mon Sep 17 00:00:00 2001 From: leo <10200039@qq.com> Date: Sat, 22 Apr 2023 16:47:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=85=E8=A7=84=E4=B8=8D=E8=83=BD=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PackageController.cs | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) 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;