diff --git a/FactorySystemApi/Controllers/FormulaController.cs b/FactorySystemApi/Controllers/FormulaController.cs index 37ba9ba..c419b7e 100644 --- a/FactorySystemApi/Controllers/FormulaController.cs +++ b/FactorySystemApi/Controllers/FormulaController.cs @@ -375,7 +375,7 @@ namespace FactorySystemApi.Controllers TFS_Formula formula = formulas[0]; OAService oAService = new OAService(); string bomListStr = ""; - + Dictionary bomResult = null; List specifList = new List() { new Specifications() }; specifList[0].SP = formula.FPlmCode; @@ -392,89 +392,316 @@ namespace FactorySystemApi.Controllers if (restResult != null && restResult.data != null) { List bomList = JsonConvert.DeserializeObject>(restResult.data.ToString()); - string materialCodes = ","; - string testCodes = ","; + + + + + //string materialCodes = ","; + //string testCodes = ","; if (bomList != null && bomList.Count > 0) { - List subBomList = bomList[0].Specifications; + bomResult = CheckBomMaterial(bomList, 0, new Random()); + + //List subBomList = bomList[0].Specifications; + + //if (subBomList != null && subBomList.Count > 0) + //{ + // foreach(BomModel bom in subBomList) + // { + // string bomType = bom.Type.ToLower(); // 转小写 + // if (bomType == "a" || bomType == "f") + // { + // bom.ABomType = "20"; + // } + // else if (bomType == "b" || bomType == "bb" || bomType == "i" || bomType == "iz") + // { + // bom.ABomType = "30"; + // } + // else + // { + // bom.ABomType = "40"; + // } + + // if ("40".Equals(bom.ABomType)) + // { + // bom.ASapCode = bom.SP_VALUE; + // materialCodes = materialCodes + bom.ASapCode + ","; + // } + // else + // { + // bom.ATestCode = bom.SP_VALUE; + // testCodes = testCodes + bom.ATestCode + ","; + // } + // } + + // List viewsByMaterialCodes = FormulaBll.GetViewByMaterialCodes(materialCodes); + // List viewsByTestCodes = FormulaBll.GetViewByTestCodes(testCodes); + + // foreach (BomModel bom in subBomList) + // { + // if ("40".Equals(bom.ABomType)) + // { + // if (viewsByMaterialCodes != null && viewsByMaterialCodes.Count > 0) + // { + // TFS_ViewMaterial view = viewsByMaterialCodes.Find(v => v.FBaseMaterialCode.Equals(bom.ASapCode)); + // if (view != null) + // { + // bom.AMaterialCode = view.FSaleOldMaterialCode; + // } + // } + // } + // else + // { + // if (viewsByTestCodes != null && viewsByTestCodes.Count > 0) + // { + // TFS_ViewMaterial view = viewsByTestCodes.Find(v => v.FBaseTestCode.Equals(bom.ATestCode)); + // if (view != null) + // { + // bom.AMaterialCode = view.FSaleOldMaterialCode; + // bom.ASapCode = view.FBaseMaterialCode; + // } + // } + // } + // } + + // int formulaApplyHistoryId = FormulaBll.AddFormulaApplyHistroy(formula, user.FName, user.FID); + + // resultObj.Add("applyHistoryId", formulaApplyHistoryId); + // resultObj.Add("bomList", bomList); + + // bomListStr = JsonConvert.SerializeObject(resultObj); + //} + } + } - if (subBomList != null && subBomList.Count > 0) - { - foreach(BomModel bom in subBomList) - { - string bomType = bom.Type.ToLower(); // 转小写 - if (bomType == "a" || bomType == "f") - { - bom.ABomType = "20"; - } - else if (bomType == "b" || bomType == "bb" || bomType == "i" || bomType == "iz") - { - bom.ABomType = "30"; - } - else - { - bom.ABomType = "40"; - } + apiResult.Data = bomResult; - if ("40".Equals(bom.ABomType)) - { - bom.ASapCode = bom.SP_VALUE; - materialCodes = materialCodes + bom.ASapCode + ","; - } - else - { - bom.ATestCode = bom.SP_VALUE; - testCodes = testCodes + bom.ATestCode + ","; - } - } + } + }, apiResult, Request); + } - List viewsByMaterialCodes = FormulaBll.GetViewByMaterialCodes(materialCodes); - List viewsByTestCodes = FormulaBll.GetViewByTestCodes(testCodes); - foreach (BomModel bom in subBomList) - { - if ("40".Equals(bom.ABomType)) - { - if (viewsByMaterialCodes != null && viewsByMaterialCodes.Count > 0) - { - TFS_ViewMaterial view = viewsByMaterialCodes.Find(v => v.FBaseMaterialCode.Equals(bom.ASapCode)); - if (view != null) - { - bom.AMaterialCode = view.FSaleOldMaterialCode; - } - } - } - else - { - if (viewsByTestCodes != null && viewsByTestCodes.Count > 0) - { - TFS_ViewMaterial view = viewsByTestCodes.Find(v => v.FBaseTestCode.Equals(bom.ATestCode)); - if (view != null) - { - bom.AMaterialCode = view.FSaleOldMaterialCode; - bom.ASapCode = view.FBaseMaterialCode; - } - } - } - } + /// + /// 递归梳理BOM + /// + /// 需要解析的集合 + /// 层级 + /// 内部定义会有问题,需要外部传入 + /// 父子级关系ID + private Dictionary CheckBomMaterial(List dataList, int materLevel, Random random, int parentId = -1) + { + List mateList = new List(); + List viewList = new List(); + List formulaList = new List(); + string ids1 = "", ids2 = "";//需求变更ids2弃用 + string materialCodes = ","; + string testCodes = ","; + if (dataList != null && dataList.Count > 0) + { + foreach (BomModel item in dataList) + { + if (!string.IsNullOrWhiteSpace(item.SP)) + { + item.Code = item.SP; + } + if (!string.IsNullOrWhiteSpace(item.SP_Version)) + { + item.Version = item.SP_Version; + } + if (!string.IsNullOrWhiteSpace(item.SP_VALUE)) + { + item.TestNO = item.SP_VALUE; + } + + int dataId = random.Next(1, 99) * random.Next(1, 99); + dataId += random.Next(10, 99) * random.Next(10, 99) * 2; + dataId += random.Next(1, 99) * random.Next(1, 99) * 10; + TFS_Material material = new TFS_Material() + { + FID = DateTime.Now.DayOfYear * 10 + dataId, + FPlmCode = item.Code, + FName = item.Name, + //FCode = item.Code, + FType = item.Type.ToLower(), + //FTestCode = item.TestNO, + FVersionCode = item.Version, + FParentID = parentId + }; + + TFS_ViewMaterial view = new TFS_ViewMaterial() + { + //FBaseFameCode = "", + //FBaseMaterialCode = material.FCode, + //FBaseTestCode = material.FTestCode, + FExtraQuantity = item.Quantity, + FBaseMaterialDesc = material.FName, + FLevel = materLevel, + FBomMaterialID = material.FID + }; + if (material.FType == "a" || material.FType == "f") + { + material.FType = "20"; + } + else if (material.FType == "b" || material.FType == "bb" || material.FType == "i" || material.FType == "iz") + { + material.FType = "30"; + } + else + { + material.FType = "40"; + } - int formulaApplyHistoryId = FormulaBll.AddFormulaApplyHistroy(formula, user.FName, user.FID); + if ("40".Equals(material.FType)) + { + item.ASapCode = item.SP_VALUE; + materialCodes = materialCodes + item.ASapCode + ","; + item.ATestCode = ""; + } + else + { + item.ATestCode = item.SP_VALUE; + testCodes = testCodes + item.ATestCode + ","; + } + + List viewsByMaterialCodes = FormulaBll.GetViewByMaterialCodes(materialCodes); + List viewsByTestCodes = FormulaBll.GetViewByTestCodes(testCodes); + + MaterialBll materialBll = new MaterialBll(); + TFS_Material tFS_Material = materialBll.GetMaterialListByFTestCode(item.SP_VALUE).LastOrDefault(); - resultObj.Add("applyHistoryId", formulaApplyHistoryId); - resultObj.Add("bomList", bomList); + if ("40".Equals(material.FType)) + { + item.AMaterialCode = item.SP_VALUE; + if (tFS_Material != null) + { + item.ASapCode = tFS_Material.OldCode; + } + else + { + item.ASapCode = ""; + } + } + else + { + if (viewsByTestCodes != null && viewsByTestCodes.Count > 0) + { + //TFS_ViewMaterial view2 = viewsByTestCodes.Find(v => v.FBaseTestCode.Equals(item.ATestCode)); + - bomListStr = JsonConvert.SerializeObject(resultObj); + if (tFS_Material != null) + { + item.AMaterialCode = tFS_Material.FCode; + item.ASapCode = tFS_Material.OldCode; + + //item.AMaterialCode = view2.FSaleOldMaterialCode; + //item.ASapCode = view2.FBaseMaterialCode; + } + else + { + item.ASapCode = ""; } } } + item.ABomType = "kg"; - apiResult.Data = bomListStr; + if (item.Name.Contains("@")) + { + item.EnName = "甜味"; + } + else if (item.Name.Contains("□")) + { + item.EnName = "咸味"; + } + else { + item.EnName = ""; + } + + if (materLevel == 0) + { + material.FType = "20"; + ids2 = material.FID + ""; + } + if (material.FType == "40") + { + material.FCode = item.TestNO; + //material.FPlmCode = ""; + } + + int.TryParse(material.FType, out int mType); + if (materLevel == 1) ids1 += material.FID + ","; + switch (mType) + { + case (int)Constant.MaterialType.产成品: + material.FTestCode = item.TestNO; + view.FBaseTestCode = item.TestNO; + view.FViewType = 1; + break; + case (int)Constant.MaterialType.半成品: + view.FViewType = (int)Constant.ViewType.半成品视图; + material.FTestCode = item.TestNO; + view.FBaseTestCode = item.TestNO; + break; + case (int)Constant.MaterialType.中间品: + view.FViewType = material.FName.Contains("香基") ? (int)Constant.ViewType.香基视图 : (int)Constant.ViewType.中间品视图; + material.FTestCode = item.TestNO; + view.FBaseTestCode = item.TestNO; + break; + case (int)Constant.MaterialType.原辅料: + view.FViewType = (int)Constant.ViewType.原料视图; + view.FBaseMaterialCode = material.FCode; + //默认值不同 + view.FPurchaseCompany = "kg"; + view.FPurchaseCompanyCount = "1"; + view.FPurchaseBaseCompanyCount = "1000"; + view.FSaleAccountSettingGroup = "15"; + view.FStorageTotalShelfLife = "7300"; + view.FMRP2ExternalStoragePlace = "1000"; + view.FPlanUnlimitedOverDelivery = ""; + view.FAccountPriceControl = "V"; + view.FAccountPriceDetermine = "2"; + view.FAccountAccessType = "1000"; + view.FAccountSaleOrderInventory = "1010"; + break; + } + mateList.Add(material); + viewList.Add(view); + if (item.Specifications != null && item.Specifications.Count > 0) + { + Dictionary childData = CheckBomMaterial(item.Specifications, materLevel + 1, random, material.FID); + if (materLevel >= 1) + { + formulaList.Add(new TFS_Formula() + { + FID = -1, + FName = material.FName, + FType = material.FType, + FTestCode = material.FTestCode, + FVersionCode = material.FVersionCode, + FPlmCode = string.IsNullOrEmpty(material.FPlmCode) ? material.FCode : material.FPlmCode + }); + } + mateList.AddRange((List)childData["mateList"]); + viewList.AddRange((List)childData["viewList"]); + formulaList.AddRange((List)childData["formulaList"]); + ids1 = ids1.Trim(',') + "," + childData["formulaIds"] + ","; + ids2 = ids2.Trim(',') + "," + childData["halfIds"] + ","; + } } - }, apiResult, Request); + } + return new Dictionary + { + { "mateList", mateList }, + { "viewList", viewList }, + { "formulaList", formulaList }, + { "formulaIds", ids1.Trim(',') }, + { "halfIds", ids2.Trim(',') }, + { "bomList", dataList } + }; } + /// /// 根据物料号列表获取物料列表 /// diff --git a/FactorySystemApi/Controllers/TeamworkController.cs b/FactorySystemApi/Controllers/TeamworkController.cs index 0de4edb..37374a9 100644 --- a/FactorySystemApi/Controllers/TeamworkController.cs +++ b/FactorySystemApi/Controllers/TeamworkController.cs @@ -700,7 +700,7 @@ namespace FactorySystemApi.Controllers FName = item.Name, //FCode = item.Code, FType = item.Type.ToLower(), - FTestCode = item.TestNO, + //FTestCode = item.TestNO, FVersionCode = item.Version, FParentID = parentId }; @@ -709,7 +709,7 @@ namespace FactorySystemApi.Controllers { //FBaseFameCode = "", //FBaseMaterialCode = material.FCode, - FBaseTestCode = material.FTestCode, + //FBaseTestCode = material.FTestCode, FExtraQuantity = item.Quantity, FBaseMaterialDesc = material.FName, FLevel = materLevel, @@ -735,8 +735,8 @@ namespace FactorySystemApi.Controllers } if (material.FType == "40") { - material.FCode = material.FPlmCode; - material.FPlmCode = ""; + material.FCode = item.TestNO; + //material.FPlmCode = ""; } int.TryParse(material.FType, out int mType); @@ -744,13 +744,19 @@ namespace FactorySystemApi.Controllers switch (mType) { case (int)Constant.MaterialType.产成品: + material.FTestCode = item.TestNO; + view.FBaseTestCode=item.TestNO; view.FViewType = 1; break; case (int)Constant.MaterialType.半成品: view.FViewType = (int)Constant.ViewType.半成品视图; + material.FTestCode = item.TestNO; + view.FBaseTestCode = item.TestNO; break; case (int)Constant.MaterialType.中间品: view.FViewType = material.FName.Contains("香基") ? (int)Constant.ViewType.香基视图 : (int)Constant.ViewType.中间品视图; + material.FTestCode = item.TestNO; + view.FBaseTestCode = item.TestNO; break; case (int)Constant.MaterialType.原辅料: view.FViewType = (int)Constant.ViewType.原料视图; @@ -1218,14 +1224,23 @@ namespace FactorySystemApi.Controllers END ,'') as '{1}'", field.FField, field.FName); } - else if (field.FName == "固定损耗数量" && intType == 2) + else if (field.FName == "固定损耗数量" && intType == 2) { selectSql += string.Format(@"isnull(CASE - WHEN TFS_Material.FFixedLoss='(空)' THEN '' + WHEN TFS_Material.FFixedLoss='(空)' OR TFS_Material.FFixedLoss=0 THEN '' ELSE TFS_Material.FFixedLoss END ,'') as '{1}'", field.FField, field.FName); } + //else if (field.FName == "组件损耗率" && intType == 5) + //{ + // selectSql += string.Format(@"isnull( + // isnull( + + // (select CAST ( 100.0 - TFS_MaterialInfo.FTheoryYield AS VARCHAR ) from TFS_MaterialInfo where FDataID=(select TOP 1 FMaterialID from TFS_ViewMaterial where FTeamID={0}) AND TFS_MaterialInfo.FTheoryYield <>'(空)' AND TFS_MaterialInfo.FTheoryYield<>'' AND TFS_MaterialInfo.FTheoryYield IS NOT NULL), + // '' + // ),'') AS '组件损耗率'", teamId); + //} else { selectSql += string.Format("isnull({0},'') as '{1}'", field.FField, field.FName); @@ -1473,6 +1488,7 @@ namespace FactorySystemApi.Controllers DataTable dataList2 = dataList.Copy(); for (int i = 0; i < rowCount; i++) { + dataList2.Rows[i]["版本"] = "0002"; if (isChange && dataList2.Rows[i]["BOM用途"].ToString() == "1") { dataList2.Rows[i]["BOM用途"] = "Y"; diff --git a/FactorySystemApi/Web.config b/FactorySystemApi/Web.config index 1ad47c3..91dd930 100644 --- a/FactorySystemApi/Web.config +++ b/FactorySystemApi/Web.config @@ -4,44 +4,45 @@ https://go.microsoft.com/fwlink/?LinkId=301879 --> - - -
- - - - - - - + + +
+ + + + + + + + - - - - + + + + - + - + - - - + + + - - - - + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://dd.hbflavor.com:28888/PlmMsg/SendPLMMsgInterface.asmx - - - http://sappoqas.hbglobal.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=ZMCS_FLAVOR&receiverParty=&receiverService=&interface=si_mm100_mcs_sender&interfaceNamespace=http%3A%2F%2Fwww.zmc.com%2Fflavor%2Fmm - - - http://sappoqas.hbglobal.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=ZMCS_FLAVOR&receiverParty=&receiverService=&interface=si_pp062_bc_sender&interfaceNamespace=http%3A%2F%2Fwww.zmc.com%2Fflavor%2Fpp - - - http://sappoqas.hbglobal.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=ZMCS_FLAVOR&receiverParty=&receiverService=&interface=si_pp071_mcs_sender&interfaceNamespace=http%3A%2F%2Fwww.zmc.com%2Fflavor%2Fpp - - - https://plmtest.hbflavor.com/PlmWebService/OAService.asmx - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://dd.hbflavor.com:28888/PlmMsg/SendPLMMsgInterface.asmx + + + http://sappoqas.hbglobal.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=ZMCS_FLAVOR&receiverParty=&receiverService=&interface=si_mm100_mcs_sender&interfaceNamespace=http%3A%2F%2Fwww.zmc.com%2Fflavor%2Fmm + + + http://sappoqas.hbglobal.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=ZMCS_FLAVOR&receiverParty=&receiverService=&interface=si_pp062_bc_sender&interfaceNamespace=http%3A%2F%2Fwww.zmc.com%2Fflavor%2Fpp + + + http://sappoqas.hbglobal.com:50000/XISOAPAdapter/MessageServlet?senderParty=&senderService=ZMCS_FLAVOR&receiverParty=&receiverService=&interface=si_pp071_mcs_sender&interfaceNamespace=http%3A%2F%2Fwww.zmc.com%2Fflavor%2Fpp + + + https://plmtest.hbflavor.com/PlmWebService/OAService.asmx + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/FactorySystemBll/MaterialBll.cs b/FactorySystemBll/MaterialBll.cs index 471c075..42bffe8 100644 --- a/FactorySystemBll/MaterialBll.cs +++ b/FactorySystemBll/MaterialBll.cs @@ -43,6 +43,7 @@ namespace FactorySystemBll if (factory == null) temp.FFactoryID = -1; else temp.FFactoryID = factory.FID; } + temp.OldCode = temp.FOldID.ToString(); temp.FAddDate = temp.FEditDate = DateTime.Now; temp.FEditUser = userId; insertList.Add(temp); @@ -69,6 +70,7 @@ namespace FactorySystemBll } } } + temp.OldCode = temp.FOldID.ToString(); } updateList.Add(temp); } diff --git a/FactorySystemModel/SqlSugarModel/TFS_Material.cs b/FactorySystemModel/SqlSugarModel/TFS_Material.cs index 74d22eb..b662843 100644 --- a/FactorySystemModel/SqlSugarModel/TFS_Material.cs +++ b/FactorySystemModel/SqlSugarModel/TFS_Material.cs @@ -488,5 +488,9 @@ namespace FactorySystemModel.SqlSugarModel /// Nullable:False /// public string FSAPDescription { get; set; } + /// + /// 接收旧码字段 + /// + public string OldCode { get; set; } } }