Dictionary <string, object> fillDicWithWBS(S_I_WBS item)
        {
            var dic = new Dictionary <string, object>();

            dic.SetValue("ID", item.ID);
            dic.SetValue("ParentID", item.ParentID);
            dic.SetValue("FullID", item.FullID);
            dic.SetValue("Value", item.Value);
            dic.SetValue("Name", item.Name);
            dic.SetValue("WBSID", item.ID);
            dic.SetValue("NodeType", item.NodeType);
            dic.SetValue("SortIndex", item.SortIndex);
            dic.SetValue("TaskID", "");
            if (item.S_I_Engineering.S_R_Resource.Count(c => c.WBSID == item.ID && c.ResourceID == this.CurrentUserInfo.UserID &&
                                                        !String.IsNullOrEmpty(c.RoleCode) && String.IsNullOrEmpty(c.TaskID)) > 0)
            {
                dic.SetValue("InUser", true.ToString());
                var roleCodes = item.S_I_Engineering.S_R_Resource.Where(c => c.WBSID == item.ID && c.ResourceID == this.CurrentUserInfo.UserID &&
                                                                        !String.IsNullOrEmpty(c.RoleCode) && String.IsNullOrEmpty(c.TaskID)).Select(c => c.RoleCode).ToList();
                dic.SetValue("RoleCode", String.Join(",", roleCodes));
            }
            else
            {
                dic.SetValue("InUser", false.ToString());
                dic.SetValue("RoleCode", "");
            }
            return(dic);
        }
Example #2
0
        public JsonResult AddChildWithDefAttr(string Children)
        {
            var    dic       = JsonHelper.ToObject(Children);
            string parentIDs = dic["ParentIDs"].ToString();
            string children  = string.Empty;

            if (dic.ContainsKey("childNodes"))
            {
                children = dic["childNodes"].ToString();
            }
            if (dic.ContainsKey("allChildNodes"))
            {
                children = dic["allChildNodes"].ToString();
            }
            string type   = dic["Type"].ToString();
            var    list   = BaseConfigFO.GetWBSAttrList(type);
            var    result = new List <S_W_WBS>();
            //EPCWBS信息
            var epcEntities = FormulaHelper.GetEntities <EPCEntities>();

            foreach (var parentID in parentIDs.TrimEnd(',').Split(','))
            {
                var parent = this.GetEntityByID <S_W_WBS>(parentID);
                if (parent == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }
                var epcParentWBSNode = epcEntities.Set <S_I_WBS>().Find(parentID);
                if (epcParentWBSNode == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }
                foreach (var item in children.Split(','))
                {
                    var attrDefine = list.FirstOrDefault(d => d.Code == item);
                    if (attrDefine == null)
                    {
                        continue;
                    }
                    var wbs = new S_W_WBS();
                    wbs.WBSType   = dic["Type"].ToString();
                    wbs.Name      = attrDefine.Name;
                    wbs.SortIndex = attrDefine.SortIndex;
                    wbs.WBSValue  = item;
                    result.Add(parent.AddChild(wbs));
                    var epcWBS = new S_I_WBS();
                    epcWBS.NodeType  = dic["Type"].ToString();
                    epcWBS.Name      = attrDefine.Name;
                    epcWBS.SortIndex = attrDefine.SortIndex;
                    epcWBS.Value     = item;
                    epcWBS.ID        = wbs.ID;
                    epcParentWBSNode.AddChild(epcWBS, true, true);
                }
            }
            this.entities.SaveChanges();
            epcEntities.SaveChanges();
            return(Json(result));
        }
Example #3
0
        Dictionary <string, object> fillDicWithWBS(S_I_WBS item)
        {
            var dic = new Dictionary <string, object>();

            dic.SetValue("ID", item.ID);
            dic.SetValue("ParentID", item.ParentID);
            dic.SetValue("FullID", item.FullID);
            dic.SetValue("Value", item.Value);
            dic.SetValue("Name", item.Name);
            dic.SetValue("WBSID", item.ID);
            dic.SetValue("NodeType", item.NodeType);
            dic.SetValue("SortIndex", item.SortIndex);
            dic.SetValue("TaskID", "");
            dic.SetValue("DrawingCount", this.entities.Set <S_E_DrawingResult>().Count(c => c.TaskID == item.ID));
            return(dic);
        }
Example #4
0
        public JsonResult AddChild(string parentIDs, string Children, string WBSType)
        {
            var result           = new List <S_W_WBS>();
            var list             = JsonHelper.ToList(Children);
            var majorType        = WBSNodeType.Major.ToString();
            var majorWBSAttrList = BaseConfigFO.GetWBSAttrList(majorType);
            //EPCWBS信息
            var epcEntities = FormulaHelper.GetEntities <EPCEntities>();

            foreach (var parentID in parentIDs.TrimEnd(',').Split(','))
            {
                var parent = this.GetEntityByID <S_W_WBS>(parentID);
                if (parent == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }

                var epcParentWBSNode = epcEntities.Set <S_I_WBS>().Find(parentID);
                if (epcParentWBSNode == null)
                {
                    throw new Formula.Exceptions.BusinessException("未能找到ID为【" + parentID + "】的WBS节点,无法增加子节点");
                }

                var rbsList = parent.S_W_RBS.ToList();
                foreach (var item in list)
                {
                    var wbs = new S_W_WBS();
                    this.UpdateEntity <S_W_WBS>(wbs, item);
                    var subEntityNode = parent.AddChild(wbs, true, true);
                    result.Add(subEntityNode);

                    var epcWBS = new S_I_WBS();
                    this.UpdateEntity <S_I_WBS>(epcWBS, item);
                    epcWBS.NodeType = WBSNodeType.SubProject.ToString();
                    epcWBS.ID       = wbs.ID;
                    var epcSubProjectNode = epcParentWBSNode.AddChild(epcWBS, true, false);

                    var majorCodes = item.GetValue("MajorCode");
                    if (!string.IsNullOrWhiteSpace(majorCodes))
                    {
                        foreach (var majorCode in majorCodes.Split(','))
                        {
                            var majorAttrDefine = majorWBSAttrList.FirstOrDefault(d => d.Code == majorCode);
                            if (majorAttrDefine == null)
                            {
                                continue;
                            }

                            var majorWBSNode = new S_W_WBS();
                            majorWBSNode.WBSType   = majorType;
                            majorWBSNode.Name      = majorAttrDefine.Name;
                            majorWBSNode.SortIndex = majorAttrDefine.SortIndex;
                            majorWBSNode.WBSValue  = majorCode;
                            result.Add(subEntityNode.AddChild(majorWBSNode));

                            var epcMajorWBSNode = new S_I_WBS();
                            epcMajorWBSNode.NodeType  = majorType;
                            epcMajorWBSNode.Name      = majorAttrDefine.Name;
                            epcMajorWBSNode.SortIndex = majorAttrDefine.SortIndex;
                            epcMajorWBSNode.Value     = majorCode;
                            epcMajorWBSNode.ID        = majorWBSNode.ID;
                            epcSubProjectNode.AddChild(epcMajorWBSNode, true, true);
                        }
                    }

                    if (!string.IsNullOrEmpty(parent.MajorCode))
                    {
                        if (wbs.StructNodeInfo.S_T_WBSStructRole.Count > 0)
                        {
                            var roleDefines = wbs.StructNodeInfo.S_T_WBSStructRole.Where(c => c.SychWBS != true.ToString()).ToList();
                            foreach (var roleDefine in roleDefines)
                            {
                                var users = rbsList.Where(a => a.RoleCode == roleDefine.RoleCode).Select(a => a.UserID).ToArray();
                                if (users.Length > 0)
                                {
                                    wbs.SetUsers(roleDefine.RoleCode, users, false, true, false, true);
                                }
                            }
                        }
                    }
                }
            }
            this.entities.SaveChanges();
            epcEntities.SaveChanges();
            return(Json(result));
        }
        private S_I_ProjectInfo AddProject(S_I_WBS designNode, T_CP_TaskNotice entity, T_CP_TaskNotice_PhaseDetail singlePhase = null)
        {
            entity.ProjectInfoID = designNode.ID;
            S_I_ProjectInfo projectInfo = entity.Push();

            projectInfo.ModifyDate   = projectInfo.CreateDate;
            projectInfo.ModifyUser   = projectInfo.CreateUser;
            projectInfo.ModifyUserID = projectInfo.CreateUserID;

            //重新修改phaseValue、phaseName、Name、Code等信息
            if (singlePhase != null)
            {
                projectInfo.PhaseValue        = singlePhase.Phase;
                projectInfo.WBSRoot.PhaseCode = singlePhase.Phase;
                var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase);
                var phaseItem = phaseList.FirstOrDefault(d => projectInfo.PhaseValue == d.Code);
                projectInfo.PhaseName      = phaseItem.Name;
                projectInfo.Name           = singlePhase.Name;
                projectInfo.Code           = singlePhase.Code;
                projectInfo.ChargeDeptID   = singlePhase.ChargeDept ?? entity.ChargeDept;
                projectInfo.ChargeDeptName = singlePhase.ChargeDeptName ?? entity.ChargeDeptName;
                projectInfo.ChargeUserID   = singlePhase.ChargeUser ?? entity.ChargeUser;
                projectInfo.ChargeUserName = singlePhase.ChargeUserName ?? entity.ChargeUserName;
                projectInfo.OtherDeptID    = singlePhase.OtherDept ?? entity.OtherDept;
                projectInfo.OtherDeptName  = singlePhase.OtherDeptName ?? entity.OtherDeptName;
                projectInfo.PlanStartDate  = singlePhase.PlanStartDate ?? entity.PlanStartDate;
                projectInfo.PlanFinishDate = singlePhase.PlanFinishDate ?? entity.PlanFinishDate;
            }
            projectInfo.ModifyDate          = projectInfo.CreateDate;
            projectInfo.ModifyUser          = projectInfo.CreateUser;
            projectInfo.ModifyUserID        = projectInfo.CreateUserID;
            projectInfo.MarketProjectInfoID = projectInfo.ID;

            #region 默认创建EPS结构
            var group = this.BusinessEntities.Set <S_I_ProjectGroup>().FirstOrDefault(d => d.RelateID == entity.EngineeringID && d.Type == "Engineering");
            if (group == null)
            {
                group                      = new S_I_ProjectGroup();
                group.ID                   = Formula.FormulaHelper.CreateGuid();
                group.Name                 = designNode.S_I_Engineering.Name;
                group.Code                 = designNode.S_I_Engineering.SerialNumber;
                group.City                 = designNode.S_I_Engineering.City;
                group.Province             = designNode.S_I_Engineering.Province;
                group.Area                 = designNode.S_I_Engineering.Area;
                group.ProjectClass         = designNode.S_I_Engineering.ProjectClass;
                group.Investment           = designNode.S_I_Engineering.Investment;
                group.PhaseContent         = designNode.S_I_Engineering.PhaseValue;
                group.DeptID               = designNode.S_I_Engineering.ChargerDept;
                group.DeptName             = designNode.S_I_Engineering.ChargerDeptName;
                group.RelateID             = designNode.S_I_Engineering.ID;
                group.EngineeringSpaceCode = ProjectMode.Standard.ToString();
                group.CreateDate           = DateTime.Now;
                var fo = Formula.FormulaHelper.CreateFO <EPSFO>();
                fo.BuildEngineering(group);
            }
            group.BindingProject(projectInfo);
            entity.GroupID   = group.ID;
            group.PhaseValue = designNode.S_I_Engineering.PhaseValue;
            #endregion

            projectInfo.InitDeisgnInputTemplate(true);

            //把设总放进RBS中
            if (projectInfo != null && !string.IsNullOrEmpty(entity.DesignManager))
            {
                projectInfo.WBSRoot.SetUsers(ProjectRole.DesignManager.ToString(), entity.DesignManager.Split(','), true, true, true, true);
            }
            return(projectInfo);
        }
        protected override void OnFlowEnd(T_CP_TaskNotice entity, Workflow.Logic.Domain.S_WF_InsTaskExec taskExec, Workflow.Logic.Domain.S_WF_InsDefRouting routing)
        {
            if (entity == null)
            {
                throw new Formula.Exceptions.BusinessException("没有找到指定的任务单,立项失败");
            }
            var projectList = new List <S_I_ProjectInfo>();
            var dbContext   = FormulaHelper.GetEntities <EPC.Logic.Domain.EPCEntities>();

            if (!String.IsNullOrEmpty(entity.ProjectInfoID) && this.BusinessEntities.Set <S_I_ProjectInfo>().Any(a => a.ID == entity.ProjectInfoID))
            {
                #region
                S_I_ProjectInfo projectInfo = null;
                projectInfo = entity.UpGrade();
                #endregion
            }
            else
            {
                #region 新下任务单
                var EngineeringID = entity.EngineeringID;
                if (string.IsNullOrWhiteSpace(EngineeringID))
                {
                    EngineeringID = "aabe00fb-15ec-4eff-96ad-1e6ebb2c0bf7";
                }
                var engineeringInfo = dbContext.S_I_Engineering.Find(EngineeringID);
                if (engineeringInfo == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("没有找对应的工程信息,无法下达任务单");
                }
                if (engineeringInfo.S_I_WBS.Count == 0)
                {
                    if (String.IsNullOrEmpty(engineeringInfo.ModeCode))
                    {
                        engineeringInfo.initModeCode();
                    }
                    engineeringInfo.InitWBS();
                }
                var structNode = engineeringInfo.Mode.S_C_WBSStruct.FirstOrDefault(c => c.NodeType == "DesignProject");
                if (structNode == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("没有找到设计项目的WBS节点定义,无法下达任务单");
                }
                var parentNode = engineeringInfo.S_I_WBS.FirstOrDefault(c => c.StructInfoID == structNode.Parent.ID);
                if (parentNode == null)
                {
                    throw new Formula.Exceptions.BusinessValidationException("设计节点不能作为根节点定义,请联系管理员配置项目模式WBS模板");
                }
                var wbsNode = new S_I_WBS();
                wbsNode.Name            = entity.ProjectInfo;
                wbsNode.Code            = entity.SerialNumber;
                wbsNode.Value           = entity.SerialNumber;
                wbsNode.PlanStartDate   = entity.PlanStartDate;
                wbsNode.PlanEndDate     = entity.PlanFinishDate;
                wbsNode.ChargerDept     = entity.ChargeDept;
                wbsNode.ChargerDeptName = entity.ChargeDeptName;
                wbsNode.ChargerUser     = entity.ChargeUser;
                wbsNode.ChargerUserName = entity.ChargeUserName;
                wbsNode.NodeType        = structNode.NodeType;
                wbsNode.StructInfoID    = structNode.ID;
                wbsNode.ID = FormulaHelper.CreateGuid();
                parentNode.AddChild(wbsNode);

                var managerIds   = entity.ChargeUser.Split(',');
                var managerNames = entity.ChargeUserName.Split(',');

                for (int i = 0; i < managerIds.Length; i++)
                {
                    var managerID   = managerIds[i];
                    var managerName = managerNames[i];
                    if (engineeringInfo.S_R_Resource.Count(c => c.ResourceID == managerID &&
                                                           c.WBSID == wbsNode.ID && c.RoleCode == "DesignManager" && c.ResourceID == managerID) > 0)
                    {
                        continue;
                    }
                    var resource = new S_R_Resource();
                    resource.RoleName     = "设计经理";
                    resource.RoleCode     = "DesignManager";
                    resource.WBSID        = wbsNode.ID;
                    resource.WBSFullID    = wbsNode.FullID;
                    resource.TaskID       = resource.WBSID;
                    resource.ResourceType = ResourceType.UserRole.ToString();
                    resource.ResourceID   = managerID;
                    resource.ResourceName = managerName;
                    resource.ID           = FormulaHelper.CreateGuid();
                    engineeringInfo.S_R_Resource.Add(resource);
                    engineeringInfo.SetOBSUser("DesignManager", managerID);
                }
                entity.ProjectInfoID = wbsNode.ID;
                var prj = AddProject(wbsNode, entity);
                engineeringInfo.SetWBSAuthWithUser();
                #endregion
            }

            dbContext.SaveChanges();

            this.BusinessEntities.SaveChanges();

            //#region 自动同步核算项目
            //Expenses.Logic.CBSInfoFO.SynCBSInfo(FormulaHelper.ModelToDic<T_CP_TaskNotice>(entity), Expenses.Logic.SetCBSOpportunity.TaskNoticeComplete);
            //#endregion
        }