From f182a95ae1c66073269c4287f81e22e0955ff579 Mon Sep 17 00:00:00 2001 From: Leo Date: Thu, 27 Jul 2023 19:33:33 +0800 Subject: [PATCH] =?UTF-8?q?20230727=20=E4=BF=AE=E6=94=B9=E5=8D=8F=E5=90=8C?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF=E4=B8=AD=EF=BC=8C=E7=89=A9=E6=96=99=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E7=9A=84=E6=9F=A5=E8=AF=A2=E9=80=BB=E8=BE=91=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AF=B9=E8=A7=86=E5=9B=BE=E8=A1=A8=E4=B8=AD?= =?UTF-8?q?FTeamType=E7=9A=84=E5=88=A4=E6=96=AD=EF=BC=8C=E5=BD=93FTeamType?= =?UTF-8?q?=20=3D=200=E6=97=B6=EF=BC=8C=E6=97=B6=E5=8D=8F=E5=90=8C?= =?UTF-8?q?=E8=B7=AF=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/TeamworkController.cs | 40 ++++++++++------ FactorySystemBll/ViewBll.cs | 47 ++++++++++--------- 2 files changed, 52 insertions(+), 35 deletions(-) diff --git a/FactorySystemApi/Controllers/TeamworkController.cs b/FactorySystemApi/Controllers/TeamworkController.cs index 1edc44c..92fc2de 100644 --- a/FactorySystemApi/Controllers/TeamworkController.cs +++ b/FactorySystemApi/Controllers/TeamworkController.cs @@ -143,11 +143,21 @@ namespace FactorySystemApi.Controllers List materialList = TeamworkBll.CheckMaterialListByTest(teamwork.FFormulaTestCode, teamwork.FVersionCode); if (materialList.Count == 0) { TeamworkBll.CreateProductView(teamwork, null, user.FID); + + // 20230726 不论新增或暂存,都在创建协同时生成成品事项 + //BaseBll.CreateTaskData(teamwork.FID, user.FID, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID); + //BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.成品视图, 2, 1); + //开始BOM下载 DockGetBomData(teamwork.FID, user.FID); } else { TeamworkBll.CreateProductView(teamwork, materialList, user.FID); + + // 20230726 不论新增或暂存,都在创建协同时生成成品事项 + //BaseBll.CreateTaskData(teamwork.FID, user.FID, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID); + //BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.成品视图, 2, 1); + TeamworkBll.HasMaterialTestCode(teamwork); /** @@ -178,6 +188,12 @@ namespace FactorySystemApi.Controllers } else { + // 20230726 不论新增或暂存,都在创建协同时生成成品事项 + //TFS_FTeamwork teamwork = BaseBll.GetTempModel(teamId); + //TeamworkBll.CreateProductView(teamwork, null, user.FID); + //BaseBll.CreateTaskData(teamwork.FID, user.FID, "3", teamwork.FCreateFactoryID + "," + teamwork.FProdFactoryID); + //BaseBll.UpdateTeamProcess(teamwork.FID, (int)Constant.ProcessType.成品视图, 2, 1); + BaseBll.CreateTaskData(teamId, user.FID, ((int)Constant.TaskType.配方选择).ToString()); BaseBll.UpdateTeamProcess(teamId, (int)Constant.ProcessType.协同发起, 1, 1); } @@ -304,16 +320,16 @@ namespace FactorySystemApi.Controllers savePath += Constant.TeamViewType.配方视图.ToString(); //原始配方 whereSql = string.Format(@"dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialFormulaIDs from TFS_FTeamwork where FID={0}))>0 - and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); + and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); //生产、计划配方 joinSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialFormulaIDs from TFS_FTeamwork where FID={0}))>0 - and TFS_Material.FSuccedaneumID<1)and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", + and TFS_Material.FSuccedaneumID<1) and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); break; case (int)Constant.TeamViewType.生产工艺路线视图: savePath += Constant.TeamViewType.生产工艺路线视图.ToString(); //只要生产工厂 - whereSql += string.Format(" and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.单工厂); + whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.单工厂); //视图类型 List tempInt3_1 = new List { @@ -322,12 +338,12 @@ namespace FactorySystemApi.Controllers (int)Constant.ViewType.香基视图, (int)Constant.ViewType.中间品视图 }; - whereSql += string.Format(" and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt3_1)); + whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt3_1)); break; case (int)Constant.TeamViewType.生产版本视图: savePath += Constant.TeamViewType.生产版本视图.ToString(); //只要生产工厂 - whereSql += string.Format(" and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.单工厂); + whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID in(select FID from TFS_Factory where FType={0})", (int)Constant.FactoryType.单工厂); //视图类型 List tempInt4_1 = new List { @@ -336,22 +352,22 @@ namespace FactorySystemApi.Controllers (int)Constant.ViewType.中间品视图, (int)Constant.ViewType.香基视图 }; - whereSql += string.Format(" and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt4_1)); + whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FViewType in({0})", string.Join(",", tempInt4_1)); break; case (int)Constant.TeamViewType.组装BOM视图: savePath += Constant.TeamViewType.组装BOM视图.ToString(); //一级半成品、包材→无替代料的 - whereSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialHalfIDs from TFS_FTeamwork where FID={0}))>0 or - TFS_ViewMaterial.FMaterialID in(select FMaterialID from TFS_PackageChild where FTeamID={0} or + whereSql = string.Format(@"(dbo.StrExistInStr(TFS_ViewMaterial.FMaterialID,(select FMaterialHalfIDs from TFS_FTeamwork where FID={0}))>0 or ( + TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FMaterialID in(select FMaterialID from TFS_PackageChild where FTeamID={0}) or FPackageID=(select FPackID from TFS_FTeamwork where FID={0}))) ", inParam["FTeamID"]); //只要生产工厂 - whereSql += string.Format(" and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); + whereSql += string.Format(" and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FFactoryID=(select FProdFactoryID from TFS_FTeamwork where FID={0})", inParam["FTeamID"]); break; case (int)Constant.TeamViewType.物料视图: default: savePath += Constant.TeamViewType.物料视图.ToString(); - whereSql += " and TFS_ViewMaterial.FMaterialID>0"; + whereSql += " and TFS_ViewMaterial.FTeamType = 0 and TFS_ViewMaterial.FMaterialID>0"; break; } savePath += ".xlsx"; @@ -621,10 +637,6 @@ namespace FactorySystemApi.Controllers return result; } - - - - /// /// 递归梳理BOM /// diff --git a/FactorySystemBll/ViewBll.cs b/FactorySystemBll/ViewBll.cs index 81709ee..144fcce 100644 --- a/FactorySystemBll/ViewBll.cs +++ b/FactorySystemBll/ViewBll.cs @@ -37,24 +37,26 @@ namespace FactorySystemBll { viewList = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) - .Where((a, b) => a.FTeamID == teamId) - //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) - .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) - .WhereIF(viewType > 0, (a, b) => a.FViewType == viewType) - .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + - "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + - "b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); + .Where((a, b) => a.FTeamID == teamId) + .Where((a, b) => a.FTeamType == 0) + //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) + .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) + .WhereIF(viewType > 0, (a, b) => a.FViewType == viewType) + .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + + "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + + "b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); } else if (viewType == 10) { viewList = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) - .Where((a, b) => a.FTeamID == teamId) - //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) - .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) - .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + - "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + - "b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); + .Where((a, b) => a.FTeamID == teamId) + .Where((a, b) => a.FTeamType == 0) + //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) + .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) + .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + + "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + + "b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); TFS_FTeamwork teamWork = db.Queryable().Where(s => s.FID == teamId).First(); TFS_PackageMain packAge = db.Queryable().Where(s => s.FCode == teamWork.FPackCode).First(); @@ -81,11 +83,12 @@ namespace FactorySystemBll { viewList = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) - .Where((a, b) => a.FTeamID == teamId) - //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) - .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) - .WhereIF(viewType > 0, (a, b) => a.FViewType == 1) - .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + + .Where((a, b) => a.FTeamID == teamId) + .Where((a, b) => a.FTeamType == 0) + //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) + .WhereIF(currUser != null, (a, b) => currUser.FFactoryList.Contains(a.FFactoryID.ToString())) + .WhereIF(viewType > 0, (a, b) => a.FViewType == 1) + .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode,b.FTestCode,b.FRelationCode,b.FRelationName,b.FSAPCode,b.FSAPDescription,b.FMaterialGroup,b.FMaterialType,b.FCustomerCode,b.FStoreHouse," + "b.FBomEntry,b.FLineHouse,b.FProductDesc,b.FWorkCenter,b.FCraftExplain,b.FIidentifier,b.FGuaranteePeriod,b.FBStorageConditions,b.FSafetyStock,b.FTriggerRatio,b.FMinAmount,b.FMaxAmount,b.FYield,b.FFixedLoss,b.FTheoryYield," + "b.FQualityTest1,b.FQualityTest2").ToDictionaryList(); List Minfo = GetMaterialInfoList(viewList.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId); @@ -281,6 +284,7 @@ namespace FactorySystemBll List> viewList = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) .Where((a, b) => a.FTeamID == teamId) + .Where((a, b) => a.FTeamType == 0) //.WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList(); @@ -294,10 +298,11 @@ namespace FactorySystemBll { List> viewList1 = db.Queryable((a, b) => new JoinQueryInfos(JoinType.Inner, a.FMaterialID == b.FID)) - .Where((a, b) => a.FTeamID == teamId) - .WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) + .Where((a, b) => a.FTeamID == teamId) + .Where((a, b) => a.FTeamType == 0) + .WhereIF(currUser != null, (a, b) => a.FFactoryID == currUser.FFactoryID) .WhereIF(viewType > 0, (a, b) => a.FViewType == 2) - .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList(); + .Select("distinct a.*,b.FTypeID1,b.FTypeID2,b.FK3Code,b.FK3Name,b.FK3ShortCode").ToDictionaryList(); List Minfo = GetMaterialInfoList(viewList1.GroupBy(s => s["FMaterialID"]).Select(s => int.Parse(s.Key.ToString())).ToList(), "", "", currUserId); if (Minfo.Count > 0) {