public Dictionary <string, object> GetColumnChart(S_I_ProjectInfo projectInfo) { var majorList = projectInfo.GetMajors(); var picFileType = EnumBaseHelper.GetEnumDef("Project.PublicationType").EnumItem.ToList(); var dataSource = new DataTable(); dataSource.Columns.Add("MajorName"); var seriesNames = "出图费用(元)"; var seriesFields = "CostValue"; //foreach (var item in picFileType) //{ // dataSource.Columns.Add(item.Code, typeof(decimal)); // seriesNames += item.Name + "折A1,"; // seriesFields += item.Code + ","; //} dataSource.Columns.Add("CostValue", typeof(decimal)); string sql = @"select SUM(CostValue) CostValue,Extend5 MajorValue from S_FC_CostInfo where ProjectID = '" + projectInfo.MarketProjectInfoID + "' and SubjectCode = 'PublishFee' group by Extend5"; var marketSqlHepler = SQLHelper.CreateSqlHelper(ConnEnum.Market); var dt = marketSqlHepler.ExecuteDataTable(sql); foreach (var major in majorList) { var row = dataSource.NewRow(); row["MajorName"] = major.GetValue("Name"); //foreach (var item in picFileType) //{ // var value = 0m; // var list = dt.Select("MajorValue='" + major.GetValue("Value") + "' and PublishType='" + item.Code + "'"); // if (list.Length > 0) // { // value = list[0]["ToA1"] == null || list[0]["ToA1"] == DBNull.Value ? 0m : Convert.ToDecimal(list[0]["ToA1"]); // } // row[item.Code] = value; //} var value = 0m; var list = dt.Select("MajorValue='" + major.GetValue("Value") + "'"); if (list.Length > 0) { value = list[0]["CostValue"] == null || list[0]["CostValue"] == DBNull.Value ? 0m : Convert.ToDecimal(list[0]["CostValue"]); } row["CostValue"] = value; dataSource.Rows.Add(row); } var chart = HighChartHelper.CreateColumnChart("各专业出图费用统计", dataSource, "MajorName", seriesNames.TrimEnd(',').Split(','), seriesFields.TrimEnd(',').Split(',')); var result = chart.Render(); var credits = new Dictionary <string, object>(); credits.SetValue("enabled", false); result.SetValue("credits", credits); return(result); }
/// <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 JsonResult Reorganize(string ProjectInfoID, bool IsAll, string Files) { S_I_ProjectInfo projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档"); } var docList = this.entities.Set <S_D_Document>().Where(d => d.ProjectInfoID == ProjectInfoID && d.State != "Archive").ToList(); var _group = docList.GroupBy(a => a.RelateID).Select(a => new { a.Key, MaxVersion = a.Max(b => (string.IsNullOrEmpty(b.Version) ? 0d : Convert.ToDouble(b.Version))) } ).ToList(); var fileList = JsonHelper.ToList(Files); if (fileList.Count == 0) { throw new Formula.Exceptions.BusinessException("暂无文件清单,请先添加归档文件"); } if (!IsAll) { docList = docList.Where(a => _group.Any(g => g.Key == a.RelateID && g.MaxVersion == (string.IsNullOrEmpty(a.Version) ? 0d : Convert.ToDouble(a.Version)))).ToList(); } if (docList.Count > 0) { S_R_Reorganize entity = new S_R_Reorganize(); entity.TaskName = projectInfo.Name; entity.BusinessID = projectInfo.ID; foreach (var doc in docList) { S_R_Reorganize_DocumentList item = new S_R_Reorganize_DocumentList(); entity.S_R_Reorganize_DocumentList.Add(item); FormulaHelper.UpdateModel(item, doc); item.RelateID = doc.ID; item.RelateTable = "S_D_Document"; item.MainFile = doc.MainFiles; doc.State = "Archive"; doc.ArchiveDate = new DateTime?(DateTime.Now); } new ReorganizeFO().CreateReorganize("DesignDoc", entity); this.entities.SaveChanges(); } return(Json("")); }
public JsonResult ReorganizeFile(string ProjectInfoID, string Files) { S_I_ProjectInfo projectInfo = this.GetEntityByID <S_I_ProjectInfo>(ProjectInfoID); if (projectInfo == null) { throw new Formula.Exceptions.BusinessException("未能找到项目信息,无法归档"); } var fileList = JsonHelper.ToList(Files); if (fileList.Count == 0) { throw new Formula.Exceptions.BusinessException("暂无文件清单,请先添加归档文件"); } fileList = fileList.Where(a => !a.Keys.Contains("NewAdd") || (a.Keys.Contains("NewAdd") && a.GetValue("NewAdd") != "T")).ToList(); if (fileList.Count > 0) { S_R_Reorganize entity = new S_R_Reorganize(); entity.TaskName = projectInfo.Name; entity.BusinessID = projectInfo.ID; foreach (var filedic in fileList) { var doc = this.GetEntityByID <S_D_Document>(filedic.GetValue("DocumentID")); if (doc == null) { continue; } S_R_Reorganize_DocumentList item = new S_R_Reorganize_DocumentList(); entity.S_R_Reorganize_DocumentList.Add(item); FormulaHelper.UpdateModel(item, doc); item.RelateID = doc.ID; item.RelateTable = "S_D_Document"; item.MainFile = doc.MainFiles; doc.State = "Archive"; doc.ArchiveDate = new DateTime?(DateTime.Now); } new ReorganizeFO().CreateReorganize("DesignDoc", entity); this.entities.SaveChanges(); } return(base.Json("")); }
public JsonResult SaveWBSUserInfo(string WBSInfo) { var list = JsonHelper.ToList(WBSInfo); S_I_ProjectInfo prj = null; foreach (var item in list) { if (String.IsNullOrEmpty(item.GetValue("VirtualID"))) { continue; } var wbs = this.GetEntityByID <S_W_WBS>(item.GetValue("VirtualID")); this.entities.Set <S_W_RBS>().Delete(c => c.WBSID == wbs.ID); if (prj == null) { prj = wbs.S_I_ProjectInfo; prj.ModifyDate = DateTime.Now;//c_hua 修改时间以便同步程序同步人员给四方系统 } var structInfoRoles = wbs.StructNodeInfo.S_T_WBSStructRole.ToList(); foreach (var stRole in structInfoRoles) { var roleField = stRole.RoleCode + "UserID"; var userID = item.GetValue(roleField); if (String.IsNullOrEmpty(userID)) { wbs.RemoveUser(stRole.RoleCode); continue; } wbs.SetUsers(stRole.RoleCode, userID.Split(','), false); } } this.entities.SaveChanges(); prj.ResetOBSUserFromRBS(); this.entities.SaveChanges(); return(Json("")); }
private S_I_ProjectInfo AddProject(T_CP_TaskNotice entity, S_I_Engineering engineering, T_CP_TaskNotice_PhaseDetail singlePhase = null) { var marketEntities = FormulaHelper.GetEntities <Market.Logic.Domain.MarketEntities>(); 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; #region 步创建经营库的项目信息 S_I_Project project = null; var marketClue = marketEntities.S_P_MarketClue.Find(entity.RelateID); project = marketEntities.S_I_Project.FirstOrDefault(d => d.TasKNoticeID == entity.ID); if (project != null) { throw new Formula.Exceptions.BusinessException("任务单已经下达过项目,无法重复下达"); } project = new S_I_Project(); project.ID = projectInfo.ID; project.TasKNoticeID = entity.ID; project.TasKNoticeTmplCode = entity.TmplCode; project.Name = projectInfo.Name; project.Code = projectInfo.Code; project.Phase = projectInfo.PhaseValue; project.ProjectClass = projectInfo.ProjectClass; project.Customer = projectInfo.CustomerID; project.CustomerName = projectInfo.CustomerName; project.CreateDate = DateTime.Now; project.EngineeringInfo = entity.EngineeringID; project.ChargerDept = projectInfo.ChargeDeptID; project.ChargerDeptName = projectInfo.ChargeDeptName; project.ChargerUser = projectInfo.ChargeUserID; project.ChargerUserName = projectInfo.ChargeUserName; project.Country = projectInfo.Country; project.Province = projectInfo.Province; project.Area = projectInfo.Area; project.City = projectInfo.City; project.State = projectInfo.State; project.ProjectScale = entity.ProjectLevel; if (marketClue != null) { project.MakertClueID = marketClue.ID; marketClue.State = Market.Logic.ClueState.Succeed.ToString(); } marketEntities.S_I_Project.Add(project); entity.MarketProjectID = project.ID; #endregion #region 步绑定合同 if (!String.IsNullOrEmpty(entity.ContractInfo)) { var contract = marketEntities.Set <S_C_ManageContract>().Include("S_C_ManageContract_ProjectRelation") .Include("S_C_ManageContract_ReceiptObj").FirstOrDefault(d => d.ID == entity.ContractInfo); if (contract != null) { var relation = contract.S_C_ManageContract_ProjectRelation.FirstOrDefault(a => a.ProjectID == project.ID); if (relation == null) { relation = new S_C_ManageContract_ProjectRelation(); relation.ID = FormulaHelper.CreateGuid(); relation.ProjectID = project.ID; relation.S_C_ManageContractID = contract.ID; relation.ProjectCode = project.Code; relation.ProjectName = project.Name; if (contract.S_C_ManageContract_ProjectRelation.Count == 0) { if (entity.ContractValue.HasValue && contract.ContractRMBAmount > 0) { if (contract.ContractRMBAmount > 0) { relation.Scale = entity.ContractValue.Value / contract.ContractRMBAmount * 100; } else { relation.Scale = 0; } relation.ProjectValue = entity.ContractValue; relation.TaxRate = contract.TaxRate; relation.TaxValue = relation.ProjectValue / (1 + contract.TaxRate) * contract.TaxRate; relation.ClearValue = relation.ProjectValue - relation.TaxValue; } else { relation.Scale = 100; relation.ProjectValue = contract.ContractRMBAmount; var taxRate = contract.TaxRate.HasValue ? contract.TaxRate.Value : 0; var taxValue = contract.ContractRMBAmount / (1 + taxRate) * taxRate; var clearVlaue = contract.ContractRMBAmount - taxValue; relation.TaxRate = taxRate; relation.TaxValue = taxValue; relation.ClearValue = contract.ContractRMBAmount - taxValue; } foreach (var item in contract.S_C_ManageContract_ReceiptObj.ToList()) { item.ProjectInfo = project.ID; item.ProjectInfoName = project.Name; relation.TaxRate = contract.TaxRate; } } else { if (entity.ContractValue.HasValue && contract.ContractRMBAmount > 0) { if (contract.ContractRMBAmount > 0) { relation.Scale = entity.ContractValue.Value / contract.ContractRMBAmount * 100; } else { relation.Scale = 0; } relation.ProjectValue = entity.ContractValue; relation.TaxRate = contract.TaxRate; relation.TaxValue = relation.ProjectValue / (1 + contract.TaxRate) * contract.TaxRate; relation.ClearValue = relation.ProjectValue - relation.TaxValue; } else { relation.Scale = 0; relation.ProjectValue = 0; relation.TaxRate = contract.TaxRate; } } contract.S_C_ManageContract_ProjectRelation.Add(relation); if (String.IsNullOrEmpty(contract.EngineeringInfo) && engineering != null) { contract.EngineeringInfo = engineering.ID; contract.EngineeringInfoName = engineering.Name; } } } } else { var contractList = marketEntities.Set <S_C_ManageContract>().Include("S_C_ManageContract_ProjectRelation") .Include("S_C_ManageContract_ReceiptObj").Where(d => d.EngineeringInfo == entity.EngineeringID).ToList(); foreach (var contract in contractList) { var relation = contract.S_C_ManageContract_ProjectRelation.FirstOrDefault(a => a.ProjectID == project.ID); if (relation == null) { relation = new S_C_ManageContract_ProjectRelation(); relation.ID = FormulaHelper.CreateGuid(); relation.ProjectID = project.ID; relation.S_C_ManageContractID = contract.ID; relation.ProjectCode = project.Code; relation.ProjectName = project.Name; if (contract.S_C_ManageContract_ProjectRelation.Count == 0) { relation.Scale = 100; relation.ProjectValue = contract.ContractRMBAmount; foreach (var item in contract.S_C_ManageContract_ReceiptObj.ToList()) { item.ProjectInfo = project.ID; item.ProjectInfoName = project.Name; } } else { relation.Scale = 0; relation.ProjectValue = 0; } contract.S_C_ManageContract_ProjectRelation.Add(relation); } } } #endregion projectInfo.MarketProjectInfoID = project.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 = engineering.Name; group.Code = engineering.Code; group.City = engineering.City; group.Country = engineering.Country; group.Province = engineering.Province; group.Area = engineering.Area; group.ProjectClass = engineering.Class; group.Investment = engineering.Investment; group.Proportion = engineering.Proportion; group.PhaseContent = engineering.PhaseContent; group.Address = engineering.Address; group.DeptID = engineering.MainDept; group.DeptName = engineering.MainDeptName; group.RelateID = 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.PhaseContent = engineering.PhaseContent; group.PhaseValue = 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); } var customer = marketEntities.Set <S_F_Customer>().FirstOrDefault(a => a.ID == entity.Customer); if (customer != null) { if (string.IsNullOrEmpty(entity.Country)) { project.Country = customer.Country; projectInfo.Country = customer.Country; } if (string.IsNullOrEmpty(entity.Province)) { project.Province = customer.Province; projectInfo.Province = customer.Province; } if (string.IsNullOrEmpty(entity.City)) { project.City = customer.City; projectInfo.City = customer.City; } if (string.IsNullOrEmpty(entity.Area)) { project.Area = customer.Area; projectInfo.Area = customer.Area; } } 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 marketEntities = FormulaHelper.GetEntities <Market.Logic.Domain.MarketEntities>(); var projectList = new List <S_I_ProjectInfo>(); if (!String.IsNullOrEmpty(entity.ProjectInfoID) && this.BusinessEntities.Set <S_I_ProjectInfo>().Any(a => a.ID == entity.ProjectInfoID)) { #region 任务单升版 S_I_ProjectInfo projectInfo = null; S_I_Project project = null; projectInfo = entity.UpGrade(); project = marketEntities.S_I_Project.FirstOrDefault(d => d.ID == projectInfo.MarketProjectInfoID); project.Name = entity.ProjectInfo; project.Code = entity.SerialNumber; project.Phase = entity.Phase; project.ProjectClass = entity.ProjectClass; project.Customer = entity.Customer; project.CustomerName = entity.CustomerName; project.CreateDate = DateTime.Now; project.EngineeringInfo = entity.EngineeringID; project.ChargerDept = string.IsNullOrEmpty(entity.ChargeDept) ? entity.DesignDept : entity.ChargeDept; project.ChargerDeptName = string.IsNullOrEmpty(entity.ChargeDeptName) ? entity.DesignDeptName : entity.ChargeDeptName; project.ChargerUser = entity.ChargeUser; project.ChargerUserName = entity.ChargeUserName; project.Country = entity.Country; project.Province = entity.Province; project.Area = entity.Area; if (string.IsNullOrEmpty(project.Area)) { //获取省份对应的地区(SubCategory) var enumItem = EnumBaseHelper.GetEnumDef("System.Province").EnumItem.FirstOrDefault(a => a.Code == entity.Province); if (enumItem != null) { project.Area = enumItem.SubCategory; } } project.City = entity.City; project.ProjectScale = entity.ProjectLevel; projectInfo.ModifyDate = DateTime.Now; projectInfo.ModifyUser = entity.CreateUser; projectInfo.ModifyUserID = entity.CreateUserID; //修改经营库项目名称冗余字段 if (!string.IsNullOrEmpty(projectInfo.MarketProjectInfoID)) { if (entity.ContractValue.HasValue && String.IsNullOrEmpty(entity.ContractInfo)) { marketEntities.S_C_ManageContract_ProjectRelation.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID && a.S_C_ManageContractID == entity.ContractInfo).Update(a => a.ProjectValue = entity.ContractValue); } marketEntities.S_C_ManageContract_ProjectRelation.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID).Update(a => a.ProjectName = entity.ProjectInfo); marketEntities.S_C_ManageContract_ReceiptObj.Where(a => a.ProjectInfo == projectInfo.MarketProjectInfoID).Update(a => a.ProjectInfoName = entity.ProjectInfo); marketEntities.S_C_PlanReceipt.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID).Update(a => a.ProjectName = entity.ProjectInfo); marketEntities.S_FC_CostInfo.Where(a => a.ProjectID == projectInfo.MarketProjectInfoID).Update(a => a.ProjectName = entity.ProjectInfo); marketEntities.S_SP_SupplierContract.Where(a => a.ProjectInfo == projectInfo.MarketProjectInfoID).Update(a => a.ProjectInfoName = entity.ProjectInfo); } projectList.Add(projectInfo); #endregion } else { #region 新建任务单立项 #region 如果工程信息为空,则默认创建工程 var engineering = marketEntities.S_I_Engineering.Find(entity.EngineeringID); bool newEngineer = false; if (engineering == null) { engineering = new S_I_Engineering(); engineering.ID = FormulaHelper.CreateGuid(); marketEntities.S_I_Engineering.Add(engineering); newEngineer = true; } engineering.Name = String.IsNullOrEmpty(entity.EngineeringName) ? entity.ProjectInfo : entity.EngineeringName; if (!String.IsNullOrEmpty(entity.Customer)) { engineering.CustomerInfo = entity.Customer; engineering.CustomerInfoName = entity.CustomerName; } engineering.Code = String.IsNullOrEmpty(entity.EngineeringCode) ? entity.SerialNumber : entity.EngineeringCode; if (!string.IsNullOrEmpty(entity.MainDeptInfo)) { engineering.MainDept = entity.MainDeptInfo; engineering.MainDeptName = entity.MainDeptInfoName; } else if (string.IsNullOrEmpty(engineering.MainDept)) { engineering.MainDept = entity.ChargeDept; engineering.MainDeptName = entity.ChargeDeptName; } engineering.OtherDept = String.IsNullOrEmpty(entity.EngineeringOtherDept) ? entity.OtherDept : entity.EngineeringOtherDept; engineering.OtherDeptName = String.IsNullOrEmpty(entity.EngineeringOtherDeptName) ? entity.OtherDeptName : entity.EngineeringOtherDeptName; engineering.ChargerUser = String.IsNullOrEmpty(entity.EngineeringChargeUser) ? entity.ChargeUser : entity.EngineeringChargeUser; engineering.ChargerUserName = String.IsNullOrEmpty(entity.EngineeringChargeUserName) ? entity.ChargeUserName : entity.EngineeringChargeUserName; engineering.Country = entity.Country; engineering.Province = entity.Province; engineering.City = entity.City; engineering.Area = entity.Area; engineering.Proportion = entity.BuildArea; engineering.Address = entity.BuildAddress; engineering.LandingArea = entity.LandArea; engineering.CreateDate = DateTime.Now; if (!String.IsNullOrEmpty(entity.Investment)) { engineering.Investment = Convert.ToDecimal(entity.Investment); } if (newEngineer) { entity.EngineeringID = engineering.ID; entity.EngineeringName = engineering.Name; entity.EngineeringCode = engineering.Code; entity.EngineeringChargeUser = engineering.ChargerUser; entity.EngineeringChargeUserName = engineering.ChargerUserName; entity.MainDeptInfo = engineering.MainDept; entity.MainDeptInfoName = engineering.MainDeptName; entity.EngineeringOtherDept = engineering.OtherDept; entity.EngineeringOtherDeptName = engineering.OtherDeptName; } var phaseName = ""; var phaseList = BaseConfigFO.GetWBSAttrList(WBSNodeType.Phase); var entityPhaseList = phaseList.Where(d => entity.Phase.Contains(d.Code)).ToList(); foreach (var item in entityPhaseList) { phaseName += item.Name + ","; } engineering.PhaseContent = phaseName.TrimEnd(','); engineering.PhaseValue = entity.Phase; #endregion if (!string.IsNullOrEmpty(entity.MultiProjMode) && entity.MultiProjMode.ToLower() == "1") { var list = entity.Phase.Split(','); if (list.Length == 0) { throw new Formula.Exceptions.BusinessException("没有指定阶段"); } string projIds = ""; foreach (var item in entity.T_CP_TaskNotice_PhaseDetail) { var prj = AddProject(entity, engineering, item); projIds += prj.ID + ","; item.ProjectInfoID = prj.ID; projectList.Add(prj); } entity.ProjectInfoID = projIds.TrimEnd(','); } else { var prj = AddProject(entity, engineering); projectList.Add(prj); } #endregion } this.BusinessEntities.SaveChanges(); marketEntities.SaveChanges(); #region 自动同步核算项目 Expenses.Logic.CBSInfoFO.SynCBSInfo(FormulaHelper.ModelToDic <T_CP_TaskNotice>(entity), Expenses.Logic.SetCBSOpportunity.TaskNoticeComplete); #endregion }
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> /// 取本次校审的所有环节 /// </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> /// 获取校审流程启动参数 /// </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); }
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 }
void SendNotice(S_T_ISODefine isoDefine, Dictionary <string, object> dic, S_I_ProjectInfo projectInfo, string sendType, string allTaskUserIDs, string allTaskUserNames, string stepName, bool isStep = false) { var regText = sendType == "Start" ? isoDefine.StartNoticeContent : isoDefine.EndNoticeContent; if (isStep) { regText = isoDefine.StepNoticeContent; } if (isoDefine.SendNotice != "True" || String.IsNullOrEmpty(regText)) { return; } var majorCode = string.Empty; if (!string.IsNullOrEmpty(isoDefine.MajorField)) { majorCode = dic.GetValue(isoDefine.MajorField); } var formID = dic.GetValue("ID"); var notice = this.BusinessEntities.Set <S_N_Notice>().FirstOrDefault(d => d.RelateType == sendType && d.RelateID == formID); if (notice == null || isStep) { notice = this.BusinessEntities.Set <S_N_Notice>().Create(); notice.ID = FormulaHelper.CreateGuid(); var enumDefine = new List <Dictionary <string, object> >(); if (!String.IsNullOrEmpty(isoDefine.EnumFieldInfo)) { enumDefine = JsonHelper.ToList(isoDefine.EnumFieldInfo); } dic.SetValue("StepName", stepName); var content = replaceNameString(regText, dic, enumDefine); notice.Title = content; notice.Content = content; if (!String.IsNullOrEmpty(isoDefine.LinkViewUrl)) { notice.LinkUrl = isoDefine.LinkViewUrl.IndexOf("?") >= 0 ? isoDefine.LinkViewUrl + "&ID=" + formID : isoDefine.LinkViewUrl + "?ID=" + formID; } notice.CreateDate = DateTime.Now; notice.RelateID = formID; notice.RelateType = sendType; notice.CreateUserID = dic.GetValue("CreateUserID"); notice.CreateUserName = dic.GetValue("CreateUser"); notice.GroupInfoID = projectInfo.GroupRootID; notice.IsFromSys = "True"; notice.ProjectInfoID = projectInfo.ID; notice.MajorValue = majorCode; notice.NoticeType = isoDefine.Level ?? "Project"; if (isoDefine.Level == "Flow") { notice.ReceiverIDs = allTaskUserIDs; notice.ReceiverNames = allTaskUserNames; } else if (isoDefine.Level == "Major") { notice.WBSID = dic.GetValue("WBSID"); } if (isoDefine.ExpiresDate != null) { notice.ExpiresTime = DateTime.Now.AddDays((double)isoDefine.ExpiresDate); } this.BusinessEntities.Set <S_N_Notice>().Add(notice); } }