| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections; | 
					
						
							|  |  |  |  | using System.Diagnostics.CodeAnalysis; | 
					
						
							|  |  |  |  | using System.Globalization; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Data.Linq; | 
					
						
							|  |  |  |  | using System.Web.Security; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | using Model; | 
					
						
							|  |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace BLL | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public class WbsSetService | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 增加分部/子分部/分项/子分项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="user">分部/子分部/分项/子分项</param> | 
					
						
							|  |  |  |  |         public static void AddWbsSet(Model.Wbs_WbsSet wbsSet) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet newWS = new Model.Wbs_WbsSet(); | 
					
						
							|  |  |  |  |             newWS.WbsSetId = wbsSet.WbsSetId; | 
					
						
							|  |  |  |  |             newWS.WbsSetName = wbsSet.WbsSetName; | 
					
						
							|  |  |  |  |             newWS.WbsSetCode = wbsSet.WbsSetCode; | 
					
						
							|  |  |  |  |             newWS.SuperWbsSetId = wbsSet.SuperWbsSetId; | 
					
						
							|  |  |  |  |             newWS.ProjectId = wbsSet.ProjectId; | 
					
						
							|  |  |  |  |             newWS.InstallationId = wbsSet.InstallationId; | 
					
						
							|  |  |  |  |             newWS.CnProfessionId = wbsSet.CnProfessionId; | 
					
						
							|  |  |  |  |             newWS.UnitProjectId = wbsSet.UnitProjectId; | 
					
						
							|  |  |  |  |             newWS.StartDate = wbsSet.StartDate; | 
					
						
							|  |  |  |  |             newWS.EndDate = wbsSet.EndDate; | 
					
						
							|  |  |  |  |             newWS.IsChild = wbsSet.IsChild; | 
					
						
							|  |  |  |  |             newWS.ControlItemDef = wbsSet.ControlItemDef; | 
					
						
							|  |  |  |  |             newWS.ControlPoint = wbsSet.ControlPoint; | 
					
						
							|  |  |  |  |             newWS.Cycle = wbsSet.Cycle; | 
					
						
							|  |  |  |  |             newWS.Frequency = wbsSet.Frequency; | 
					
						
							|  |  |  |  |             newWS.Weights = wbsSet.Weights; | 
					
						
							|  |  |  |  |             newWS.Flag = wbsSet.Flag; | 
					
						
							|  |  |  |  |             newWS.Way = wbsSet.Way; | 
					
						
							|  |  |  |  |             newWS.Remark = wbsSet.Remark; | 
					
						
							|  |  |  |  |             newWS.IsIn = wbsSet.IsIn; | 
					
						
							|  |  |  |  |             newWS.IsSelected = wbsSet.IsSelected; | 
					
						
							|  |  |  |  |             newWS.IsApprove = wbsSet.IsApprove; | 
					
						
							|  |  |  |  |             newWS.EngineerQuantity = wbsSet.EngineerQuantity; | 
					
						
							|  |  |  |  |             newWS.BudgetUnitPrice = wbsSet.BudgetUnitPrice; | 
					
						
							|  |  |  |  |             newWS.CostUnivalent = wbsSet.CostUnivalent; | 
					
						
							|  |  |  |  |             newWS.Unit = wbsSet.Unit; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             db.Wbs_WbsSet.InsertOnSubmit(newWS); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 修改分部/子分部/分项/子分项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="user">分部/子分部/分项/子分项</param> | 
					
						
							|  |  |  |  |         public static void UpdateWbsSet(Model.Wbs_WbsSet wbsSet) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet newWS = db.Wbs_WbsSet.First(e => e.WbsSetId == wbsSet.WbsSetId); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             newWS.WbsSetName = wbsSet.WbsSetName; | 
					
						
							|  |  |  |  |             newWS.WbsSetCode = wbsSet.WbsSetCode; | 
					
						
							|  |  |  |  |             newWS.StartDate = wbsSet.StartDate; | 
					
						
							|  |  |  |  |             newWS.EndDate = wbsSet.EndDate; | 
					
						
							|  |  |  |  |             newWS.Weights = wbsSet.Weights; | 
					
						
							|  |  |  |  |             newWS.WeightsMoney = wbsSet.WeightsMoney; | 
					
						
							|  |  |  |  |             newWS.Flag = wbsSet.Flag; | 
					
						
							|  |  |  |  |             newWS.Way = wbsSet.Way; | 
					
						
							|  |  |  |  |             newWS.ControlItemDef = wbsSet.ControlItemDef; | 
					
						
							|  |  |  |  |             newWS.ControlPoint = wbsSet.ControlPoint; | 
					
						
							|  |  |  |  |             newWS.Cycle = wbsSet.Cycle; | 
					
						
							|  |  |  |  |             newWS.Frequency = wbsSet.Frequency; | 
					
						
							|  |  |  |  |             newWS.Remark = wbsSet.Remark; | 
					
						
							|  |  |  |  |             newWS.IsSelected = wbsSet.IsSelected; | 
					
						
							|  |  |  |  |             newWS.IsApprove = wbsSet.IsApprove; | 
					
						
							|  |  |  |  |             newWS.IsWeightsApprove = wbsSet.IsWeightsApprove; | 
					
						
							|  |  |  |  |             newWS.IsPlanApprove = wbsSet.IsPlanApprove; | 
					
						
							|  |  |  |  |             newWS.VersionNum = wbsSet.VersionNum; | 
					
						
							|  |  |  |  |             newWS.LastCheckDate = wbsSet.LastCheckDate; | 
					
						
							|  |  |  |  |             newWS.CheckDate = wbsSet.CheckDate; | 
					
						
							|  |  |  |  |             newWS.CheckNum = wbsSet.CheckNum; | 
					
						
							|  |  |  |  |             newWS.HandleType = wbsSet.HandleType; | 
					
						
							|  |  |  |  |             newWS.IsENEnd = wbsSet.IsENEnd; | 
					
						
							|  |  |  |  |             newWS.SortIndex = wbsSet.SortIndex; | 
					
						
							|  |  |  |  |             newWS.NoShow = wbsSet.NoShow; | 
					
						
							|  |  |  |  |             newWS.EngineerQuantity = wbsSet.EngineerQuantity; | 
					
						
							|  |  |  |  |             newWS.BudgetUnitPrice = wbsSet.BudgetUnitPrice; | 
					
						
							|  |  |  |  |             newWS.CostUnivalent = wbsSet.CostUnivalent; | 
					
						
							|  |  |  |  |             newWS.Unit = wbsSet.Unit; | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 修改分部/子分部/分项/子分项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="user">分部/子分部/分项/子分项</param> | 
					
						
							|  |  |  |  |         public static void UpdateWbsSetIsPlanApprove(Model.Wbs_WbsSet wbsSet, bool isPlanApprove) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet newWS = db.Wbs_WbsSet.First(e => e.WbsSetId == wbsSet.WbsSetId); | 
					
						
							|  |  |  |  |             newWS.IsPlanApprove = wbsSet.IsPlanApprove; | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据Id删除分部/子分部/分项/子分项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="userId"></param> | 
					
						
							|  |  |  |  |         public static void DeleteWbsSet(string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet WS = db.Wbs_WbsSet.First(e => e.WbsSetId == wbsSetId); | 
					
						
							|  |  |  |  |             db.Wbs_WbsSet.DeleteOnSubmit(WS); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据单位工程Id删除所有分部/子分部/分项/子分项信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="userId"></param> | 
					
						
							|  |  |  |  |         public static void DeleteWbsSetByUnitProjectId(string unitProjectId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             var q = from x in db.Wbs_WbsSet where x.UnitProjectId == unitProjectId select x; | 
					
						
							|  |  |  |  |             db.Wbs_WbsSet.DeleteAllOnSubmit(q); | 
					
						
							|  |  |  |  |             db.SubmitChanges(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据装置Id获取集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="installationId">装置Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.Wbs_WbsSet> GetWbsSetsByInstallationId(string installationId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet where x.InstallationId == installationId orderby x.SortIndex, x.WbsSetCode select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.Wbs_WbsSet> GetWbsSetsBySuperWbsSetId(string superWbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == superWbsSetId orderby x.WbsSetCode select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.Wbs_WbsSet> GetApproveWbsSetsBySuperWbsSetId(string superWbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == superWbsSetId && x.IsApprove == true orderby x.WbsSetCode select x).ToList(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.Wbs_WbsSet> GetIsChildWbsSetsBySuperWbsSetId(string superWbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == superWbsSetId && x.IsChild == null orderby x.WbsSetCode select x).ToList(); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取子级集合的累计工程量 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitProjectId">单位工程Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static decimal GetChildEngineerQuantitys(string superWbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == superWbsSetId && x.IsApprove == true select x.EngineerQuantity ?? 0).Sum(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取已经选择的集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.Wbs_WbsSet> GetIsSelectedWbsSetsBySuperWbsSetId(string superWbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == superWbsSetId && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据级别获取末级项集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<Model.Wbs_WbsSet> GetWbsSetsByControlPoint(string installationId, string controlPoint) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return (from x in Funs.DB.Wbs_WbsSet | 
					
						
							|  |  |  |  |                     join y in Funs.DB.WBS_CnProfession on x.CnProfessionId equals y.CnProfessionId | 
					
						
							|  |  |  |  |                     where y.InstallationId == installationId && x.ControlPoint == controlPoint | 
					
						
							|  |  |  |  |                     orderby x.SortIndex, x.WbsSetCode | 
					
						
							|  |  |  |  |                     select x).ToList(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据Id判断子级中是否存在对应Id | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static bool IsExitWbsSetById(string wbsSetId, string searchId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             List<string> ids = GetWbsSetIds(wbsSetId); | 
					
						
							|  |  |  |  |             if (ids.Contains(searchId) || wbsSetId == searchId) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据Id判断子级中是否存在对应Id  | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="superWbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static bool IsExitWbsSetById2(string wbsSetId, string searchId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             List<string> ids = GetWbsSetIds2(wbsSetId); | 
					
						
							|  |  |  |  |             if (ids.Contains(searchId) || wbsSetId == searchId) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return true; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取所有Id集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="wbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<string> GetWbsSetIds(string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             List<string> ids = new List<string>(); | 
					
						
							|  |  |  |  |             var wbsSets = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(wbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSets.Count > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (var wbsSet in wbsSets) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ids.Add(wbsSet.WbsSetId); | 
					
						
							|  |  |  |  |                     ids.AddRange(GetWbsSetIds(wbsSet.WbsSetId)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return ids; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据子级Id获取所有上级Id集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="wbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<string> GetParentWbsSetIds(string superWbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             List<string> ids = new List<string>(); | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(superWbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSet != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ids.Add(wbsSet.WbsSetId); | 
					
						
							|  |  |  |  |                 ids.AddRange(GetParentWbsSetIds(wbsSet.SuperWbsSetId)); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return ids; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据上级Id获取所有Id集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="wbsSetId">上级Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<string> GetWbsSetIds2(string wbsSetId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             List<string> ids = new List<string>(); | 
					
						
							|  |  |  |  |             var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSets.Count > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (var wbsSet in wbsSets) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     ids.Add(wbsSet.WbsSetId); | 
					
						
							|  |  |  |  |                     ids.AddRange(GetWbsSetIds2(wbsSet.WbsSetId)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return ids; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |         /// 根据分部/子分部/分项/子分项工程Id获取分部/子分部/分项/子分项工程信息 | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// </summary> | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |         /// <param name="unitProjectId">分部/子分部/分项/子分项工程Id</param> | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         /// <returns></returns> | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |         public static Model.Wbs_WbsSet GetWbsSetByWbsSetId(string wbsSetId) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             return Funs.DB.Wbs_WbsSet.FirstOrDefault(e => e.WbsSetId == wbsSetId); | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据分部/子分部/分项/子分项工程Id获取分部/子分部/分项/子分项工程信息 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitProjectId">分部/子分部/分项/子分项工程Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |         public static Model.Wbs_WbsSet GetWbsSetByWbsSetCode(string wbsSetCode, string projectId) | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2021-08-13 11:15:59 +08:00
										 |  |  |  |             return Funs.DB.Wbs_WbsSet.FirstOrDefault(e => e.WbsSetCode == wbsSetCode && e.ProjectId == projectId); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据装置、专业Id和分部编号获取分部Id | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitProjectId">专业Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<string> GetWbsSetIdByInstallationIdAndCNCodeAndUnitProjectCodeAndWbsSetCode(string installationId, string cnCode, string unitProjectCode, string wbsSetCode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             string inId = string.Empty; | 
					
						
							|  |  |  |  |             Model.Project_Installation ins = db.Project_Installation.FirstOrDefault(x => x.InstallationId == installationId); | 
					
						
							|  |  |  |  |             if (ins.IsEnd == true) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 inId = installationId; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 inId = Project_InstallationService.GetEndInstallationId(installationId); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             var cn = (from x in db.WBS_CnProfession where x.InstallationId == inId && x.OldId.ToString() == cnCode select x).FirstOrDefault(); | 
					
						
							|  |  |  |  |             var list = (from x in db.Wbs_WbsSet | 
					
						
							|  |  |  |  |                        join y in db.Wbs_UnitProject | 
					
						
							|  |  |  |  |                        on x.UnitProjectId equals y.UnitProjectId | 
					
						
							|  |  |  |  |                        where x.CnProfessionId == cn.CnProfessionId && y.UnitProjectCode == unitProjectCode && x.WbsSetCode==wbsSetCode select x.WbsSetId).ToList(); | 
					
						
							|  |  |  |  |             return list; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据专业Id和分部编号获取分部Id | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitProjectId">专业Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<string> GetWbsSetIdByCnProfessionIdAndUnitProjectCodeAndWbsSetCode(string cnProfessionId, string unitProjectCode, string wbsSetCode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             var list = (from x in db.Wbs_WbsSet | 
					
						
							|  |  |  |  |                         join y in db.Wbs_UnitProject | 
					
						
							|  |  |  |  |                         on x.UnitProjectId equals y.UnitProjectId | 
					
						
							|  |  |  |  |                         where x.CnProfessionId == cnProfessionId && y.UnitProjectCode == unitProjectCode && x.WbsSetCode == wbsSetCode | 
					
						
							|  |  |  |  |                         select x.WbsSetId).ToList(); | 
					
						
							|  |  |  |  |             return list; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 根据分部Id获取分部Id | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="unitProjectId">专业Id</param> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public static List<string> GetWbsSetIdByUnitProjectIdAndWbsSetCode(string unitProjectId, string wbsSetCode) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							|  |  |  |  |             var list = (from x in db.Wbs_WbsSet | 
					
						
							|  |  |  |  |                         where x.UnitProjectId == unitProjectId && x.WbsSetCode == wbsSetCode | 
					
						
							|  |  |  |  |                         select x.WbsSetId).ToList(); | 
					
						
							|  |  |  |  |             return list; | 
					
						
							| 
									
										
										
										
											2021-04-30 10:28:37 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |