/// <summary> /// 同步项目负责人,项目副经理,主管副总工,计划工程师,质量工程师,文档工程师写进RBS /// </summary> public void SynchRBSUser(Dictionary <string, string> dic, S_W_WBS rootWBS = null) { if (rootWBS == null) { var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); //获取项目信息 var projectInfo = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息"); } rootWBS = projectInfo.WBSRoot; if (rootWBS == null) { throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。"); } } if (rootWBS.WBSType != WBSNodeType.Project.ToString()) { throw new Formula.Exceptions.BusinessException("非根节点WBS,不可将项目主要干系人信息同步至RBS"); } if (rootWBS == null) { throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。"); } //将项目负责人,项目副经理,主管副总工,计划工程师,质量工程师,文档工程师写进RBS rootWBS.SetUsers(ProjectRole.ProjectManager.ToString(), this.ChargeUser.Split(','), true, true);//项目负责人 //c_hua 2018/10/08 根据角色定义与表单字段动态写入RBS var roleList = BaseConfigFO.GetRoleDefineList().Where(a => dic.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(dic.GetValue(a.RoleCode))); foreach (var roleDef in roleList) { rootWBS.SetUsers(roleDef.RoleCode, dic.GetValue(roleDef.RoleCode).Split(','), true, true); } }
/// <summary> /// 将WBS节点上的设校审人员填充到工作包上(如有多人,默认获取第一个人) /// </summary> /// <param name="wbsNode">WBS节点</param> public void FillWBSUser(S_W_WBS wbsNode) { var designer = wbsNode.GetUser(ProjectRole.Designer.ToString()); var collactor = wbsNode.GetUser(ProjectRole.Collactor.ToString()); var auditor = wbsNode.GetUser(ProjectRole.Auditor.ToString()); var approver = wbsNode.GetUser(ProjectRole.Approver.ToString()); var mapper = wbsNode.GetUser(ProjectRole.Mapper.ToString()); if (designer != null) { this.DesignerUserID = designer.UserID; this.DesignerUserName = designer.UserName; if (this.S_W_WBS != null) { this.S_W_WBS.SetUsers(ProjectRole.Designer.ToString(), this.DesignerUserID.Split(','), false, true, true, true); } } if (collactor != null) { this.CollactorUserID = collactor.UserID; this.CollactorUserName = collactor.UserName; if (this.S_W_WBS != null) { this.S_W_WBS.SetUsers(ProjectRole.Collactor.ToString(), this.CollactorUserID.Split(','), false, true, true, true); } } if (auditor != null) { this.AuditorUserID = auditor.UserID; this.AuditorUserName = auditor.UserName; if (this.S_W_WBS != null) { this.S_W_WBS.SetUsers(ProjectRole.Auditor.ToString(), this.AuditorUserID.Split(','), false, true, true, true); } } if (approver != null) { this.ApproverUserID = approver.UserID; this.ApproverUserName = approver.UserName; if (this.S_W_WBS != null) { this.S_W_WBS.SetUsers(ProjectRole.Approver.ToString(), this.ApproverUserID.Split(','), false, true, true, true); } } if (mapper != null) { this.MapperUserID = mapper.UserID; this.MapperUserName = mapper.UserName; if (this.S_W_WBS != null) { this.S_W_WBS.SetUsers(ProjectRole.Mapper.ToString(), this.MapperUserID.Split(','), false, true, true, true); } } }
/// <summary> /// 设置表单默认属性 /// </summary> /// <param name="auditForm"></param> /// <param name="wbs"></param> /// <param name="projectInfo"></param> public virtual void SetAuditFormInfo(T_AE_Audit auditForm, S_W_WBS wbs, S_I_ProjectInfo projectInfo) { if (String.IsNullOrEmpty(auditForm.ID)) { auditForm.ID = FormulaHelper.CreateGuid(); } if (string.IsNullOrEmpty(auditForm.WBSID)) { auditForm.WBSID = wbs.ID; } if (string.IsNullOrEmpty(auditForm.ProjectInfoID)) { auditForm.ProjectInfoID = wbs.ProjectInfoID; } if (string.IsNullOrEmpty(auditForm.State)) { auditForm.State = ProjectFlowState.InFlow.ToString(); } auditForm.CreateDate = DateTime.Now; auditForm.ProjectInfoCode = projectInfo.Code; auditForm.ProjectInfoName = projectInfo.Name; if (wbs.WBSType == WBSNodeType.Work.ToString()) { auditForm.TaskWorkCode = wbs.Code; auditForm.TaskWorkName = wbs.Name; } var subProject = wbs.Seniorities.FirstOrDefault(d => d.WBSType == WBSNodeType.SubProject.ToString()); if (subProject != null) { auditForm.SubProjectCode = subProject.Code; auditForm.SubProjectName = subProject.Name; } var major = wbs.Seniorities.FirstOrDefault(d => d.WBSType == WBSNodeType.Major.ToString()); if (major != null) { auditForm.MajorCode = major.WBSValue; auditForm.MajorName = major.Name; } auditForm.PhaseCode = projectInfo.PhaseValue; var ph = BaseConfigFO.GetWBSEnum(WBSNodeType.Phase).AsEnumerable().FirstOrDefault(c => c["value"].ToString() == projectInfo.PhaseValue); if (ph != null) { auditForm.PhaseName = ph["text"].ToString(); } }
public void BuildSubProjectWBS(S_W_WBS parentWBS, List <Dictionary <string, object> > subProjectList, List <Dictionary <string, object> > majorList) { foreach (var subProject in subProjectList) { //子项 var sCode = subProject.GetValue("Code").ToString(); S_W_WBS subprojectwbs = parentWBS.AllChildren.FirstOrDefault(c => c.Code == sCode); if (subprojectwbs == null) { #region 新增 subprojectwbs = new S_W_WBS { WBSType = WBSNodeType.SubProject.ToString(), Code = subProject.GetValue("Code").ToString(), Name = subProject.GetValue("Name").ToString(), ChargeUserID = subProject.GetValue("ChargeUserID").ToString(), ChargeUserName = subProject.GetValue("ChargeUserName").ToString() }; if (!string.IsNullOrEmpty(subProject.GetValue("PlanStartDate"))) { subprojectwbs.PlanStartDate = Convert.ToDateTime(subProject.GetValue("PlanStartDate")); } if (!string.IsNullOrEmpty(subProject.GetValue("PlanEndDate"))) { subprojectwbs.PlanEndDate = Convert.ToDateTime(subProject.GetValue("PlanEndDate")); } parentWBS.AddChild(subprojectwbs); #endregion } else { subprojectwbs.Name = subProject.GetValue("Name").ToString(); if (!String.IsNullOrEmpty(subProject.GetValue("ChargeUserID"))) { subprojectwbs.ChargeUserID = subProject.GetValue("ChargeUserID"); subprojectwbs.ChargeUserName = subProject.GetValue("ChargeUserName"); } if (!string.IsNullOrEmpty(subProject.GetValue("PlanStartDate"))) { subprojectwbs.PlanStartDate = Convert.ToDateTime(subProject.GetValue("PlanStartDate")); } if (!string.IsNullOrEmpty(subProject.GetValue("PlanEndDate"))) { subprojectwbs.PlanEndDate = Convert.ToDateTime(subProject.GetValue("PlanEndDate")); } } BuildMajorWBS(subprojectwbs, majorList); } }
/// <summary> /// 递归创建工作包节点 /// </summary> /// <param name="parentWorkNode"></param> /// <param name="parentVirtualNodeID"></param> /// <param name="cwbsList"></param> /// <param name="result"></param> private void createWorkNodes(S_W_WBS parentWorkNode, string parentVirtualNodeID , List <S_W_WBS> cwbsList, List <Dictionary <string, object> > result) { var works = cwbsList.Where(d => d.ParentID == parentWorkNode.ID).ToList(); foreach (var work in works) { var dic = work.ToDic(); var virtualID = FormulaHelper.CreateGuid(); dic.SetValue("VirtualID", virtualID); dic.SetValue("ParentID", parentVirtualNodeID); result.Add(dic); createWorkNodes(work, virtualID, cwbsList, result); } }
/// <summary> /// 根据数据字典保存工作包 /// </summary> /// <param name="dic"></param> /// <param name="parentWBS"></param> internal void SaveTaskWorkByDic(Dictionary <string, object> dic, S_W_WBS parentWBS) { S_W_TaskWork taskWork; if (String.IsNullOrEmpty(dic.GetValue("ID"))) { taskWork = new S_W_TaskWork(); this.UpdateEntity <S_W_TaskWork>(taskWork, dic); parentWBS.AddTaskWork(taskWork); } else { taskWork = this.GetEntityByID <S_W_TaskWork>(dic.GetValue("ID")); this.UpdateEntity <S_W_TaskWork>(taskWork, dic); taskWork.Save(); } }
public VirtualWBS CreateChildNode(S_W_WBS wbs, bool fillPty = false) { if (wbs == null) { var child = new VirtualWBS(); child.VirtualLevel = this.VirtualLevel + 1; child.ParentID = this.VirtualID; return(child); } else { var child = new VirtualWBS(wbs, fillPty); child.VirtualLevel = this.VirtualLevel + 1; child.ParentID = this.VirtualID; return(child); } }
private void FillMileStoneGantList(S_W_WBS relateWBS, List <Dictionary <string, object> > result, List <S_P_MileStone> mileStoneList) { var children = mileStoneList.Where(d => d.WBSID == relateWBS.ID).OrderBy(d => d.PlanFinishDate).ThenBy(d => d.SortIndex).ToList(); for (int i = 0; i < children.Count; i++) { var child = children[i]; var dic = child.ToDic(); dic.SetValue("UID", child.ID); dic.SetValue("MileStoneID", child.ID); dic.SetValue("ParentTaskUID", relateWBS.ID); if (child.PlanStartDate.HasValue) { dic.SetValue("Start", child.PlanStartDate.Value.ToShortDateString() + " 00:00:00"); } else { if (i == 0) { dic.SetValue("Start", GetStartDate(relateWBS)); } else { var preChild = children.Where(a => a.PlanFinishDate < child.PlanFinishDate).OrderByDescending(a => a.PlanFinishDate).FirstOrDefault(); if (preChild == null) { dic.SetValue("Start", GetStartDate(relateWBS)); } else if (preChild.PlanFinishDate.HasValue) { dic.SetValue("Start", (preChild.PlanFinishDate.Value.AddDays(1)).ToShortDateString() + " 00:00:00"); } } } if (child.PlanFinishDate.HasValue) { dic.SetValue("Finish", child.PlanFinishDate.Value.ToShortDateString() + " 23:59:59"); } dic.SetValue("Critical", "1"); result.Add(dic); } }
public VirtualWBS(S_W_WBS wbs, bool fillpty = false) { if (wbs != null) { this.dic = wbs.ToDic(); this.ID = wbs.ID; this.ParentID = ""; this.Name = wbs.Name; this.WBSType = wbs.WBSType; this.Code = wbs.Code; this.WBSValue = wbs.WBSValue; this.FullID = wbs.FullID; if (fillpty) { this.ChargeUserID = wbs.ChargeUserID; this.ChargeUserName = wbs.ChargeUserName; this.PlanStartDate = wbs.PlanStartDate; this.PlanEndDate = wbs.PlanEndDate; } } this.VirtualID = Formula.FormulaHelper.CreateGuid(); }
private string GetStartDate(S_W_WBS node) { var date = ""; if (node.PlanStartDate.HasValue) { date = node.PlanStartDate.Value.ToShortDateString() + " 00:00:00"; } else { if (node.WBSType == WBSNodeType.Project.ToString()) { if (node.S_I_ProjectInfo.PlanStartDate.HasValue) { date = node.S_I_ProjectInfo.PlanStartDate.Value.ToShortDateString() + " 00:00:00"; } } else { date = GetStartDate(node.Parent); } } return(date); }
public void Push(Dictionary <string, string> dic) { var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); var projectInfo = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息"); } var rootWBS = projectInfo.WBSRoot; if (rootWBS == null) { throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。"); } if (!String.IsNullOrEmpty(this.Code)) { projectInfo.Code = this.Code; } if (this.PlanStartDate.HasValue) { projectInfo.PlanStartDate = this.PlanStartDate; } if (this.PlanFinishDate.HasValue) { projectInfo.PlanFinishDate = this.PlanFinishDate; } this.SynchRBSUser(dic); var selectMajorList = this.Major.Split(','); #region 回写专业信息 //移除未选中的专业 var removeMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString() && !selectMajorList.Contains(d.WBSValue)).ToList(); foreach (var item in removeMajorList) { item.Delete(); } var roleDefineList = BaseConfigFO.GetRoleDefineList(); var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major); if (!string.IsNullOrEmpty(this.MajorList)) { var majorNodes = JsonHelper.ToList(this.MajorList); foreach (var item in majorNodes) { var majorCode = item.GetValue("MajorCode"); var attr = majorAttrList.FirstOrDefault(d => d.Code == majorCode); if (attr == null) { throw new Formula.Exceptions.BusinessException("未定义专业【" + majorCode + "】" + item.GetValue("MajorName") + ",操作失败"); } var major = projectInfo.S_W_WBS.FirstOrDefault(d => d.WBSValue == majorCode && d.WBSType == WBSNodeType.Major.ToString()); if (major == null) { major = new S_W_WBS(); major.Name = attr.Name; major.Code = attr.WBSCode; major.WBSValue = attr.Code; major.MajorCode = attr.Code; major.WBSType = WBSNodeType.Major.ToString(); major.SortIndex = attr.SortIndex; projectInfo.WBSRoot.AddChild(major); } else { major.PhaseCode = projectInfo.PhaseValue; } //if (!string.IsNullOrEmpty(item.MajorPrinciple)) // major.SetUsers(ProjectRole.MajorPrinciple.ToString(), item.MajorPrinciple.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.MajorEngineer)) // major.SetUsers(ProjectRole.MajorEngineer.ToString(), item.MajorEngineer.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Designer)) // major.SetUsers(ProjectRole.Designer.ToString(), item.Designer.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Collactor)) // major.SetUsers(ProjectRole.Collactor.ToString(), item.Collactor.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Auditor)) // major.SetUsers(ProjectRole.Auditor.ToString(), item.Auditor.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Approver)) // major.SetUsers(ProjectRole.Approver.ToString(), item.Approver.Split(','), true, true, true, true); var roleList = roleDefineList.Where(a => item.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(item.GetValue(a.RoleCode))); foreach (var roleDef in roleList) { major.SetUsers(roleDef.RoleCode, item.GetValue(roleDef.RoleCode).Split(','), true, true, true, true); } } } var wbsMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString()). Select(d => new { Name = d.Name, Value = d.WBSValue, SortIndex = d.SortIndex }).OrderBy(c => c.SortIndex).ToList(); projectInfo.Major = JsonHelper.ToJson(wbsMajorList); var wonomerList = projectInfo.WBSRoot.S_W_Monomer.ToList(); var userInfo = FormulaHelper.GetUserInfo(); if (wonomerList.Count == 0) { var wonomer = new S_W_Monomer(); wonomer.ID = FormulaHelper.CreateGuid(); wonomer.Name = projectInfo.Name; wonomer.ProjectInfoID = this.ProjectInfoID; wonomer.Code = ""; wonomer.CreateDate = DateTime.Now; wonomer.CreateUser = userInfo.UserName; wonomer.CreateUserID = userInfo.UserID; wonomer.SchemeFormSubID = this.ID; projectInfo.WBSRoot.S_W_Monomer.Add(wonomer); } #endregion var detailMileStoneList = this.T_SC_SingleProjectScheme_MileStoneList.ToList(); #region 除里程碑 var selectCodes = detailMileStoneList.Select(a => a.Code).ToList(); var deleteMileStoneList = projectInfo.S_P_MileStone.Where(a => !selectCodes.Contains(a.Code)).ToList(); foreach (var item in deleteMileStoneList) { item.Delete(); } #endregion #region 更新进度计划 for (int i = 0; i < detailMileStoneList.Count; i++) { var item = detailMileStoneList.ToList()[i]; var mileStone = projectEntities.S_P_MileStone.FirstOrDefault(d => d.Code == item.Code && d.WBSID == projectInfo.WBSRoot.ID && d.ProjectInfoID == this.ProjectInfoID); if (mileStone == null) { mileStone = new S_P_MileStone(); mileStone.ID = FormulaHelper.CreateGuid(); mileStone.Name = item.Name; mileStone.Code = item.Code; mileStone.MileStoneValue = item.Code; mileStone.WBSID = projectInfo.WBSRoot.ID; mileStone.ProjectInfoID = projectInfo.ID; mileStone.OrlPlanFinishDate = item.PlanEndDate; mileStone.S_I_ProjectInfo = projectInfo; } if (mileStone.State == ProjectCommoneState.Finish.ToString()) { continue; } mileStone.PlanFinishDate = item.PlanEndDate; mileStone.Weight = item.Weight; mileStone.MajorValue = item.Major; mileStone.TemplateID = item.TemplateID; mileStone.MileStoneType = item.MileStoneType; mileStone.Name = item.Name; if (projectInfo.ProjectMode.ExtentionObject.GetValue("Ext_MsDataIsFromLastVertion") == TrueOrFalse.True.ToString()) { mileStone.SortIndex = Convert.ToInt32(item.SortIndex.HasValue ? Convert.ToDecimal(item.SortIndex) * 100 : i); } else { var template = projectInfo.ProjectMode.S_T_MileStone.FirstOrDefault(d => d.ID == item.TemplateID); if (template != null) { mileStone.SortIndex = template.SortIndex; } if (!mileStone.SortIndex.HasValue) { mileStone.SortIndex = item.SortIndex.HasValue ? Convert.ToInt32(item.SortIndex) : i; } } mileStone.Description = item.Remark; mileStone.Save(); if (mileStone.MileStoneType == MileStoneType.Cooperation.ToString()) { mileStone.OutMajorValue = item.InMajor; var cooperationPlan = projectEntities.S_P_CooperationPlan.FirstOrDefault(d => d.SchemeWBSID == projectInfo.WBSRoot.ID && d.CooperationValue == mileStone.MileStoneValue); if (cooperationPlan == null) { cooperationPlan = new S_P_CooperationPlan(); cooperationPlan.InMajorValue = item.InMajor; cooperationPlan.OutMajorValue = item.OutMajor; cooperationPlan.MileStoneID = mileStone.ID; cooperationPlan.ID = FormulaHelper.CreateGuid(); cooperationPlan.CooperationContent = mileStone.Name; cooperationPlan.CooperationValue = mileStone.MileStoneValue; cooperationPlan.OrPlanFinishDate = item.PlanEndDate; cooperationPlan.PlanFinishDate = item.PlanEndDate; } if (!cooperationPlan.OrPlanFinishDate.HasValue) { cooperationPlan.OrPlanFinishDate = item.PlanEndDate; } cooperationPlan.PlanFinishDate = item.PlanEndDate; if (projectInfo.WBSRoot != null) { projectInfo.WBSRoot.SaveCooperationPlan(cooperationPlan); } } } #endregion //根据RBS更新OBS projectInfo.ResetOBSUserFromRBS(); projectInfo.State = ProjectCommoneState.Execute.ToString(); }
/// <summary> /// 取本次校审的所有环节 /// </summary> /// <param name="auditForm"></param> /// <returns></returns> public virtual List <AuditStep> GetAuditSteps(Dictionary <string, Dictionary <string, string> > userInfo, List <S_E_Product> productList, S_W_WBS wbs, S_I_ProjectInfo projectInfo) { List <AuditStep> stepList = new List <AuditStep>(); var configInfo = configEnitites.S_C_ProofreadConfiguration.OrderBy(c => c.Level).ToList(); foreach (var config in configInfo) { if (string.IsNullOrEmpty(config.AuditSteps)) { continue; } //只取第一个符合条件的流程 if (IsMatching(config, wbs, projectInfo, productList)) { List <AuditStep> defStepList = GetDefStepList(config, userInfo); return(defStepList); //MergeStepList(stepList, defStepList); } } return(stepList); //return OrderByStep(stepList); }
/// <summary> /// 根据专业同步WBS /// </summary> /// <param name="parentNode"></param> public void SynchMajorWBSNode(List <S_D_RoleDefine> roleDefineList, S_W_WBS parentNode, string rbsList = "") { var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); if (parentNode == null) { throw new Formula.Exceptions.BusinessException("传入的WBS节点为空。"); } var majorList = ""; if (!string.IsNullOrEmpty(rbsList)) { majorList = rbsList; } else { majorList = this.MajorList; } #region 除不需要的专业 //sll edit 2018-8-8 //改前var delMajors = parentNode.Children.Where(d => !this.Major.Contains(d.WBSValue)).ToList(); var delMajors = parentNode.Children.Where(d => !this.Major.Contains(d.WBSValue) && d.WBSType == WBSNodeType.Major.ToString()).ToList(); foreach (var item in delMajors) { item.Delete(); parentNode.Children.Remove(item); } #endregion if (!string.IsNullOrEmpty(majorList)) { var majorNodes = JsonHelper.ToList(majorList); var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major); var majorWBSType = WBSNodeType.Major.ToString(); foreach (var majorNode in majorNodes) { if (majorNode.GetValue("Valid") == "0") { var thisMajorValue = majorNode.GetValue("MajorCode"); var thisMajorNode = parentNode.Children.SingleOrDefault(c => c.WBSValue == thisMajorValue); if (thisMajorNode != null) { thisMajorNode.Delete(); } continue; } var value = majorNode.GetValue("MajorCode"); var majorAttr = majorAttrList.SingleOrDefault(c => c.Code == value); if (majorAttr == null) { continue; } var childNode = parentNode.Children.SingleOrDefault(c => c.WBSValue == value); if (!this.Major.Split(',').Contains(value)) { if (childNode != null) { childNode.Delete(); } continue; } if (childNode == null) { childNode = projectEntities.Set <S_W_WBS>().Create(); if (string.IsNullOrEmpty(childNode.ID)) { childNode.ID = FormulaHelper.CreateGuid(); } childNode._state = EntityState.Added.ToString(); childNode.WBSType = majorWBSType; childNode.Name = majorAttr.Name; childNode.WBSValue = majorAttr.Code; childNode.MajorCode = majorAttr.Code; childNode.Code = majorAttr.WBSCode; } childNode.SortIndex = majorAttr.SortIndex; childNode.ChargeUserID = majorNode.GetValue("MajorPrinciple"); childNode.ChargeUserName = majorNode.GetValue("MajorPrincipleName"); if (childNode._state == EntityState.Added.ToString()) { parentNode.AddChild(childNode); } #region 步设校审人员信息 var roleList = roleDefineList.Where(a => majorNode.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(majorNode.GetValue(a.RoleCode))); foreach (var roleDef in roleList) { childNode.SetUsers(roleDef.RoleCode, majorNode.GetValue(roleDef.RoleCode).Split(','), true, false, true, true); } #endregion } } }
public void BuildMajorWBS(S_W_WBS majorParentWBS, List <Dictionary <string, object> > majorList) { if (majorList == null || majorList.Count <= 0) { return; } var majorEnum = BaseConfigFO.GetWBSEnum(WBSNodeType.Major) .AsEnumerable() .Select(c => new DicItem { Text = c["text"].ToString(), Value = c["value"].ToString() }).ToList(); var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major.ToString()); foreach (var major in majorList) { var mCode = major.GetValue("Major").ToString(); S_W_WBS majorwbs = majorParentWBS.AllChildren.FirstOrDefault(c => c.WBSValue == mCode); if (majorwbs == null) { #region 新增 majorwbs = new S_W_WBS { WBSType = WBSNodeType.Major.ToString(), Name = majorEnum.FirstOrDefault(c => c.Value == mCode).Text, WBSValue = mCode //Code = mCode, }; var attrDefine = majorAttrList.FirstOrDefault(d => d.Code == majorwbs.WBSValue); if (attrDefine != null) { majorwbs.SortIndex = attrDefine.SortIndex; } majorParentWBS.AddChild(majorwbs); #endregion } else { majorwbs.Name = majorEnum.FirstOrDefault(c => c.Value == mCode).Text; var attrDefine = majorAttrList.FirstOrDefault(d => d.Code == majorwbs.WBSValue); if (attrDefine != null) { majorwbs.SortIndex = attrDefine.SortIndex; } } if (!String.IsNullOrEmpty(major.GetValue("MajorPrincipleID"))) { majorwbs.SetUsers(ProjectRole.MajorPrinciple.ToString(), major.GetValue("MajorPrincipleID").ToString().Split(',')); } if (!String.IsNullOrEmpty(major.GetValue("DesignID"))) { majorwbs.SetUsers(ProjectRole.Designer.ToString(), major.GetValue("DesignID").Split(',')); } if (!String.IsNullOrEmpty(major.GetValue("CollactorID"))) { majorwbs.SetUsers(ProjectRole.Collactor.ToString(), major.GetValue("CollactorID").Split(',')); } if (!String.IsNullOrEmpty(major.GetValue("AuditorID"))) { majorwbs.SetUsers(ProjectRole.Auditor.ToString(), major.GetValue("AuditorID").Split(',')); } if (!String.IsNullOrEmpty(major.GetValue("CheckID"))) { majorwbs.SetUsers(ProjectRole.Approver.ToString(), major.GetValue("CheckID").Split(',')); } } }
public virtual bool IsMatching(S_C_ProofreadConfiguration auditConfig, S_W_WBS wbs, S_I_ProjectInfo projectInfo, List <S_E_Product> productList) { if (string.IsNullOrEmpty(auditConfig.AuditParams)) { return(true); } List <AuditConfigParam> list = JsonHelper.ToObject <List <AuditConfigParam> >(auditConfig.AuditParams); bool isTure = true; var taskWork = wbs.S_W_TaskWork.FirstOrDefault(); foreach (var param in list) { //如果值空,忽略此条件 if (string.IsNullOrEmpty(param.PropertyKey)) { continue; } Type t = Type.GetType("Project.Logic.Domain." + param.TableKey); if (t == null) { return(false); } PropertyInfo pi = t.GetProperty(param.ColumnKey); if (pi == null) { return(false); } switch (param.TableKey) { case "S_I_ProjectInfo": string value = (string)pi.GetValue(projectInfo, null); if (value == null || !param.PropertyKey.Split(',').Contains(value)) { return(false); } break; case "S_W_TaskWork": //var taskWork = wbs.S_W_TaskWork.FirstOrDefault(); if (taskWork == null) { return(false); } value = (string)pi.GetValue(taskWork, null); if (value == null || !param.PropertyKey.Split(',').Contains(value)) { return(false); } break; case "S_E_Product": bool exists = false; foreach (var product in productList) { value = (string)pi.GetValue(product, null); if (value != null && param.PropertyKey.Split(',').Contains(value)) { exists = true; break; } } if (!exists) { return(false); } break; } } return(isTure); }
/// <summary> /// 根据阶段、子项信息、专业信息同步WBS节点 /// </summary> public void SynchWBSNode(Dictionary <string, string> dic, S_W_WBS rootWBS = null) { var enumService = FormulaHelper.GetService <IEnumService>(); var userInfo = FormulaHelper.GetUserInfo(); var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); var projectInfo = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息"); } if (rootWBS == null) { //获取项目信息 rootWBS = projectInfo.WBSRoot; if (rootWBS == null) { throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。"); } } var detailList = this.T_SC_SchemeForm_OEM_Szsow_SubProjectList.OrderBy(d => d.SortIndex).ToList(); var roleDefineList = BaseConfigFO.GetRoleDefineList(); var phaseWBSes = rootWBS.Children.ToList(); var phaseAttrs = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase); foreach (var phaseValue in projectInfo.PhaseValue.Split(',')) { #region 阶段节点 var phaseName = enumService.GetEnumText("Project.Phase", phaseValue); var attr = phaseAttrs.FirstOrDefault(a => a.Code == phaseValue); if (attr == null) { throw new Formula.Exceptions.BusinessException("未定义阶段【" + phaseValue + "】" + phaseName + ",操作失败"); } var phaseWBSNode = phaseWBSes.FirstOrDefault(d => d.WBSValue == phaseValue && d.WBSType == WBSNodeType.Phase.ToString()); if (phaseWBSNode == null) { phaseWBSNode = new S_W_WBS(); phaseWBSNode.ID = FormulaHelper.CreateGuid(); phaseWBSNode.WBSType = WBSNodeType.Phase.ToString(); phaseWBSNode.Name = phaseName; phaseWBSNode.Code = attr.WBSCode; phaseWBSNode.WBSValue = attr.Code; rootWBS.AddChild(phaseWBSNode); } else { phaseWBSNode.Name = phaseName; phaseWBSNode.Code = attr.WBSCode; phaseWBSNode.WBSValue = attr.Code; phaseWBSNode.Save(); phaseWBSes.Remove(phaseWBSNode); } #endregion #region 子项节点 var subwbses = phaseWBSNode.Children.ToList(); foreach (var subProject in detailList.Where(a => a.PhaseValue.Split(',').Contains(phaseValue)).ToList()) { var subWBSNode = subwbses.FirstOrDefault(d => d.WBSValue == subProject.Code && d.WBSType == WBSNodeType.SubProject.ToString()); if (subWBSNode == null) { subWBSNode = new S_W_WBS(); subWBSNode.ID = FormulaHelper.CreateGuid(); subWBSNode.WBSType = WBSNodeType.SubProject.ToString(); subWBSNode.Name = subProject.Name; subWBSNode.Code = ""; subWBSNode.WBSValue = subProject.Code; subWBSNode.ExtField1 = subProject.Area.HasValue ? subProject.Area.ToString() : ""; subWBSNode.ExtField2 = subProject.Unit; phaseWBSNode.AddChild(subWBSNode); } else { subWBSNode.Name = subProject.Name; subWBSNode.WBSValue = subProject.Code; subWBSNode.ExtField1 = subProject.Area.HasValue ? subProject.Area.ToString() : ""; subWBSNode.ExtField2 = subProject.Unit; subWBSNode.Save(); subwbses.Remove(subWBSNode); } subProject.PhaseWBSID = phaseWBSNode.ID; #region 新增单体 var wonomerList = subWBSNode.S_W_Monomer.ToList(); if (String.IsNullOrEmpty(subProject.Unit)) { var wonomer = wonomerList.FirstOrDefault(d => d.Name == subProject.Name); if (wonomer == null) { wonomer = new S_W_Monomer(); wonomer.ID = FormulaHelper.CreateGuid(); wonomer.Name = subProject.Name; wonomer.ProjectInfoID = this.ProjectInfoID; wonomer.Code = ""; wonomer.CreateDate = DateTime.Now; wonomer.CreateUser = userInfo.UserName; wonomer.CreateUserID = userInfo.UserID; wonomer.SchemeFormSubID = this.ID; subWBSNode.S_W_Monomer.Add(wonomer); } } else if (!string.IsNullOrEmpty(subProject.Name)) { foreach (var item in subProject.Unit.Replace(",", ",").Split(',')) { var wonomer = subWBSNode.S_W_Monomer.FirstOrDefault(d => d.Name == item); if (wonomer == null) { wonomer = new S_W_Monomer(); wonomer.ID = FormulaHelper.CreateGuid(); wonomer.Name = item; wonomer.ProjectInfoID = this.ProjectInfoID; wonomer.Code = ""; wonomer.CreateDate = DateTime.Now; wonomer.CreateUser = userInfo.UserName; wonomer.CreateUserID = userInfo.UserID; wonomer.SchemeFormSubID = this.ID; subWBSNode.S_W_Monomer.Add(wonomer); } else { wonomerList.Remove(wonomer); } } } foreach (var delWonomer in wonomerList) //移除不需要的单体 { projectEntities.S_W_Monomer.Remove(delWonomer); } #endregion //增加名称判断逻辑 if (string.IsNullOrEmpty(subProject.Name)) { //将空名子项的专业挂到阶段下 SynchMajorWBSNode(roleDefineList, subWBSNode.Parent, subProject.RBSJson); //删除空名子项 subWBSNode.Delete(); //排除在阶段下的专业 var rbsDicList = JsonHelper.ToList(subProject.RBSJson ?? MajorList); subwbses.RemoveAll(a => rbsDicList.Any(b => a.WBSValue == b.GetValue("MajorCode"))); } else { subProject.SubProjectWBSID = subWBSNode.ID; SynchMajorWBSNode(roleDefineList, subWBSNode, subProject.RBSJson); } //this.InitMileStone(subWBSNode); } #endregion //删除阶段节点下多余的子项和专业 subwbses.ForEach(t => { if (t.WBSType == WBSNodeType.Major.ToString()) { //删除阶段下层专业时,同时删除挂在阶段下的专业计划、发图计划 projectEntities.Set <S_P_MileStone>().Delete(d => d.WBSID == phaseWBSNode.ID && d.MajorValue == t.WBSValue); } t.Delete(); }); } phaseWBSes.ForEach(t => t.Delete()); //删除多余的阶段 this.SubProjectList = JsonHelper.ToJson <List <T_SC_SchemeForm_OEM_Szsow_SubProjectList> >(detailList); }
/// <summary> /// 根据子项和专业列表同步WBS表 /// </summary> public void SynchSubProjectWBSNode(Dictionary <string, string> dic, S_W_WBS rootWBS = null) { var userInfo = FormulaHelper.GetUserInfo(); var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); var projectInfo = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息"); } if (rootWBS == null) { //获取项目信息 rootWBS = projectInfo.WBSRoot; if (rootWBS == null) { throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。"); } } var roleDefineList = BaseConfigFO.GetRoleDefineList(); var enumSubProject = WBSNodeType.SubProject.ToString(); var subwbses = rootWBS.Children.ToList(); if (this.T_SC_MixProjectScheme_SubProjectList.ToList().Count == 0) { SynchMajorWBSNode(roleDefineList, rootWBS, ""); subwbses.RemoveWhere(a => a.WBSType == WBSNodeType.Major.ToString()); } foreach (var subProject in this.T_SC_MixProjectScheme_SubProjectList.OrderBy(d => d.SortIndex).ToList()) { var subWBSNode = subwbses.FirstOrDefault(d => d.WBSValue == subProject.Code && d.WBSType == WBSNodeType.SubProject.ToString()); if (subWBSNode == null) { subWBSNode = new S_W_WBS(); subWBSNode.ID = FormulaHelper.CreateGuid(); subWBSNode.WBSType = WBSNodeType.SubProject.ToString(); subWBSNode.Name = subProject.Name; subWBSNode.Code = ""; subWBSNode.WBSValue = subProject.Code; subWBSNode.PhaseCode = subProject.PhaseValue; subWBSNode.ExtField1 = subProject.Area.HasValue ? subProject.Area.ToString() : ""; subWBSNode.ExtField2 = subProject.Unit; rootWBS.AddChild(subWBSNode); } else { subWBSNode.Name = subProject.Name; subWBSNode.PhaseCode = subProject.PhaseValue; subWBSNode.ExtField1 = subProject.Area.HasValue ? subProject.Area.ToString() : ""; subWBSNode.ExtField2 = subProject.Unit; subWBSNode.Save(); subwbses.Remove(subWBSNode); } #region 新增单体 var wonomerList = subWBSNode.S_W_Monomer.ToList(); if (String.IsNullOrEmpty(subProject.Unit)) { var wonomer = wonomerList.FirstOrDefault(d => d.Name == subProject.Name); if (wonomer == null) { wonomer = new S_W_Monomer(); wonomer.ID = FormulaHelper.CreateGuid(); wonomer.Name = subProject.Name; wonomer.ProjectInfoID = this.ProjectInfoID; wonomer.Code = ""; wonomer.CreateDate = DateTime.Now; wonomer.CreateUser = userInfo.UserName; wonomer.CreateUserID = userInfo.UserID; wonomer.SchemeFormSubID = this.ID; subWBSNode.S_W_Monomer.Add(wonomer); } } else { foreach (var item in subProject.Unit.Replace(",", ",").Split(',')) { var wonomer = subWBSNode.S_W_Monomer.FirstOrDefault(d => d.Name == item); if (wonomer == null) { wonomer = new S_W_Monomer(); wonomer.ID = FormulaHelper.CreateGuid(); wonomer.Name = item; wonomer.ProjectInfoID = this.ProjectInfoID; wonomer.Code = ""; wonomer.CreateDate = DateTime.Now; wonomer.CreateUser = userInfo.UserName; wonomer.CreateUserID = userInfo.UserID; wonomer.SchemeFormSubID = this.ID; subWBSNode.S_W_Monomer.Add(wonomer); } else { wonomerList.Remove(wonomer); } } } foreach (var delWonomer in wonomerList) //移除不需要的单体 { projectEntities.S_W_Monomer.Remove(delWonomer); } #endregion SynchMajorWBSNode(roleDefineList, subWBSNode, subProject.RBSJson); //this.InitMileStone(subWBSNode); } subwbses.ForEach(t => t.Delete()); //删除多余的子项 }
public void Push(Dictionary <string, string> dic) { var projectEntities = FormulaHelper.GetEntities <ProjectEntities>(); var projectInfo = projectEntities.Set <S_I_ProjectInfo>().Find(this.ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("根据当前项目策划单,未找到对应的项目信息"); } var rootWBS = projectInfo.WBSRoot; if (rootWBS == null) { throw new Formula.Exceptions.BusinessException("未获取到当前项目的WBS根节点。"); } if (!String.IsNullOrEmpty(this.Code)) { projectInfo.Code = this.Code; } if (this.PlanStartDate.HasValue) { projectInfo.PlanStartDate = this.PlanStartDate; } if (this.PlanFinishDate.HasValue) { projectInfo.PlanFinishDate = this.PlanFinishDate; } this.SynchRBSUser(dic); var selectMajorList = this.Major.Split(','); #region 更新预留工时、管理工时CBS var cbsRoot = projectInfo.CBSRoot; var nodeType = CBSNodeType.Category.ToString(); var categoryType = CBSCategoryType.Reserve.ToString(); var enums = EnumBaseHelper.GetEnumDef(typeof(CBSCategoryType)); //预留工时 var reserveCBS = cbsRoot.Children.FirstOrDefault(d => d.NodeType == nodeType && d.Code == categoryType); if (reserveCBS == null) { reserveCBS = new S_C_CBS(); reserveCBS.Name = enums.EnumItem.FirstOrDefault(a => a.Code == categoryType).Name; reserveCBS.Code = categoryType; reserveCBS.NodeType = nodeType; reserveCBS.CBSType = CBSType.LabourExpense.ToString(); reserveCBS.SortIndex = 0; reserveCBS.CreateUserID = this.CreateUserID; reserveCBS.CreateUser = this.CreateUser; cbsRoot.AddChild(reserveCBS); } reserveCBS.Quantity = this.ReserveWorkload ?? 0; reserveCBS.TotalPrice = reserveCBS.Quantity.Value * reserveCBS.UnitPrice.Value; //管理工时 categoryType = CBSCategoryType.Manage.ToString(); var manageCBS = cbsRoot.Children.FirstOrDefault(d => d.NodeType == nodeType && d.Code == categoryType); if (manageCBS == null) { manageCBS = new S_C_CBS(); manageCBS.Name = enums.EnumItem.FirstOrDefault(a => a.Code == categoryType).Name; manageCBS.Code = categoryType; manageCBS.NodeType = nodeType; manageCBS.CBSType = CBSType.LabourExpense.ToString(); manageCBS.SortIndex = 1; manageCBS.CreateUserID = this.CreateUserID; manageCBS.CreateUser = this.CreateUser; cbsRoot.AddChild(manageCBS); } //删除不存在的 var subManageWorkloadList = this.T_SC_ElectricalPowerProjectScheme_ManageWorkloadList.ToList(); var removeManageList = manageCBS.Children.Where(d => !subManageWorkloadList.Select(a => a.Item).Contains(d.Code)).ToList(); foreach (var item in removeManageList) { item.Delete(); } foreach (var item in subManageWorkloadList) { var _mcbs = manageCBS.Children.FirstOrDefault(a => a.Code == item.Item); if (_mcbs == null) { _mcbs = new S_C_CBS(); _mcbs.Name = item.ItemName; _mcbs.Code = item.Item; _mcbs.NodeType = CBSNodeType.CBS.ToString(); _mcbs.CBSType = CBSType.LabourExpense.ToString(); _mcbs.SortIndex = item.SortIndex; _mcbs.CreateUserID = this.CreateUserID; _mcbs.CreateUser = this.CreateUser; manageCBS.AddChild(_mcbs); } else { _mcbs.ModifyUserID = this.CreateUserID; _mcbs.ModifyUser = this.CreateUser; _mcbs.ModifyDate = DateTime.Now; } _mcbs.Quantity = item.ManageWorkload ?? 0; _mcbs.TotalPrice = _mcbs.Quantity.Value * _mcbs.UnitPrice.Value; } manageCBS.SummayQuantity(); #endregion var ProjectTaskWorkList = new List <S_W_TaskWork>(); var DetailTaskWorkList = this.T_SC_ElectricalPowerProjectScheme_TaskWorkList.ToList(); #region 除卷册 if (!string.IsNullOrEmpty(this.TaskWorkList)) { var selectids = DetailTaskWorkList.Select(a => a.TaskWorkID).ToList(); ProjectTaskWorkList = projectEntities.Set <S_W_TaskWork>().Where(a => a.ProjectInfoID == projectInfo.ID).ToList(); var deleteList = ProjectTaskWorkList.Where(a => !selectids.Contains(a.ID)).ToList(); foreach (var item in deleteList) { item.Delete(); ProjectTaskWorkList.Remove(item); } } #endregion #region 回写专业信息,专业工时CBS //移除未选中的专业 var removeMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString() && !selectMajorList.Contains(d.WBSValue)).ToList(); foreach (var item in removeMajorList) { item.Delete(); } #region 专业工时 categoryType = CBSCategoryType.Product.ToString(); var productCBS = cbsRoot.Children.FirstOrDefault(d => d.NodeType == nodeType && d.Code == categoryType); if (productCBS == null) { productCBS = new S_C_CBS(); productCBS.Name = enums.EnumItem.FirstOrDefault(a => a.Code == categoryType).Name; productCBS.Code = categoryType; productCBS.NodeType = nodeType; productCBS.CBSType = CBSType.LabourExpense.ToString(); productCBS.SortIndex = 2; productCBS.CreateUserID = this.CreateUserID; productCBS.CreateUser = this.CreateUser; cbsRoot.AddChild(productCBS); } //删除不存在的 var removeMajorWorkloadList = productCBS.Children.Where(d => !selectMajorList.Contains(d.Code)).ToList(); foreach (var item in removeMajorWorkloadList) { item.Delete(); } #endregion var roleDefineList = BaseConfigFO.GetRoleDefineList(); var majorAttrList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Major); if (!string.IsNullOrEmpty(this.MajorList)) { var majorNodes = JsonHelper.ToList(this.MajorList); foreach (var item in majorNodes) { var majorCode = item.GetValue("MajorCode"); var majorName = item.GetValue("MajorName"); var attr = majorAttrList.FirstOrDefault(d => d.Code == majorCode); if (attr == null) { throw new Formula.Exceptions.BusinessException("未定义专业【" + majorCode + "】" + majorName + ",操作失败"); } var major = projectInfo.S_W_WBS.FirstOrDefault(d => d.WBSValue == majorCode && d.WBSType == WBSNodeType.Major.ToString()); if (major == null) { major = new S_W_WBS(); major.Name = attr.Name; major.Code = attr.WBSCode; major.WBSValue = attr.Code; major.WBSType = WBSNodeType.Major.ToString(); major.SortIndex = attr.SortIndex; projectInfo.WBSRoot.AddChild(major); } //if (!string.IsNullOrEmpty(item.MajorPrinciple)) // major.SetUsers(ProjectRole.MajorPrinciple.ToString(), item.MajorPrinciple.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.MajorEngineer)) // major.SetUsers(ProjectRole.MajorEngineer.ToString(), item.MajorEngineer.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Designer)) // major.SetUsers(ProjectRole.Designer.ToString(), item.Designer.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Collactor)) // major.SetUsers(ProjectRole.Collactor.ToString(), item.Collactor.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Auditor)) // major.SetUsers(ProjectRole.Auditor.ToString(), item.Auditor.Split(','), true, true, true, true); //if (!string.IsNullOrEmpty(item.Approver)) // major.SetUsers(ProjectRole.Approver.ToString(), item.Approver.Split(','), true, true, true, true); var roleList = roleDefineList.Where(a => item.ContainsKey(a.RoleCode) && !string.IsNullOrEmpty(item.GetValue(a.RoleCode))); foreach (var roleDef in roleList) { major.SetUsers(roleDef.RoleCode, item.GetValue(roleDef.RoleCode).Split(','), true, true, true, true); } #region 卷册 if (!string.IsNullOrEmpty(this.TaskWorkList)) { var list = DetailTaskWorkList.Where(a => a.Major == major.WBSValue).ToList(); foreach (var detail in list) { var task = ProjectTaskWorkList.FirstOrDefault(a => a.ID == detail.TaskWorkID); if (task == null) { task = new S_W_TaskWork(); task.State = TaskWorkState.Plan.ToString(); } task.Name = detail.Name; task.Code = detail.Code; task.MajorValue = detail.Major; task.PhaseValue = detail.Phase; if (string.IsNullOrEmpty(task.ID)) { task.ID = detail.TaskWorkID; //根据专业同步人员 task.FillWBSUser(major); major.AddTaskWork(task); } else { task.Save(); } task.DossierCode = detail.DossierCode; task.DossierName = detail.DossierName; task.S_W_WBS.PhaseCode = task.PhaseValue; //修改成果的阶段、专业、卷号 foreach (var product in task.S_W_WBS.S_E_Product.ToList()) { product.PhaseValue = task.PhaseValue; product.MajorValue = task.MajorValue; product.MonomerCode = task.DossierCode; product.MonomerInfo = task.DossierName; product.PackageCode = task.Code; product.PackageName = task.Name; } if (task.Version == null) { task.Version = 1; } } } #endregion #region 专业工时CBS数据 var _mcbs = productCBS.Children.FirstOrDefault(a => a.Code == majorCode); if (_mcbs == null) { _mcbs = new S_C_CBS(); _mcbs.Name = majorName; _mcbs.Code = majorCode; _mcbs.NodeType = CBSNodeType.Major.ToString(); _mcbs.CBSType = CBSType.LabourExpense.ToString(); _mcbs.SortIndex = 0; if (!string.IsNullOrEmpty(item.GetValue("SortIndex"))) { _mcbs.SortIndex = Convert.ToDouble(item.GetValue("SortIndex")); } _mcbs.CreateUserID = this.CreateUserID; _mcbs.CreateUser = this.CreateUser; productCBS.AddChild(_mcbs); } else { _mcbs.ModifyUserID = this.CreateUserID; _mcbs.ModifyUser = this.CreateUser; _mcbs.ModifyDate = DateTime.Now; } _mcbs.Quantity = 0; if (!string.IsNullOrEmpty(item.GetValue("MajorWorkload"))) { _mcbs.Quantity = Convert.ToDecimal(item.GetValue("MajorWorkload")); } _mcbs.TotalPrice = _mcbs.Quantity.Value * _mcbs.UnitPrice.Value; #endregion } } productCBS.SummayQuantity(); var wbsMajorList = projectInfo.S_W_WBS.Where(d => d.WBSType == WBSNodeType.Major.ToString()). Select(d => new { Name = d.Name, Value = d.WBSValue, SortIndex = d.SortIndex }).OrderBy(c => c.SortIndex).ToList(); projectInfo.Major = JsonHelper.ToJson(wbsMajorList); var wonomerList = projectInfo.WBSRoot.S_W_Monomer.ToList(); var userInfo = FormulaHelper.GetUserInfo(); if (wonomerList.Count == 0) { var wonomer = new S_W_Monomer(); wonomer.ID = FormulaHelper.CreateGuid(); wonomer.Name = projectInfo.Name; wonomer.ProjectInfoID = this.ProjectInfoID; wonomer.Code = ""; wonomer.CreateDate = DateTime.Now; wonomer.CreateUser = userInfo.UserName; wonomer.CreateUserID = userInfo.UserID; wonomer.SchemeFormSubID = this.ID; projectInfo.WBSRoot.S_W_Monomer.Add(wonomer); } #endregion var detailMileStoneList = this.T_SC_ElectricalPowerProjectScheme_MileStoneList.ToList(); #region 除里程碑 var selectCodes = detailMileStoneList.Select(a => a.Code).ToList(); var deleteMileStoneList = projectInfo.S_P_MileStone.Where(a => !selectCodes.Contains(a.Code)).ToList(); foreach (var item in deleteMileStoneList) { item.Delete(); } #endregion #region 更新进度计划 for (int i = 0; i < detailMileStoneList.Count; i++) { var item = detailMileStoneList.ToList()[i]; var mileStone = projectEntities.S_P_MileStone.FirstOrDefault(d => d.Code == item.Code && d.WBSID == projectInfo.WBSRoot.ID && d.ProjectInfoID == this.ProjectInfoID); if (mileStone == null) { mileStone = new S_P_MileStone(); mileStone.ID = FormulaHelper.CreateGuid(); mileStone.Name = item.Name; mileStone.Code = item.Code; mileStone.MileStoneValue = item.Code; mileStone.WBSID = projectInfo.WBSRoot.ID; mileStone.ProjectInfoID = projectInfo.ID; mileStone.OrlPlanFinishDate = item.PlanEndDate; mileStone.S_I_ProjectInfo = projectInfo; } if (mileStone.State == ProjectCommoneState.Finish.ToString()) { continue; } mileStone.PlanFinishDate = item.PlanEndDate; mileStone.Weight = item.Weight; mileStone.MajorValue = item.Major; mileStone.TemplateID = item.TemplateID; mileStone.MileStoneType = item.MileStoneType; mileStone.Name = item.Name; if (projectInfo.ProjectMode.ExtentionObject.GetValue("Ext_MsDataIsFromLastVertion") == TrueOrFalse.True.ToString()) { mileStone.SortIndex = Convert.ToInt32(item.SortIndex.HasValue ? Convert.ToDecimal(item.SortIndex) * 100 : i); } else { var template = projectInfo.ProjectMode.S_T_MileStone.FirstOrDefault(d => d.ID == item.TemplateID); if (template != null) { mileStone.SortIndex = template.SortIndex; } if (!mileStone.SortIndex.HasValue) { mileStone.SortIndex = item.SortIndex.HasValue ? Convert.ToInt32(item.SortIndex) : i; } } mileStone.Description = item.Remark; mileStone.Save(); if (mileStone.MileStoneType == MileStoneType.Cooperation.ToString()) { mileStone.OutMajorValue = item.InMajor; var cooperationPlan = projectEntities.S_P_CooperationPlan.FirstOrDefault(d => d.SchemeWBSID == projectInfo.WBSRoot.ID && d.CooperationValue == mileStone.MileStoneValue); if (cooperationPlan == null) { cooperationPlan = new S_P_CooperationPlan(); cooperationPlan.InMajorValue = item.InMajor; cooperationPlan.OutMajorValue = item.OutMajor; cooperationPlan.MileStoneID = mileStone.ID; cooperationPlan.ID = FormulaHelper.CreateGuid(); cooperationPlan.CooperationContent = mileStone.Name; cooperationPlan.CooperationValue = mileStone.MileStoneValue; cooperationPlan.OrPlanFinishDate = item.PlanEndDate; cooperationPlan.PlanFinishDate = item.PlanEndDate; } if (!cooperationPlan.OrPlanFinishDate.HasValue) { cooperationPlan.OrPlanFinishDate = item.PlanEndDate; } cooperationPlan.PlanFinishDate = item.PlanEndDate; if (projectInfo.WBSRoot != null) { projectInfo.WBSRoot.SaveCooperationPlan(cooperationPlan); } } } #endregion //根据RBS更新OBS projectInfo.ResetOBSUserFromRBS(); projectInfo.State = ProjectCommoneState.Execute.ToString(); }
/// <summary> /// 获取校审流程启动参数 /// </summary> /// <param name="auditForm"></param> /// <param name="auditFormUrl"></param> /// <param name="stepList"></param> /// <returns></returns> public virtual AuditFlowStartParam GetAuditFlowStartParam(T_AE_Audit auditForm, string auditFormUrl, List <S_E_Product> productList, S_W_WBS wbs, S_I_ProjectInfo projectInfo) { var startParam = new AuditFlowStartParam(); startParam.DisplayName = EnumBaseHelper.GetEnumDescription(typeof(ActivityType), ActivityType.Design.ToString()) + "(" + auditForm.Name + ")"; startParam.AuditFormUrl = auditFormUrl; startParam.AuditFormID = auditForm.ID; startParam.WBSID = auditForm.WBSID; //参与校审的人员 var userInfo = GetAuditRoleUser(auditForm.WBSID); //本次校审的环节 var stepList = GetAuditSteps(userInfo, productList, wbs, projectInfo); foreach (var auditStep in stepList) { startParam.AddStep(auditStep); } return(startParam); }