///<summary> ///修改: ///</summary> /// <param name="model">要修改的model</param> /// <returns>受影响的行数</returns> public Result <int> UpdateApprover(Epm_Approver model) { Result <int> result = new Result <int>(); try { var rows = DataOperateBusiness <Epm_Approver> .Get().Update(model); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Approver.GetText(), SystemRight.Modify.GetText(), "修改: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateApprover"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddApprover(Epm_Approver model) { Result <int> result = new Result <int>(); try { model.IsApprover = false; model.CrtCompanyId = CurrentCompanyID.ToLongReq(); model.CrtCompanyName = CurrentCompanyName; model.CreateUserId = CurrentUserID.ToLongReq(); model.CreateUserName = CurrentUserName; model.CreateTime = DateTime.Now; model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.IsDelete = false; var rows = DataOperateBusiness <Epm_Approver> .Get().Add(model); Epm_ApproverRecord record = new Epm_ApproverRecord(); record.BusinessId = model.BusinessId; record.BusinessType = model.BusinessTypeNo; record.BusinessName = model.BusinessTypeName; record.HandleUserId = CurrentUserID.ToLongReq(); record.HandleUserName = CurrentUserName; record.BusinessState = model.BusinessState.ToString(); AddApproverRecord(record); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Approver.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddApprover"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result<int> AddVisa(VisaView model, List<Base_Files> fileList) { Result<int> result = new Result<int>(); try { Epm_Visa visa = new Epm_Visa(); List<Epm_VisaCompany> companys = new List<Epm_VisaCompany>(); model.Id = visa.Id; ViewToEmp(model, out visa, out companys); var rows = DataOperateBusiness<Epm_Visa>.Get().Add(visa); DataOperateBusiness<Epm_VisaCompany>.Get().AddRange(companys); if (model.State == (int)ApprovalState.WaitAppr) { if (companys.Any() && companys.Count > 0) { for (int i = 0; i < companys.Count; i++) { var comID = companys[i].CompanyId; var temp = DataOperateBusiness<Epm_ProjectStateTrack>.Get().GetList(t => t.CompanyId == comID).FirstOrDefault(); if (temp != null) { temp.Qty = (Convert.ToInt32(temp.Qty) + 1).ToString(); DataOperateBusiness<Epm_ProjectStateTrack>.Get().Update(temp); } } } #region 生成待办 var project = DataOperateBusiness<Epm_Project>.Get().GetModel(model.ProjectId.Value); List<Epm_Approver> list = new List<Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了隐蔽工程作业单,待审核"; app.Content = CurrentUserName + "提报了隐蔽工程作业单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Visa.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Visa.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = visa.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Visa.GetText(), SystemRight.Add.GetText(), "提交签证生成待办: " + visa.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了隐蔽工程作业单,待审核"; modelMsg.Content = CurrentUserName + "提报了隐蔽工程作业单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Visa.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness<Epm_Massage>.Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterssm = new Dictionary<string, string>(); //parameterssm.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.VisaAdd, parameterssm); #endregion } if (fileList != null) { //新增附件 AddFilesByTable(visa, fileList); } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Visa.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddVisa"); } return result; }
/// <summary> /// 更新状态 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public Result<int> UpdateVisaState(long id, string state) { Result<int> result = new Result<int>(); try { var model = DataOperateBusiness<Epm_Visa>.Get().GetModel(id); if (model != null) { model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.State = (int)state.ToEnumReq<ApprovalState>(); var rows = DataOperateBusiness<Epm_Visa>.Get().Update(model); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Change.GetText(), SystemRight.Delete.GetText(), "更新状态: " + rows); //处理待办 var tempApp = DataOperateBusiness<Epm_Approver>.Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); } string title = ""; if (model.State == (int)ApprovalState.Discarded) { var list = DataOperateBusiness<Epm_VisaCompany>.Get().GetList(t => t.VisaId == model.Id).ToList(); if (list.Any()) { for (int i = 0; i < list.Count; i++) { var comID = list[i].CompanyId; var temp = DataOperateBusiness<Epm_ProjectStateTrack>.Get().GetList(t => t.CompanyId == comID).FirstOrDefault(); temp.Qty = (Convert.ToInt32(temp.Qty) - 1).ToString(); DataOperateBusiness<Epm_ProjectStateTrack>.Get().Update(temp); } } title = model.CreateUserName + "提报了签证单,已废弃"; #region 生成待办 var project = DataOperateBusiness<Epm_Project>.Get().GetModel(model.ProjectId.Value); List<Epm_Approver> listApp = new List<Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报了签证单,已废弃"; app.Content = model.CreateUserName + "提报了签证单,已废弃"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Visa.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.Visa.GetText(); app.BusinessState = (int)(ApprovalState.Discarded); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; listApp.Add(app); AddApproverBatch(listApp); WriteLog(BusinessType.Visa.GetText(), SystemRight.Invalid.GetText(), "废弃签证生成待办: " + model.Id); #endregion } if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprSuccess) { #region 更改项目状态表 var companys = DataOperateBusiness<Epm_VisaCompany>.Get().GetList(t => t.VisaId == model.Id).ToList(); if (companys.Any()) { var companyIds = companys.Select(t => t.CompanyId); var track = DataOperateBusiness<Epm_ProjectStateTrack>.Get().GetList(t => t.ProjectId == model.ProjectId && companyIds.Contains(t.CompanyId) && t.StateTrackNo == "VisaNum"); if (track.Any()) { foreach (var item in track) { int qty = Convert.ToInt32(item.Qty) + 1; item.Qty = qty.ToString(); } DataOperateBusiness<Epm_ProjectStateTrack>.Get().UpdateRange(track); } } #endregion #region 生成待办 List<Epm_Approver> list = new List<Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的隐蔽工程作业单已审核通过"; app.Content = model.CreateUserName + "提报的隐蔽工程作业单已审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Visa.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Visa.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Visa.GetText(), SystemRight.Check.GetText(), "审核通过签证生成待办: " + model.Id); #endregion } if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprFailure) { title = model.CreateUserName + "提报的签证单已被驳回,请处理"; #region 生成待办 List<Epm_Approver> list = new List<Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的签证单已被驳回,请处理"; app.Content = model.CreateUserName + "提报的签证单已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Visa.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Visa.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Visa.GetText(), SystemRight.UnCheck.GetText(), "驳回签证生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.VisaReject, null); #endregion } #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Visa.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness<Epm_Massage>.Get().Add(modelMsg); } #endregion } else { throw new Exception("id有误"); } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateState"); } return result; }
/// <summary> /// 修改状态(废弃) /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public Result <int> ChangeContractState(long id, string state) { Result <int> result = new Result <int>(); try { var drawState = state.ToEnumReq <ApprovalState>(); var model = DataOperateBusiness <Epm_Contract> .Get().GetModel(id); model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.State = int.Parse(drawState.GetValue().ToString()); var rows = DataOperateBusiness <Epm_Contract> .Get().Update(model); //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传了项目合同,已废弃"; app.Content = model.CreateUserName + "上传了项目合同,已废弃"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Contract.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.Contract.GetText(); app.BusinessState = (int)(ApprovalState.Discarded); app.BusinessId = model.Id; app.ApproverId = project.PMId; app.ApproverName = project.PMName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Contract.GetText(), SystemRight.Invalid.GetText(), "废弃合同生成待办: " + model.Id); #endregion if (model.ProjectId.Value != 0) { #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = model.CreateUserName + "上传了项目合同,已废弃"; modelMsg.Content = model.CreateUserName + "上传了项目合同,已废弃"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Contract.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion } result.Data = rows; result.Flag = EResultFlag.Success; } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "ChangeContractState"); } return(result); }
/// <summary> /// 修改状态 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <param name="reason"></param> /// <returns></returns> public Result <int> ChangeCompletionAcceptanceState(long id, PreCompletionScceptanceState state, string reason) { Result <int> result = new Result <int>(); try { var model = DataOperateBusiness <Epm_CompletionAcceptance> .Get().GetModel(id); if (model != null) { model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.State = (int)state; string title = ""; var projectInfo = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); if ((PreCompletionScceptanceState)Enum.ToObject(typeof(PreCompletionScceptanceState), model.State) == PreCompletionScceptanceState.ApprovalSuccess) { #region 消息 title = model.CreateUserName + "提报的完工验收单,审核通过"; #endregion //“省公司验收”的初始化状态为“未完成”,当完工验收功能的流程结束后,将项目的“省公司验收”字段状态改为“完成” projectInfo.ProCompanyAcceptance = 1; DataOperateBusiness <Epm_Project> .Get().Update(projectInfo); #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的完工验收单,审核通过"; app.Content = model.CreateUserName + "提报的完工验收单,审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Completed.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Completed.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = model.Id; app.ApproverId = projectInfo.PMId; app.ApproverName = projectInfo.PMName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Contract.GetText(), SystemRight.Check.GetText(), "审核通过完工验收单生成待办: " + model.Id); #endregion } else if ((PreCompletionScceptanceState)Enum.ToObject(typeof(PreCompletionScceptanceState), model.State) == PreCompletionScceptanceState.ApprovalFailure) { #region 消息 title = model.CreateUserName + "提报的完工验收单,已被驳回"; #endregion #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的完工验收单已被驳回,请处理"; app.Content = model.CreateUserName + "提报的完工验收单已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Completed.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Completed.GetText(); app.BusinessState = (int)(PreCompletionScceptanceState.ApprovalFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Contract.GetText(), SystemRight.UnCheck.GetText(), "驳回完工验收单生成待办: " + model.Id); #endregion } //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Completed.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion var rows = DataOperateBusiness <Epm_CompletionAcceptance> .Get().Update(model); //保存需要发送的基础数据 AddSendDateByProjectId(projectInfo.Id); result.Data = rows; result.Flag = EResultFlag.Success; } else { throw new Exception("该完工验收信息不存在或已被删除!"); } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "ChangeCompletionAcceptanceState"); } return(result); }
/// <summary> /// 审核/驳回 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <param name="reason"></param> /// <returns></returns> public Result <int> RejectBim(long id, string state, string reason) { Result <int> result = new Result <int>(); try { var drawState = state.ToEnumReq <ApprovalState>(); var model = DataOperateBusiness <Epm_Bim> .Get().GetModel(id); //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.State = int.Parse(drawState.GetValue().ToString()); string title = ""; if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprSuccess) { //每一次审核通过都修改本次IsValidate的值为1,之前已经存在的IsValidate为1的状态修改为0; model.IsValidate = true; var list = DataOperateBusiness <Epm_Bim> .Get().GetList(t => t.ProjectId == model.ProjectId && t.Id != model.Id).ToList(); if (list.Count > 0) { foreach (var item in list) { item.IsValidate = false; } DataOperateBusiness <Epm_Bim> .Get().UpdateRange(list); } title = model.CreateUserName + "上传的BIM模型,审核通过"; #region 生成待办 List <Epm_Approver> listApp = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的BIM模型,审核通过"; app.Content = model.CreateUserName + "上传的BIM模型,审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Model.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Model.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; listApp.Add(app); AddApproverBatch(listApp); WriteLog(BusinessType.Model.GetText(), SystemRight.Check.GetText(), "审核通过模型生成待办: " + model.Id); #endregion } else if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprFailure) { title = model.CreateUserName + "上传的BIM模型已被驳回,请处理"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的BIM模型已被驳回,请处理"; app.Content = model.CreateUserName + "上传的BIM模型已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Model.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Model.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Model.GetText(), SystemRight.UnCheck.GetText(), "驳回模型生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.ModelReject, null); #endregion } var rows = DataOperateBusiness <Epm_Bim> .Get().Update(model); #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Model.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion result.Data = rows; result.Flag = EResultFlag.Success; } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "RejectBim"); } return(result); }
///<summary> ///修改: ///</summary> /// <param name="model">要修改的model</param> /// <returns>受影响的行数</returns> public Result <int> UpdateDraw(Epm_Draw model, List <Base_Files> fileListFile) { Result <int> result = new Result <int>(); try { //bool dConfig = DataOperateBusiness<Epm_Draw>.Get().Count(i => i.Name == model.Name && i.ProjectId == model.ProjectId && i.VersionNo == model.VersionNo && i.Id != model.Id) > 0; //if (dConfig) //{ // throw new Exception("该图纸名称已经存在"); //} //dConfig = DataOperateBusiness<Epm_Draw>.Get().Count(i => i.VersionOrder == model.VersionOrder && i.Id != model.Id) > 0; //if (dConfig) //{ // throw new Exception("该图纸版本号已经存在"); //} var oldModel = DataOperateBusiness <Epm_Draw> .Get().GetModel(model.Id); model = FiterUpdate(oldModel, model); var rows = DataOperateBusiness <Epm_Draw> .Get().Update(model); //上传图纸 if (fileListFile != null) { //删除之前的附件 DeleteFilesByTable(model.GetType().Name, new List <long>() { model.Id }); //新增附件 AddFilesByTable(model, fileListFile); } //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } //生成代办消息 if ((ApprovalState)model.State == ApprovalState.WaitAppr) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "上传了项目图纸,待审核"; app.Content = CurrentUserName + "上传了项目图纸,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Draw.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Draw.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Draw.GetText(), SystemRight.Add.GetText(), "提交图纸生成待办: " + model.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "上传了项目图纸,待审核"; modelMsg.Content = CurrentUserName + "上传了项目图纸,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Draw.ToString(); modelMsg.ProjectId = model.ProjectId; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parametersms = new Dictionary<string, string>(); //parametersms.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.DrawAdd, parametersms); #endregion } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Draw.GetText(), SystemRight.Modify.GetText(), "修改: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateDraw"); } return(result); }
/// <summary> /// 更新状态 /// </summary> /// <param name="id">危险作业Id</param> /// <param name="state"></param> /// <returns></returns> public Result <int> UpdateWorkRealScenenState(long id, ApprovalState state) { Result <int> result = new Result <int>(); try { int WorkWaitAppr = (int)ApprovalState.WaitAppr; var list = DataOperateBusiness <Epm_WorkUploadRealScene> .Get().GetList(t => t.WorkId == id && t.State == WorkWaitAppr).ToList(); if (list.Any()) { string uploadTime = ""; foreach (var item in list) { uploadTime = item.UploadTime.Value.ToShortDateString(); item.State = (int)state; item.OperateUserId = CurrentUserID.ToLongReq(); item.OperateUserName = CurrentUserName; item.OperateTime = DateTime.Now; var rows = DataOperateBusiness <Epm_WorkUploadRealScene> .Get().Update(item); } result.Data = list.Count; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Delete.GetText(), "更新状态: " + list.Count); var work = DataOperateBusiness <Epm_DangerousWork> .Get().GetModel(id); //最后一天实景审核通过时,危险作业标记完成 if (state == ApprovalState.ApprSuccess) { if (uploadTime == work.EndTime.Value.ToShortDateString()) { work.State = (int)ApprovalState.WorkFinish; work.OperateUserId = CurrentUserID.ToLongReq(); work.OperateUserName = CurrentUserName; work.OperateTime = DateTime.Now; DataOperateBusiness <Epm_DangerousWork> .Get().Update(work); } //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == work.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } #region 生成待办 List <Epm_Approver> li = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = work.CreateUserName + "上传的作业实景,审核通过"; app.Content = work.CreateUserName + "上传的作业实景,审核通过"; app.SendUserId = work.CreateUserId; app.SendUserName = work.CreateUserName; app.SendTime = work.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = work.Id; app.ApproverId = work.CreateUserId; app.ApproverName = work.CreateUserName; app.ProjectId = work.ProjectId; app.ProjectName = work.ProjectName; li.Add(app); AddApproverBatch(li); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + work.Id); #endregion } #region 消息 Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = work.CreateUserId; modelMsg.RecName = work.CreateUserName; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = work.CreateUserName + "上传的作业实景,审核通过"; modelMsg.Content = work.CreateUserName + "上传的作业实景,审核通过"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = work.Id; modelMsg.BussinesType = BusinessType.Dangerous.ToString(); modelMsg.ProjectId = work.ProjectId.Value; modelMsg.ProjectName = work.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); #endregion } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateWorkRealScenenState"); } return(result); }
/// <summary> /// 更新状态 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public Result <int> UpdateMaterialState(long id, ConfirmState state) { Result <int> result = new Result <int>(); try { var model = DataOperateBusiness <Epm_Material> .Get().GetModel(id); model.State = (int)state; var rows = DataOperateBusiness <Epm_Material> .Get().Update(model); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Equipment.GetText(), SystemRight.Modify.GetText(), "更新状态: " + rows); //处理待办 var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); } if (state == ConfirmState.Discarded) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的工器具机械验收单,已废弃"; app.Content = model.CreateUserName + "提报的工器具机械验收单,已废弃"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Equipment.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.Equipment.GetText(); app.BusinessState = (int)(ConfirmState.Discarded); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Equipment.GetText(), SystemRight.Invalid.GetText(), "废弃工器具机械验收生成待办: " + model.Id); #endregion #region 消息 Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = model.CreateUserId; modelMsg.RecName = model.CreateUserName; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = model.CreateUserName + "提报的工器具机械验收单已被" + CurrentUserName + "废弃,请处理"; modelMsg.Content = model.CreateUserName + "提报的工器具机械验收单已被" + CurrentUserName + "废弃,请处理"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Equipment.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); #endregion } else if (state == ConfirmState.Confirm) { #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的工器具机械验收单,审核通过"; app.Content = model.CreateUserName + "提报的工器具机械验收单,审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Equipment.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Equipment.GetText(); app.BusinessState = (int)(ConfirmState.Confirm); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Equipment.GetText(), SystemRight.Check.GetText(), "驳回合同生成待办: " + model.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = model.CreateUserName + "提报的工器具机械验收单," + CurrentUserName + "已审核通过"; modelMsg.Content = model.CreateUserName + "提报的工器具机械验收单," + CurrentUserName + "已审核通过"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Equipment.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion } else if (state == ConfirmState.ConfirmFailure) { #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的工器具机械验收单已被驳回,请处理"; app.Content = model.CreateUserName + "提报的工器具机械验收单已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Equipment.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Equipment.GetText(); app.BusinessState = (int)(ConfirmState.ConfirmFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Equipment.GetText(), SystemRight.UnCheck.GetText(), "驳回合同生成待办: " + model.Id); #endregion #region 消息 Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = model.CreateUserId; modelMsg.RecName = model.CreateUserName; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = model.CreateUserName + "提报的工器具机械验收单已被" + CurrentUserName + "驳回,请处理"; modelMsg.Content = model.CreateUserName + "提报的工器具机械验收单已被" + CurrentUserName + "驳回,请处理"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Equipment.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.MaterialReject, null); #endregion } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateMaterialState"); } return(result); }
/// <summary> /// 更新状态 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public Result <int> UpdateDangerousWorkState(long id, ApprovalState state) { int preState; Result <int> result = new Result <int>(); try { var model = DataOperateBusiness <Epm_DangerousWork> .Get().GetModel(id); preState = model.State.Value; if (preState == (int)ApprovalState.WorkPartAppr) { if (state == ApprovalState.ApprFailure) { state = ApprovalState.ApprSuccess; } else if (state == ApprovalState.ApprSuccess) { state = ApprovalState.WorkFinish; } } model.State = (int)state; model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; var rows = DataOperateBusiness <Epm_DangerousWork> .Get().Update(model); if (state != ApprovalState.WorkPartAppr) { //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Delete.GetText(), "更新状态: " + rows); if (preState == (int)ApprovalState.WorkPartAppr) { var sence = DataOperateBusiness <Epm_WorkUploadRealScene> .Get().GetList(t => t.WorkId == model.Id && t.State == (int)ApprovalState.WaitAppr).FirstOrDefault(); if (sence != null) { if (state == ApprovalState.WorkFinish) { sence.State = (int)ApprovalState.ApprSuccess; } else { sence.State = (int)ApprovalState.ApprFailure; } } DataOperateBusiness <Epm_WorkUploadRealScene> .Get().Update(sence); } string title = CurrentUserName + "上传了危险作业实景,待审核"; if (state == ApprovalState.ApprSuccess && preState == (int)ApprovalState.WaitAppr) { title = model.CreateUserName + "提报的危险作业单已审核通过"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的危险作业单已审核通过"; app.Content = model.CreateUserName + "提报的危险作业单已审核通过"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + model.Id); #endregion } else if (state == ApprovalState.ApprSuccess && preState == (int)ApprovalState.WorkPartAppr) { title = model.CreateUserName + "上传的作业实景,审核不通过"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的作业实景,审核不通过"; app.Content = model.CreateUserName + "上传的作业实景,审核不通过"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + model.Id); #endregion } else if (state == ApprovalState.WorkFinish) { title = model.CreateUserName + "提报的危险作业单,已完成"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的危险作业单,已完成"; app.Content = model.CreateUserName + "提报的危险作业单,已完成"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.WorkFinish); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "审核通过危险作业生成待办: " + model.Id); #endregion } else if (state == ApprovalState.Discarded) { title = model.CreateUserName + "提报的危险作业单已废弃,请处理"; #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的危险作业单已废弃,请处理"; app.Content = model.CreateUserName + "提报的危险作业单已废弃,请处理"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.Discarded); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Invalid.GetText(), "废弃危险作业生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.WorkReject, null); #endregion } else if (state == ApprovalState.ApprFailure) { title = model.CreateUserName + "提报的危险作业单已被驳回,请处理"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "提报的危险作业单已被驳回,请处理"; app.Content = model.CreateUserName + "提报的危险作业单已被驳回,请处理"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.UnCheck.GetText(), "驳回危险作业生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.WorkReject, null); #endregion } #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Dangerous.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateDangerousWorkState"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddMateriel(MaterielView model) { Result <int> result = new Result <int>(); try { model.Epm_Materiel = SetCurrentUser(model.Epm_Materiel); model.Epm_Materiel.CompanyId = CurrentCompanyID.ToLongReq(); model.Epm_Materiel.CompanyName = CurrentCompanyName; if (model.MaterielDetails.Count > 0) { model.Epm_Materiel.SupplierName = model.MaterielDetails[0].Unit; DataOperateBusiness <Epm_Materiel> .Get().Add(model.Epm_Materiel); foreach (var item in model.MaterielDetails) { item.MaterielReceiveId = model.Epm_Materiel.Id; item.UseSum = Convert.ToInt32(item.Qty) - item.UseSum - item.StayUseSum; item.SupMatApplyId = model.Epm_Materiel.SupMatApplyId; SetCreateUser(item); //修改甲供物资申请详情数据 var tzSupMatApplyList = DataOperateBusiness <Epm_TzSupMatApplyList> .Get().GetModel(item.SupMatApplyListId.Value); if (tzSupMatApplyList != null) { tzSupMatApplyList.UseSum = tzSupMatApplyList.UseSum + item.UseSum; tzSupMatApplyList.StayUseSum = item.StayUseSum; if (tzSupMatApplyList.StayUseSum == 0) { tzSupMatApplyList.UseType = true; } DataOperateBusiness <Epm_TzSupMatApplyList> .Get().Update(tzSupMatApplyList); } } DataOperateBusiness <Epm_MaterielDetails> .Get().AddRange(model.MaterielDetails); var stayList = DataOperateBusiness <Epm_MaterielDetails> .Get().GetList(p => p.SupMatApplyId == model.Epm_Materiel.SupMatApplyId).ToList(); foreach (var temp in stayList) { var tzSupMatApply = DataOperateBusiness <Epm_TzSupMatApplyList> .Get().GetModel(temp.SupMatApplyListId.Value); temp.StayUseSum = tzSupMatApply.StayUseSum; } DataOperateBusiness <Epm_MaterielDetails> .Get().UpdateRange(stayList); //修改甲供物资申请验收状态 var tzSupplyMaterialApply = DataOperateBusiness <Epm_TzSupplyMaterialApply> .Get().GetModel(model.Epm_Materiel.SupMatApplyId.Value); if (tzSupplyMaterialApply != null) { int count = DataOperateBusiness <Epm_TzSupMatApplyList> .Get().GetList(t => t.SupMatApplyId == tzSupplyMaterialApply.Id && t.UseType == false).Count(); if (count == 0) { tzSupplyMaterialApply.UseType = true; DataOperateBusiness <Epm_TzSupplyMaterialApply> .Get().Update(tzSupplyMaterialApply); } } if (model.FileList != null) { AddFilesByTable(model.Epm_Materiel, model.FileList);//上传附件 } result.Data = 1; result.Flag = EResultFlag.Success; if (model.Epm_Materiel.State == (int)ConfirmState.WaitConfirm) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.Epm_Materiel.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了材料设备验收单,待审核"; app.Content = CurrentUserName + "提报了材料设备验收单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Track.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Track.GetText(); app.BusinessState = (int)(ConfirmState.WaitConfirm); app.BusinessId = model.Epm_Materiel.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.Epm_Materiel.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Track.GetText(), SystemRight.Add.GetText(), "提交物料验收生成待办: " + model.Epm_Materiel.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.Epm_Materiel.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了材料设备验收单,待审核"; modelMsg.Content = CurrentUserName + "提报了材料设备验收单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Epm_Materiel.Id; modelMsg.BussinesType = BusinessType.Track.ToString(); modelMsg.ProjectId = model.Epm_Materiel.ProjectId; modelMsg.ProjectName = model.Epm_Materiel.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parametersms = new Dictionary<string, string>(); //parametersms.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.MaterielAdd, parametersms); #endregion } } } catch (Exception e) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(e, "AddMateriel"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddDangerousWork(Epm_DangerousWork model, List <Base_Files> files) { Result <int> result = new Result <int>(); try { model = SetCurrentUser(model); model.SubmitCompanyId = CurrentCompanyID.ToLongReq(); model.SubmitCompanyName = CurrentCompanyName; model.SubmitUserId = CurrentUserID.ToLongReq(); model.SubmitUserName = CurrentUserName; model.CrtCompanyId = CurrentCompanyID.ToLongReq(); model.CrtCompanyName = CurrentCompanyName; var rows = DataOperateBusiness <Epm_DangerousWork> .Get().Add(model); QueryCondition qc = new QueryCondition() { PageInfo = new PageListInfo() { isAllowPage = false } }; qc.ConditionList.Add(new ConditionExpression() { ExpName = "ProjectId", ExpValue = model.ProjectId, ExpOperater = eConditionOperator.Equal, ExpLogical = eLogicalOperator.And }); qc.ConditionList.Add(new ConditionExpression() { ExpName = "UploadTime", ExpValue = DateTime.Today, ExpOperater = eConditionOperator.Equal, ExpLogical = eLogicalOperator.And }); // 关联危险作业实景 var workRealScenenResult = GetWorkRealSceneList(qc); if (workRealScenenResult.Flag == EResultFlag.Success && workRealScenenResult.Data != null) { List <Epm_SupervisorLogWork> workList = workRealScenenResult.Data.Select(p => new Epm_SupervisorLogWork { WorkId = p.WorkId, LogId = model.Id, WorkUploadId = p.Id, State = p.State }).ToList(); workList.ForEach(p => { SetCurrentUser(p); SetCreateUser(p); }); DataOperateBusiness <Epm_SupervisorLogWork> .Get().AddRange(workList); } AddFilesByTable(model, files); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); if (model.State == (int)ApprovalState.WaitAppr) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了危险作业单,待审核"; app.Content = CurrentUserName + "提报了危险作业单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Add.GetText(), "提交危险作业生成待办: " + model.Id); #endregion #region 消息 //var waitSend = GetWaitSendMessageList(model.ProjectId.Value); //foreach (var send in waitSend) //{ // Epm_Massage modelMsg = new Epm_Massage(); // modelMsg.ReadTime = null; // modelMsg.RecId = send.Key; // modelMsg.RecName = send.Value; // modelMsg.RecTime = DateTime.Now; // modelMsg.SendId = CurrentUserID.ToLongReq(); // modelMsg.SendName = CurrentUserName; // modelMsg.SendTime = DateTime.Now; // modelMsg.Title = CurrentUserName + "提报了危险作业单,待审核"; // modelMsg.Content = CurrentUserName + "提报了危险作业单,待审核"; // modelMsg.Type = 2; // modelMsg.IsRead = false; // modelMsg.BussinessId = model.Id; // modelMsg.BussinesType = BusinessType.Dangerous.ToString(); // modelMsg.ProjectId = model.ProjectId.Value; // modelMsg.ProjectName = model.ProjectName; // modelMsg = base.SetCurrentUser(modelMsg); // modelMsg = base.SetCreateUser(modelMsg); // DataOperateBusiness<Epm_Massage>.Get().Add(modelMsg); //} #endregion #region 发送短信 //Dictionary<string, string> parameterSms = new Dictionary<string, string>(); //parameterSms.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.WorkAdd, parameterSms); #endregion } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddDangerousWork"); } return(result); }
///<summary> ///修改: ///</summary> /// <param name="model">要修改的model</param> /// <returns>受影响的行数</returns> public Result <int> UpdateDangerousWork(Epm_DangerousWork model, List <Base_Files> files) { Result <int> result = new Result <int>(); try { var oldModel = DataOperateBusiness <Epm_DangerousWork> .Get().GetModel(model.Id); model = FiterUpdate(oldModel, model); model.SubmitCompanyId = oldModel.SubmitCompanyId; model.SubmitCompanyName = oldModel.SubmitCompanyName; model.SubmitUserId = oldModel.SubmitUserId; model.SubmitUserName = oldModel.SubmitUserName; model.CrtCompanyId = oldModel.CrtCompanyId; model.CrtCompanyName = oldModel.CrtCompanyName; var rows = DataOperateBusiness <Epm_DangerousWork> .Get().Update(model); //AddFilesByTable(model, files); //删除之前的附件 DeleteFilesByTable(model.GetType().Name, new List <long>() { model.Id }); //新增附件 AddFilesByTable(model, files); //处理待办 var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Modify.GetText(), "修改: " + model.Id); if (model.State == (int)ApprovalState.WaitAppr) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了危险作业单,待审核"; app.Content = CurrentUserName + "提报了危险作业单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Add.GetText(), "提交危险作业生成待办: " + model.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了危险作业单,待审核"; modelMsg.Content = CurrentUserName + "提报了危险作业单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Dangerous.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterSms = new Dictionary<string, string>(); //parameterSms.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.WorkAdd, parameterSms); #endregion } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateDangerousWork"); } return(result); }
/// <summary> /// 审核/驳回 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <param name="reason"></param> /// <returns></returns> public Result <int> RejectDraw(long id, string state, string reason) { Result <int> result = new Result <int>(); try { var drawState = state.ToEnumReq <ApprovalState>(); var model = DataOperateBusiness <Epm_Draw> .Get().GetModel(id); model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.State = int.Parse(drawState.GetValue().ToString()); //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } string title = ""; if ((ApprovalState)model.State == ApprovalState.ApprSuccess) { //每一次审核通过都修改本次IsValidate的值为1,之前已经存在的IsValidate为1的状态修改为0; model.IsValidate = true; var list = DataOperateBusiness <Epm_Draw> .Get().GetList(t => t.ProjectId == model.ProjectId && t.Id != model.Id).ToList(); if (list.Count > 0) { foreach (var item in list) { item.IsValidate = false; } DataOperateBusiness <Epm_Draw> .Get().UpdateRange(list); } if (model.VersionNo == "BlueprintVersion") { //“已完成施工设计”的初始化状态为“未完成”,当图纸管理中上传项目图纸并审核通过后,所选项目的“已完成施工设计”字段状态改为“完成”。 var projectInfo = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); projectInfo.FinshDesign = 1; DataOperateBusiness <Epm_Project> .Get().Update(projectInfo); } title = model.CreateUserName + "上传的项目图纸,审核通过"; #region 生成待办 List <Epm_Approver> listApp = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的项目图纸,审核通过"; app.Content = model.CreateUserName + "上传的项目图纸,审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Draw.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Draw.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; listApp.Add(app); AddApproverBatch(listApp); WriteLog(BusinessType.Draw.GetText(), SystemRight.Check.GetText(), "审核通过图纸生成待办: " + model.Id); #endregion } else if ((ApprovalState)model.State == ApprovalState.ApprFailure) { title = model.CreateUserName + "上传的项目图纸已被驳回,请处理"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的项目图纸已被驳回,请处理"; app.Content = model.CreateUserName + "上传的项目图纸已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Draw.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Draw.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Draw.GetText(), SystemRight.UnCheck.GetText(), "驳回图纸生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.DrawReject, null); #endregion } else if ((ApprovalState)model.State == ApprovalState.Discarded) { title = model.CreateUserName + "上传了项目图纸,已废弃"; #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传了项目图纸,已废弃"; app.Content = model.CreateUserName + "上传了项目图纸,已废弃"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Draw.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.Draw.GetText(); app.BusinessState = (int)(ApprovalState.Discarded); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Draw.GetText(), SystemRight.Invalid.GetText(), "废弃图纸生成待办: " + model.Id); #endregion } #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Draw.ToString(); modelMsg.ProjectId = model.ProjectId; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion var rows = DataOperateBusiness <Epm_Draw> .Get().Update(model); result.Data = rows; result.Flag = EResultFlag.Success; } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "RejectDraw"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddMaterial(MaterialView model) { Result <int> result = new Result <int>(); try { model.Epm_Material = SetCurrentUser(model.Epm_Material); model.Epm_Material = SetCreateUser(model.Epm_Material); model.Epm_Material.CompanyId = CurrentCompanyID.ToLongReq(); model.Epm_Material.CompanyName = CurrentCompanyName; DataOperateBusiness <Epm_Material> .Get().Add(model.Epm_Material); model.MaterialDetails.ForEach(item => { item.MaterialCheckId = model.Epm_Material.Id; item.CrtCompanyId = CurrentCompanyID.ToLongReq(); item.CrtCompanyName = CurrentCompanyName; item.CreateUserId = CurrentUserID.ToLongReq(); item.CreateUserName = CurrentUserName; item.CreateTime = DateTime.Now; item.State = 0; item = SetCurrentUser(item); item = SetCreateUser(item); }); DataOperateBusiness <Epm_MaterialDetails> .Get().AddRange(model.MaterialDetails); if (model.FileList.Count > 0) { AddFilesByTable(model.Epm_Material, model.FileList); //上传附件 } result.Data = 1; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Equipment.GetText(), SystemRight.Add.GetText(), "新增: " + model.Epm_Material.Id); if (model.Epm_Material.State == (int)ConfirmState.WaitConfirm) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.Epm_Material.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了工器具机械验收单,待审核"; app.Content = CurrentUserName + "提报了工器具机械验收单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Equipment.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Equipment.GetText(); app.BusinessState = (int)(ConfirmState.WaitConfirm); app.BusinessId = model.Epm_Material.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.Epm_Material.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Equipment.GetText(), SystemRight.Add.GetText(), "提交工器具机械验收生成待办: " + model.Epm_Material.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.Epm_Material.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了工器具机械验收单,待审核"; modelMsg.Content = CurrentUserName + "提报了工器具机械验收单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Epm_Material.Id; modelMsg.BussinesType = BusinessType.Equipment.ToString(); modelMsg.ProjectId = model.Epm_Material.ProjectId.Value; modelMsg.ProjectName = model.Epm_Material.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterSms = new Dictionary<string, string>(); //parameterSms.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.MaterialAdd, parameterSms); #endregion } } catch (Exception e) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(e, "AddMaterial"); } return(result); }
/// <summary> /// 上传危险作业实景 /// </summary> /// <param name="model">作业实景</param> /// <param name="files">相关附件</param> /// <returns></returns> public Result <bool> AddWorkRealScenen(Epm_WorkUploadRealScene model, List <Base_Files> files) { Result <bool> result = new Result <bool>(); try { if (model == null) { throw new Exception("请上传危险作业实景!"); } SetCurrentUser(model); SetCreateUser(model); DataOperateBusiness <Epm_WorkUploadRealScene> .Get().Add(model); if (files.Any()) { AddFilesByTable(model, files); } // TODO: 生成待办 if (model.State == (int)ApprovalState.WaitAppr) { //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.WorkId && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } var work = DataOperateBusiness <Epm_DangerousWork> .Get().GetModel(model.WorkId.Value); work.State = (int)ApprovalState.WorkPartAppr; DataOperateBusiness <Epm_DangerousWork> .Get().Update(work); #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "上传了危险作业实景,待审核"; app.Content = CurrentUserName + "上传了危险作业实景,待审核"; app.SendUserId = work.CreateUserId; app.SendUserName = work.CreateUserName; app.SendTime = work.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Dangerous.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Dangerous.GetText(); app.BusinessState = (int)(ApprovalState.WorkPartAppr); app.BusinessId = model.WorkId; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; app.IsApprover = true; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Dangerous.GetText(), SystemRight.Add.GetText(), "提交危险作业生成待办: " + model.Id); #endregion } result.Data = true; result.Flag = EResultFlag.Success; } catch (Exception ex) { result.Exception = new ExceptionEx(ex, "AddWorkRealScenen"); result.Flag = EResultFlag.Failure; result.Data = false; result.AllRowsCount = -1; } return(result); }
///<summary> ///修改: ///</summary> /// <param name="model">要修改的model</param> /// <returns>受影响的行数</returns> public Result <int> UpdateMaterial(MaterialView model) { Result <int> result = new Result <int>(); try { var oldModel = DataOperateBusiness <Epm_Material> .Get().GetModel(model.Epm_Material.Id); if (oldModel == null) { throw new Exception("该材料设备验收不存在或已被删除"); } model.Epm_Material = FiterUpdate(oldModel, model.Epm_Material); model.Epm_Material.CompanyId = oldModel.CompanyId; model.Epm_Material.CompanyName = oldModel.CompanyName; var row = DataOperateBusiness <Epm_Material> .Get().Update(model.Epm_Material); if (model.MaterialDetails.Count > 0) { //先删除 var detaileList = DataOperateBusiness <Epm_MaterialDetails> .Get().GetList(p => p.MaterialCheckId == model.Epm_Material.Id); if (detaileList.Any()) { DataOperateBusiness <Epm_MaterialDetails> .Get().DeleteRange(detaileList); } model.MaterialDetails.ForEach(item => { item.MaterialCheckId = model.Epm_Material.Id; item.CrtCompanyId = CurrentCompanyID.ToLongReq(); item.CrtCompanyName = CurrentCompanyName; item.CreateUserId = CurrentUserID.ToLongReq(); item.CreateUserName = CurrentUserName; item.CreateTime = DateTime.Now; item.State = 0; item = SetCurrentUser(item); item = SetCreateUser(item); }); DataOperateBusiness <Epm_MaterialDetails> .Get().AddRange(model.MaterialDetails); } //上传模型 if (model.FileList != null) { //删除之前的附件 DeleteFilesByTable(model.GetType().Name, new List <long>() { model.Epm_Material.Id }); //新增附件 AddFilesByTable(model.Epm_Material, model.FileList); } result.Data = row; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Equipment.GetText(), SystemRight.Add.GetText(), "修改: " + model.Epm_Material.Id); //处理待办 var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Epm_Material.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); } if (model.Epm_Material.State == (int)ConfirmState.WaitConfirm) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.Epm_Material.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了工器具机械验收单,待审核"; app.Content = CurrentUserName + "提报了工器具机械验收单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Equipment.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Equipment.GetText(); app.BusinessState = (int)(ConfirmState.WaitConfirm); app.BusinessId = model.Epm_Material.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.Epm_Material.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Equipment.GetText(), SystemRight.Add.GetText(), "提交工器具机械验收生成待办: " + model.Epm_Material.Id); #endregion #region 消息 Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = project.ContactUserId.Value; modelMsg.RecName = project.ContactUserName; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了工器具机械验收单,待审核"; modelMsg.Content = CurrentUserName + "提报了工器具机械验收单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Epm_Material.Id; modelMsg.BussinesType = BusinessType.Equipment.ToString(); modelMsg.ProjectId = model.Epm_Material.ProjectId.Value; modelMsg.ProjectName = model.Epm_Material.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); #endregion #region 发送短信 //Dictionary<string, string> parameters = new Dictionary<string, string>(); //parameters.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.MaterialAdd, parameters); #endregion } } catch (Exception e) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(e, "UpdateMaterial"); } return(result); }
/// <summary> /// 新增检查单 /// </summary> /// <param name="type">1:暂存</param> /// <returns></returns> public Result <bool> AddRectificationNew(long projectId, DateTime time, List <checkItemesPer> dataList, int type = 0) { Result <bool> result = new Result <bool>(); if (dataList == null && dataList.Count == 0) { throw new Exception("请填写检查相关内容!"); } ///获取项目信息 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(projectId); ///获取服务商信息 var companys = DataOperateBusiness <Epm_ProjectCompany> .Get().GetList(t => t.ProjectId == projectId).ToList(); #region 或者岗位角色roleType ///复查单位 long currentUserId = CurrentUserID.ToLongReq(); string roleType = ""; bool isAgency = IsAgencyUser(currentUserId); if (!isAgency) { bool isBranch = IsBranchCompanyUser(currentUserId); if (!isBranch) { bool isSupervisor = IsSupervisor(projectId, currentUserId); if (isSupervisor) { roleType = RoleTypeEnum.JL.GetText(); } else { roleType = RoleTypeEnum.ZJL.GetText(); } } else { roleType = RoleTypeEnum.FGS.GetText(); } } else { roleType = RoleTypeEnum.SGS.GetText(); } #endregion #region 检查单 ///获取检查配置数据 var checkItem = DataOperateBusiness <Epm_CheckItem> .Get().GetList(t => t.IsDelete == false).ToList(); ///复查数据 List <Epm_InspectItem> fhfcList = GetInspectItemByProjectId(projectId).Data; ///检查单对象 List <Epm_InspectItem> inspectItemList = new List <Epm_InspectItem>(); List <Epm_CheckItem> EpmCheckItemList = new List <Epm_CheckItem>(); Epm_CheckItem epmCheckItem = null; Epm_InspectItem inspectItem = null; List <Epm_InspectScore> scoreList = new List <Epm_InspectScore>(); Epm_InspectScore score = null; ///整改单对象 Dictionary <string, List <Epm_RectificationItem> > dic = new Dictionary <string, List <Epm_RectificationItem> >(); List <Epm_RectificationItem> rectifItemList = null; Epm_RectificationItem rectifItem2 = null; Epm_RectificationItem rectifItem3 = null; Dictionary <string, List <Epm_RectificationRecord> > recordList = new Dictionary <string, List <Epm_RectificationRecord> >(); List <Epm_RectificationRecord> rectifRecordList = null; Epm_RectificationRecord record = null; ///非常规作业 List <EPM_UnconventionalWork> unWorkList = new List <EPM_UnconventionalWork>(); EPM_UnconventionalWork work = null; ///一级名称 string name1 = string.Empty; foreach (var item1 in dataList) { ///保存检查单 Epm_Inspect inspect = new Epm_Inspect(); inspect.ProjectId = project.Id; inspect.ProjectName = project.Name; inspect.InspectName = "防渗改造项目施工检查表"; inspect.InspectAddress = project.Area + project.Address; inspect.InspectDate = time; inspect.InspectUserId = currentUserId; inspect.InspectUserName = CurrentUserName; inspect.IsDraft = type == 1 ? true : false; SetCreateUser(inspect); SetCurrentUser(inspect); foreach (var fenbu in item1.checkItems) { ///分步(一级) var fb = checkItem.Where(t => t.Id == fenbu.id.ToLongReq()).FirstOrDefault(); inspectItem = new Epm_InspectItem(); inspectItem.InspectId = inspect.Id; inspectItem.CheckId = fb.Id; inspectItem.CheckName = fb.Name; inspectItem.CheckParentId = fb.ParentId; inspectItem.CheckParentName = fb.ParentName; inspectItem.Level = fb.Level; inspectItem.Choice = true; SetCreateUser(inspectItem); SetCurrentUser(inspectItem); inspectItemList.Add(inspectItem); name1 = fb.Name; var fenxianglist = fenbu.children; if (fenxianglist.Count > 0) { foreach (var fenxiang in fenxianglist) { rectifItemList = new List <Epm_RectificationItem>(); rectifRecordList = new List <Epm_RectificationRecord>(); ///分项 var fx = checkItem.Where(t => t.Id == fenxiang.id.ToLongReq()).FirstOrDefault(); if (fx != null) { #region 检查单二级 inspectItem = new Epm_InspectItem(); inspectItem.InspectId = inspect.Id; inspectItem.CheckId = fx.Id; inspectItem.CheckName = fx.Name; inspectItem.CheckParentId = fx.ParentId; inspectItem.CheckParentName = fx.ParentName; inspectItem.Level = fx.Level; inspectItem.Choice = true; SetCreateUser(inspectItem); SetCurrentUser(inspectItem); inspectItemList.Add(inspectItem); #endregion #region 整改单,整改项2级数据准备 ///整改单,整改项2级数据准备 if (!inspect.IsDraft.Value && fenxiang.children.Count > 0) { rectifItem2 = new Epm_RectificationItem(); rectifItem2.CheckId = fx.Id; rectifItem2.CheckName = fx.Name; rectifItem2.CheckParentId = fx.ParentId; rectifItem2.CheckParentName = fx.ParentName; rectifItem2.Level = fx.Level; SetCreateUser(rectifItem2); SetCurrentUser(rectifItem2); record = new Epm_RectificationRecord(); record.RectficationItemId = rectifItem2.Id; record.RectficationDescption = string.Empty; record.State = (int)RectificationState.WaitRectification; SetCreateUser(record); SetCurrentUser(record); } #endregion } //三级 var itemlist = fenxiang.children; if (itemlist.Count > 0) { foreach (var item in itemlist) { long ids = 0; var check = new Epm_CheckItem(); //具体要求 if (item.id == "") { epmCheckItem = new Epm_CheckItem(); epmCheckItem.ParentId = fx.Id; epmCheckItem.ParentName = fx.ParentName; epmCheckItem.Level = 3; epmCheckItem.Remark = itemlist[0].name; epmCheckItem.CrtCompanyId = long.Parse("902414008118808576"); epmCheckItem.CrtCompanyName = "管理员企业"; epmCheckItem.IsDelete = false; epmCheckItem.RectificationManName = dataList[0].companies[0].personnelList[0].name; epmCheckItem.ScoreRange = itemlist[0].addScore; epmCheckItem.ScoreCompany = dataList[0].companies[0].id; epmCheckItem.ScorePerson = dataList[0].companies[0].personnelList[0].id; SetCreateUser(epmCheckItem); SetCurrentUser(epmCheckItem); EpmCheckItemList.Add(epmCheckItem); DataOperateBusiness <Epm_CheckItem> .Get().AddRange(EpmCheckItemList); check = epmCheckItem; } else { check = checkItem.Where(t => t.Id == item.id.ToLongReq()).FirstOrDefault(); } if (check != null) { inspectItem = new Epm_InspectItem(); inspectItem.InspectId = inspect.Id; inspectItem.CheckId = check.Id; inspectItem.CheckName = check.Remark; inspectItem.CheckParentId = check.ParentId; inspectItem.CheckParentName = check.ParentName; inspectItem.Level = check.Level; inspectItem.Choice = true; inspectItem.RectifRecordPersonKey = check.RectificationManName == null ? "" : check.RectificationManName; inspectItem.RectifRecordPerson = check.RectificationManName == null ? "" : check.RectificationManName; inspectItem.ScoreMax = check.ScoreRange.Split(',')[0] == null ? 0 : int.Parse(check.ScoreRange.Split(',')[0]); //inspectItem.Score = check.ScoreRange == null ? 0 : decimal.Parse(check.ScoreRange); inspectItem.Score = decimal.Parse(item.addScore); //inspectItem.State = item1.checkItems[0].selected.ToLower() == "false" ? 0 : (int)RectificationState.WaitRectification; inspectItem.State = check.State = false ? 0 : (int)RectificationState.WaitRectification; SetCreateUser(inspectItem); SetCurrentUser(inspectItem); inspectItemList.Add(inspectItem); #region 得失分单位、人员 //得失分单位、人员 var companylist = string.IsNullOrEmpty(check.ScoreCompany) ? null : check.ScoreCompany.Split(',').ToList(); var userlist = string.IsNullOrEmpty(check.ScorePerson) ? null : check.ScorePerson.Split(',').ToList(); var scoreCompanyUser = GetGainLoss(companylist, userlist, project, companys); if (scoreCompanyUser != null) { foreach (var cu in scoreCompanyUser) { var company = cu.Key.Split(','); if (string.IsNullOrEmpty(cu.Value)) { score = new Epm_InspectScore(); score.InspectId = inspect.Id; score.InspectItemId = inspectItem.Id; score.GainLossCompanyId = string.IsNullOrEmpty(company[0]) ? 0 : company[0].ToLongReq(); score.GainLossCompanyName = string.IsNullOrEmpty(company[1]) ? "" : company[1]; SetCreateUser(score); SetCurrentUser(score); scoreList.Add(score); } else { var list = cu.Value.Split(';').ToList(); foreach (var cv in list) { if (!string.IsNullOrEmpty(cv)) { score = new Epm_InspectScore(); score.InspectId = inspect.Id; score.InspectItemId = inspectItem.Id; score.GainLossCompanyId = string.IsNullOrEmpty(company[0]) ? 0 : company[0].ToLongReq(); score.GainLossCompanyName = string.IsNullOrEmpty(company[1]) ? "" : company[1]; var user = cv.Split(','); score.GainLossUserId = string.IsNullOrEmpty(user[0]) ? 0 : user[0].ToLongReq(); score.GainLossUserName = string.IsNullOrEmpty(user[1]) ? "" : user[1]; SetCreateUser(score); SetCurrentUser(score); scoreList.Add(score); } } } } } #endregion #region 整改单,整改项3级数据准备 if (!inspect.IsDraft.Value) { rectifItem3 = new Epm_RectificationItem(); rectifItem3.CheckId = check.Id; rectifItem3.CheckName = check.Remark; rectifItem3.CheckParentId = check.ParentId; rectifItem3.CheckParentName = check.ParentName; rectifItem3.Level = check.Level; SetCreateUser(rectifItem3); SetCurrentUser(rectifItem3); if (item1.companies[0].personnelList.Any()) { rectifItemList = new List <Epm_RectificationItem>(); rectifRecordList = new List <Epm_RectificationRecord>(); var materialLists = new List <checkItemesPer>(); if (!dic.Keys.Contains(item1.companies[0].personnelList[0].id)) { rectifItemList.Add(rectifItem2); rectifItemList.Add(rectifItem3); dic[item1.companies[0].personnelList[0].id] = rectifItemList; rectifRecordList.Add(record); recordList[item1.companies[0].personnelList[0].id] = rectifRecordList; } else { Epm_RectificationItem item2 = dic[item1.companies[0].personnelList[0].id].Where(t => t.Id == rectifItem2.Id).FirstOrDefault(); if (item2 != null) { dic[item1.companies[0].personnelList[0].id].Add(rectifItem3); } else { rectifItemList.Add(rectifItem2); rectifItemList.Add(rectifItem3); dic[item1.companies[0].personnelList[0].id].AddRange(rectifItemList); rectifRecordList.Add(record); recordList[item1.companies[0].personnelList[0].id].AddRange(rectifRecordList); } } } } #endregion } } } } } } //删除草稿数据 //var delInspect = DataOperateBusiness<Epm_Inspect>.Get().GetList(t => t.ProjectId == projectId && t.InspectUserId == currentUserId && t.IsDraft.Value).FirstOrDefault(); //if (delInspect != null) //{ // var delItems = DataOperateBusiness<Epm_InspectItem>.Get().GetList(t => t.InspectId == delInspect.Id); // var delScores = DataOperateBusiness<Epm_InspectScore>.Get().GetList(t => t.InspectId == delInspect.Id); // var unWorks = DataOperateBusiness<EPM_UnconventionalWork>.Get().GetList(t => t.InspectId == delInspect.Id); // DataOperateBusiness<Epm_Inspect>.Get().Delete(delInspect); // DataOperateBusiness<Epm_InspectItem>.Get().DeleteRange(delItems); // DataOperateBusiness<Epm_InspectScore>.Get().DeleteRange(delScores); // DataOperateBusiness<EPM_UnconventionalWork>.Get().DeleteRange(unWorks); //} ///保存检查单 DataOperateBusiness <Epm_Inspect> .Get().Add(inspect); DataOperateBusiness <Epm_InspectItem> .Get().AddRange(inspectItemList); DataOperateBusiness <Epm_InspectScore> .Get().AddRange(scoreList); DataOperateBusiness <EPM_UnconventionalWork> .Get().AddRange(unWorkList); #region 生成待办 Epm_Approver appInspect = new Epm_Approver(); appInspect.Title = CurrentUserName + "已完成本次现场检查"; appInspect.Content = CurrentUserName + "已完成本次现场检查"; appInspect.SendUserId = CurrentUser.Id; appInspect.SendUserName = CurrentUserName; appInspect.SendTime = DateTime.Now; appInspect.LinkURL = string.Empty; appInspect.BusinessTypeNo = BusinessType.SecurityCheck.ToString(); appInspect.Action = SystemRight.Add.ToString(); appInspect.BusinessTypeName = BusinessType.SecurityCheck.GetText(); appInspect.BusinessState = (int)(RectificationState.WorkFinish); appInspect.BusinessId = inspect.Id; appInspect.ApproverId = inspect.InspectUserId; appInspect.ApproverName = inspect.InspectUserName; appInspect.ProjectId = project.Id; appInspect.ProjectName = project.Name; AddApproverBatch(new List <Epm_Approver>() { appInspect }); WriteLog(BusinessType.Rectification.GetText(), SystemRight.Add.GetText(), "阶段检查生成检查待办: " + inspect.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(inspect.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = currentUserId; modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "已完成本次现场检查"; modelMsg.Content = CurrentUserName + "已完成本次现场检查"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = inspect.Id; modelMsg.BussinesType = BusinessType.SecurityCheck.ToString(); modelMsg.ProjectId = inspect.ProjectId; modelMsg.ProjectName = inspect.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #endregion #region 整改单 foreach (var key in dic.Keys) { var rectifUser = GetRectif(key, project, companys); if (!string.IsNullOrEmpty(rectifUser)) { var rectif = new Epm_Rectification(); rectif.ProjectId = project.Id; rectif.ProjectName = project.Name; rectif.InsppectId = inspect.Id; rectif.RectificateTitle = "防渗改造项目施工检查表"; rectif.InspectAddress = project.Area + project.Address; rectif.InspectDate = time; rectif.InspectUserId = currentUserId; rectif.InspectUserName = CurrentUserName; if (rectifUser == null) { rectif.RectifRecordUserId = long.Parse("缺失"); rectif.RectifRecordUserName = "******"; } else { rectif.RectifRecordUserId = string.IsNullOrEmpty(rectifUser.Split(',')[0]) ? 0 : rectifUser.Split(',')[0].ToLongReq(); rectif.RectifRecordUserName = rectifUser.Split(',')[1]; } rectif.State = (int)RectificationState.WaitRectification; SetCreateUser(rectif); SetCurrentUser(rectif); DataOperateBusiness <Epm_Rectification> .Get().Add(rectif); var rectificateItem = dic[key]; foreach (var item in rectificateItem) { item.RectificationId = rectif.Id; item.State = (int)RectificationState.WaitRectification; } DataOperateBusiness <Epm_RectificationItem> .Get().AddRange(rectificateItem); var recordModel = recordList[key]; foreach (var item in recordModel) { item.RectficationId = rectif.Id; } DataOperateBusiness <Epm_RectificationRecord> .Get().AddRange(recordModel); var imagesList = item1.files; if (imagesList != null && imagesList.Count > 0) { foreach (var item in imagesList) { long id = item.id.ToLongReq(); Base_Files baseFiles = DataOperateBasic <Base_Files> .Get().GetModel(id); if (item.type == "0") { baseFiles.IsDelete = false; } else { baseFiles.IsDelete = true; } List <Base_Files> guidList = DataOperateBasic <Base_Files> .Get().GetList(t => t.GuidId == baseFiles.GuidId).ToList(); foreach (var temp in guidList) { temp.TableName = "Epm_RectificationRecord"; temp.TableId = rectif.Id; temp.IsDelete = baseFiles.IsDelete; } DataOperateBasic <Base_Files> .Get().UpdateRange(guidList); } } #region 生成待办 Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "进行现场检查发现问题,请处理"; app.Content = CurrentUserName + "进行现场检查发现问题,请处理"; app.SendUserId = CurrentUser.Id; app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Rectification.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Rectification.GetText(); app.BusinessState = (int)(RectificationState.WaitRectification); app.BusinessId = rectif.Id; app.ApproverId = rectif.RectifRecordUserId; app.ApproverName = rectif.RectifRecordUserName; app.ProjectId = project.Id; app.ProjectName = project.Name; AddApproverBatch(new List <Epm_Approver>() { app }); WriteLog(BusinessType.Rectification.GetText(), SystemRight.Add.GetText(), "阶段检查生成整改待办: " + rectif.Id); #endregion } } } #endregion result.Data = true; result.Flag = EResultFlag.Success; return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddBim(Epm_Bim model, List <Base_Files> fileListFile) { Result <int> result = new Result <int>(); try { model = base.SetCurrentUser(model); model.CrtCompanyId = CurrentCompanyID.ToLongReq(); model.CrtCompanyName = CurrentCompanyName; //bool dConfig = DataOperateBusiness<Epm_Bim>.Get().Count(i => i.Name == model.Name) > 0; //if (dConfig) //{ // throw new Exception("该模型名称已经存在"); //} var rows = DataOperateBusiness <Epm_Bim> .Get().Add(model); //上传模型 if (fileListFile != null) { AddFilesByTable(model, fileListFile); } //生成代办消息 if ((ApprovalState)model.State == ApprovalState.WaitAppr) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "上传了BIM模型,待审核"; app.Content = CurrentUserName + "上传了BIM模型,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Model.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Model.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = model.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Model.GetText(), SystemRight.Add.GetText(), "提交模型生成待办: " + model.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "上传了BIM模型,待审核"; modelMsg.Content = CurrentUserName + "上传了BIM模型,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Model.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterSms = new Dictionary<string, string>(); //parameterSms.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.ModelAdd, parameterSms); #endregion } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Model.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddBim"); } return(result); }
/// <summary> /// 新增延期申请 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <bool> AddPlanDelay(PlanDelayView model) { Result <bool> result = new Result <bool>(); try { if (model == null) { throw new Exception("请填写延期申请内容!"); } Epm_Plan plan = DataOperateBusiness <Epm_Plan> .Get().GetModel(model.PlanId); if (plan == null) { throw new Exception("所选计划信息不存在!"); } //if (!CurrentProjectIds.Contains(plan.ProjectId.ToString())) //{ // throw new Exception("你未负责该项目,无权对该项目下的计划进行延期申请!"); //} var listp = DataOperateBusiness <Epm_PlanDelay> .Get().GetList(t => (t.State == (int)ApprovalState.WaitAppr || t.State == (int)ApprovalState.Enabled) && t.ProjectId == model.ProjectId && t.PlanId == model.PlanId).ToList(); if (listp.Count > 0) { throw new Exception("你选择的工程节点已经存在待审核或者草稿状态的延期申请!"); } Epm_PlanDelay delay = new Epm_PlanDelay(); delay.Id = model.Id; delay.ProjectId = model.ProjectId; delay.ProjectName = model.ProjectName; delay.PlanId = model.PlanId; delay.PlanName = model.PlanName; delay.OldStartDate = plan.StartTime.Value; delay.OldEndDate = plan.EndTime.Value; delay.DelayDay = model.DelayDay; delay.Reason = model.Reason; delay.Remark = model.Remark; delay.State = model.State; delay.CreateDate = DateTime.Today; delay.ApplyCompanyId = CurrentUser.CompanyId; delay.ApplyCompanyName = CurrentCompanyName; delay.State = model.State; SetCreateUser(delay); SetCurrentUser(delay); if (!model.PlanDelayCompanys.Any()) { throw new Exception("请选择责任单位!"); } model.PlanDelayCompanys.ForEach(p => { p.DelayId = model.Id; p.ProjectId = model.ProjectId; p.ProjectName = model.ProjectName; p.State = delay.State; SetCreateUser(p); SetCurrentUser(p); }); DataOperateBusiness <Epm_PlanDelayCompany> .Get().AddRange(model.PlanDelayCompanys); DataOperateBusiness <Epm_PlanDelay> .Get().Add(delay); // todo: 如果是提交审核,添加消息推送 if (delay.State == (int)ApprovalState.WaitAppr) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(delay.ProjectId); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提报了变更计划单,待审核"; app.Content = CurrentUserName + "提报了变更计划单,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.DelayApply.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.DelayApply.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = delay.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = delay.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.DelayApply.GetText(), SystemRight.Add.GetText(), "提交延期申请生成待办: " + delay.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提报了变更计划单,待审核"; modelMsg.Content = CurrentUserName + "提报了变更计划单,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.DelayApply.ToString(); modelMsg.ProjectId = model.ProjectId; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterssm = new Dictionary<string, string>(); //parameterssm.Add("UserName", CurrentUserName); //WriteSMS(project.ContactUserId.Value, project.CompanyId, MessageStep.DelayApplyAdd, parameterssm); #endregion } result.Data = true; result.Flag = EResultFlag.Success; // todo:写操作日志 } catch (Exception ex) { result.Flag = EResultFlag.Failure; result.Data = false; result.Exception = new ExceptionEx(ex, "AddPlanDelay"); } return(result); }
///// <summary> ///// 新增工程内容要点 ///// </summary> ///// <param name="model"></param> ///// <returns></returns> //public Result<bool> AddProjectWorkPoint(Epm_ProjectWorkMainPoints model) //{ // Result<bool> result = new Result<bool>(); // try // { // var data = DataOperateBusiness<Epm_ProjectWorkMainPoints>.Get().Single(p => p.ProjectId == model.ProjectId && p.WorkMainPointsValue == model.WorkMainPointsValue); // if (data != null) // { // throw new Exception(string.Format("该项目下已存在同名【{0}】工程内容要点!", model.WorkMainPointsValue)); // } // SetCreateUser(model); // SetCurrentUser(model); // DataOperateBusiness<Epm_ProjectWorkMainPoints>.Get().Add(model); // result.Data = true; // result.Flag = EResultFlag.Success; // } // catch (Exception ex) // { // result.Data = false; // result.Flag = EResultFlag.Failure; // result.Exception = new ExceptionEx(ex, "AddProjectWorkPoint"); // } // return result; //} ///// <summary> ///// 根据 ID 修改工程内容要点 ///// </summary> ///// <param name="model"></param> ///// <returns></returns> //public Result<bool> UpdateProjectWorkPointById(Epm_ProjectWorkMainPoints model) //{ // Result<bool> result = new Result<bool>(); // try // { // var data = DataOperateBusiness<Epm_ProjectWorkMainPoints>.Get().GetModel(model.Id); // if (data == null) // { // throw new Exception("内容不存在或已被删除!"); // } // Epm_ProjectWorkMainPointsHistory historyModel = new Epm_ProjectWorkMainPointsHistory(); // //historyModel.Id = data.Id; // historyModel.ProjectId = data.ProjectId; // historyModel.WorkMainPointsKey = data.WorkMainPointsKey; // historyModel.WorkMainPointsValue = data.WorkMainPointsValue; // historyModel.IsCharging = data.IsCharging; // historyModel.CompanyId = data.CompanyId; // historyModel.CompanyName = data.CompanyName; // historyModel.Qty = data.Qty; // historyModel.Description = data.Description; // historyModel.Sort = data.Sort; // historyModel.CreateTime = data.CreateTime; // historyModel.CreateUserId = data.CreateUserId; // historyModel.CreateTime = data.CreateTime; // historyModel.OperateUserId = data.OperateUserId; // historyModel.OperateUserName = data.OperateUserName; // historyModel.OperateTime = data.OperateTime; // historyModel.IsDelete = false; // DataOperateBusiness<Epm_ProjectWorkMainPointsHistory>.Get().Add(historyModel); // data.ProjectId = model.ProjectId; // data.WorkMainPointsValue = model.WorkMainPointsValue; // data.CompanyName = model.CompanyName; // data.Qty = model.Qty; // data.Description = model.Description; // SetCurrentUser(data); // DataOperateBusiness<Epm_ProjectWorkMainPoints>.Get().Update(data); // #region 消息 // var project = DataOperateBusiness<Epm_Project>.Get().GetModel(data.ProjectId.Value); // var waitSend = GetWaitSendMessageList(project.Id); // foreach (var send in waitSend) // { // Epm_Massage modelMsg = new Epm_Massage(); // modelMsg.ReadTime = null; // modelMsg.RecId = send.Key; // modelMsg.RecName = send.Value; // modelMsg.RecTime = DateTime.Now; // modelMsg.SendId = CurrentUserID.ToLongReq(); // modelMsg.SendName = CurrentUserName; // modelMsg.SendTime = DateTime.Now; // modelMsg.Title = CurrentUserName + "更新工程内容要点信息"; // modelMsg.Content = CurrentUserName + "更新工程内容要点信息"; // modelMsg.Type = 2; // modelMsg.IsRead = false; // modelMsg.BussinessId = project.Id; // modelMsg.BussinesType = BusinessType.Project.ToString(); // modelMsg.BussinesChild = "WorkPoints"; // modelMsg.ProjectId = project.Id; // modelMsg.ProjectName = project.Name; // modelMsg = base.SetCurrentUser(modelMsg); // modelMsg = base.SetCreateUser(modelMsg); // DataOperateBusiness<Epm_Massage>.Get().Add(modelMsg); // } // #endregion // result.Data = true; // result.Flag = EResultFlag.Success; // } // catch (Exception ex) // { // result.Data = false; // result.Flag = EResultFlag.Failure; // result.Exception = new ExceptionEx(ex, "UpdateProjectWorkPointById"); // } // return result; //} /// <summary> /// 修改项目供应商负责人及项目经理 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <bool> UpdateProjectCompanyPmInfo(Epm_ProjectCompany projectCompany, long userId) { Result <bool> result = new Result <bool>(); int rows = -1; try { Epm_ProjectCompany pc = DataOperateBusiness <Epm_ProjectCompany> .Get().GetModel(projectCompany.Id); if (pc == null) { throw new Exception("供应商信息不存在或已被删除!"); } #region 更新项目经理信息 if (IsBranchCompanyUser(userId))//是否分公司 { //分公司修改不需要审核 pc.PMId_New = projectCompany.PMId_New; pc.PM_New = projectCompany.PM_New; pc.PMPhone_New = projectCompany.PMPhone_New; pc.PMId = projectCompany.PMId_New; pc.PM = projectCompany.PM_New; pc.PMPhone = projectCompany.PMPhone_New; pc.LinkManId_New = projectCompany.LinkManId_New; pc.LinkMan_New = projectCompany.LinkMan_New; pc.LinkPhone_New = projectCompany.LinkPhone_New; pc.LinkManId = projectCompany.LinkManId_New; pc.LinkMan = projectCompany.LinkMan_New; pc.LinkPhone = projectCompany.LinkPhone_New; pc.SafeManId = projectCompany.SafeManId_New; pc.SafeMan = projectCompany.SafeMan_New; pc.SafePhone = projectCompany.SafePhone_New; pc.SafeManId_New = projectCompany.SafeManId_New; pc.SafeMan_New = projectCompany.SafeMan_New; pc.SafePhone_New = projectCompany.SafePhone_New; pc.State = (int)ApprovalState.ApprSuccess; pc = base.FiterUpdate(pc, pc); pc.State = (int)ApprovalState.ApprSuccess; rows = DataOperateBusiness <Epm_ProjectCompany> .Get().Update(pc); } else { pc.PMId_New = projectCompany.PMId_New; pc.PM_New = projectCompany.PM_New; pc.PMPhone_New = projectCompany.PMPhone_New; pc.LinkManId_New = projectCompany.LinkManId_New; pc.LinkMan_New = projectCompany.LinkMan_New; pc.LinkPhone_New = projectCompany.LinkPhone_New; pc.SafeManId_New = projectCompany.SafeManId_New; pc.SafeMan_New = projectCompany.SafeMan_New; pc.SafePhone_New = projectCompany.SafePhone_New; pc.State = (int)ApprovalState.WaitAppr; pc = base.FiterUpdate(pc, pc); rows = DataOperateBusiness <Epm_ProjectCompany> .Get().Update(pc); #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "更新了服务商用户信息,待审核"; app.Content = CurrentUserName + "更新了服务商用户信息,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Project.ToString(); app.BussinesChild = "ISP"; app.Action = SystemRight.Modify.ToString(); app.BusinessTypeName = BusinessType.Project.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = pc.Id; var project = DataOperateBusiness <Epm_Project> .Get().GetModel(pc.ProjectId.Value); app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = pc.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Project.GetText(), SystemRight.Modify.GetText(), "服务商用户信息更新生成待办: " + pc.ProjectId); #endregion } #endregion result.Flag = EResultFlag.Success; result.Data = true; } catch (Exception ex) { result.Flag = EResultFlag.Failure; result.Data = false; result.Exception = new ExceptionEx(ex, "UpdateProjectCompanyPmInfo"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddChange(ChangeView model, List <Base_Files> fileList = null) { Result <int> result = new Result <int>(); try { Epm_Change change = new Epm_Change(); List <Epm_ChangeCompany> companys = new List <Epm_ChangeCompany>(); model.Id = change.Id; ViewToEmp(model, out change, out companys); bool dConfig = DataOperateBusiness <Epm_Change> .Get().Count(i => i.ProjectId == change.ProjectId && i.State != (int)ApprovalState.ApprSuccess) > 0; if (dConfig) { throw new Exception("已存在该项目的变更申请!"); } var dictionaryList = DataOperateBasic <Base_TypeDictionary> .Get().GetList(t => t.Type == DictionaryType.ChangeRatio.ToString() && t.No == "ReduceRatio").ToList().FirstOrDefault(); if (change.ChangeAmount < 0 && change.State == (int)ApprovalState.WaitAppr) { int ratio = Convert.ToInt32(dictionaryList.Name); if ((-change.ChangeAmount) < change.TotalAmount * ((decimal)ratio / 100)) { change.State = (int)ApprovalState.ApprSuccess; model.State = (int)ApprovalState.ApprSuccess; } } var rows = DataOperateBusiness <Epm_Change> .Get().Add(change); DataOperateBusiness <Epm_ChangeCompany> .Get().AddRange(companys); //新增附件 AddFilesByTable(change, fileList); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Change.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); if (model.State == (int)ApprovalState.ApprSuccess) { var project = DataOperateBusiness <Epm_Project> .Get().GetList(t => t.Id == model.ProjectId).FirstOrDefault(); if (project != null) { project.Amount = model.TotalAmount + model.ChangeAmount; DataOperateBusiness <Epm_Project> .Get().Update(project); } } if (model.State == (int)ApprovalState.WaitAppr) { if (companys.Any() && companys.Count > 0) { for (int i = 0; i < companys.Count; i++) { var comID = companys[i].CompanyId; var temp = DataOperateBusiness <Epm_ProjectStateTrack> .Get().GetList(t => t.CompanyId == comID).FirstOrDefault(); if (temp != null) { temp.Qty = (Convert.ToInt32(temp.Qty) + 1).ToString(); DataOperateBusiness <Epm_ProjectStateTrack> .Get().Update(temp); } } } WriteLog(BusinessType.Change.GetText(), SystemRight.Add.GetText(), "生成消息: " + model.Id); var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提交了变更申请,待审核"; app.Content = CurrentUserName + "提交了变更申请,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Change.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Change.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = model.Id; app.ApproverId = project.PMId; app.ApproverName = project.PMName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Change.GetText(), SystemRight.Add.GetText(), "提交变更生成待办: " + model.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提交了变更申请,待审核"; modelMsg.Content = CurrentUserName + "提交了变更申请,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Change.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterSms = new Dictionary<string, string>(); //parameterSms.Add("UserName", CurrentUserName); //WriteSMS(project.PMId.Value, 0, MessageStep.ChangeAdd, parameterSms); #endregion } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddChange"); } return(result); }
/// <summary> /// 审核延期申请 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <int> AuditPlanDelay(Epm_PlanDelay model) { Result <int> result = new Result <int>(); try { if (model == null) { throw new Exception("请选择要审核的延期申请!"); } Epm_PlanDelay planDelay = DataOperateBusiness <Epm_PlanDelay> .Get().GetModel(model.Id); if (planDelay == null) { throw new Exception("要审核的延期申请不存在!"); } // todo: 判断延期申请的状态, 是否可以进行审核 var list = DataOperateBusiness <Epm_PlanDelayCompany> .Get().GetList(p => p.DelayId == model.Id).ToList(); planDelay.State = model.State; planDelay.AuditDate = DateTime.Today; planDelay.AuditUserId = CurrentUser.Id; planDelay.AuditUserName = CurrentUserName; planDelay.OrgId = CurrentUser.CompanyId; planDelay.OrgName = CurrentCompanyName; SetCurrentUser(planDelay); list.ForEach(p => { SetCurrentUser(p); p.State = planDelay.State; }); DataOperateBusiness <Epm_PlanDelay> .Get().Update(planDelay); DataOperateBusiness <Epm_PlanDelayCompany> .Get().UpdateRange(list); //处理待办 var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == planDelay.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); } string title = ""; if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprSuccess) { //更新计划里的延期计划完工时间 Epm_Plan plan = DataOperateBusiness <Epm_Plan> .Get().GetModel(planDelay.PlanId); plan.DelayTime = plan.EndTime.Value.AddDays(double.Parse(planDelay.DelayDay.ToString())); DateTime start = Convert.ToDateTime(plan.StartTime); DateTime end = Convert.ToDateTime(plan.DelayTime); TimeSpan sp = end.Subtract(start); int days = sp.Days + 1; plan.BuildDays = days > 0 ? days : 0; SetCurrentUser(plan); DataOperateBusiness <Epm_Plan> .Get().Update(plan); title = planDelay.CreateUserName + "提报的变更计划单,审核通过"; #region 生成待办 List <Epm_Approver> listApp = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = planDelay.CreateUserName + "提报的变更计划单,审核通过"; app.Content = planDelay.CreateUserName + "提报的变更计划单,审核通过"; app.SendUserId = planDelay.CreateUserId; app.SendUserName = planDelay.CreateUserName; app.SendTime = planDelay.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.DelayApply.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.DelayApply.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = planDelay.Id; app.ApproverId = planDelay.CreateUserId; app.ApproverName = planDelay.CreateUserName; app.ProjectId = planDelay.ProjectId; app.ProjectName = planDelay.ProjectName; listApp.Add(app); AddApproverBatch(listApp); WriteLog(BusinessType.DelayApply.GetText(), SystemRight.Check.GetText(), "审核通过延期申请生成待办: " + model.Id); #endregion } else if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprFailure) { title = planDelay.CreateUserName + "提报的变更计划单已被驳回,请处理"; #region 生成待办 List <Epm_Approver> listApp = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = planDelay.CreateUserName + "提报的变更计划单已被驳回,请处理"; app.Content = planDelay.CreateUserName + "提报的变更计划单已被驳回,请处理"; app.SendUserId = planDelay.CreateUserId; app.SendUserName = planDelay.CreateUserName; app.SendTime = planDelay.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.DelayApply.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.DelayApply.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = planDelay.Id; app.ApproverId = planDelay.CreateUserId; app.ApproverName = planDelay.CreateUserName; app.ProjectId = planDelay.ProjectId; app.ProjectName = planDelay.ProjectName; listApp.Add(app); AddApproverBatch(listApp); WriteLog(BusinessType.DelayApply.GetText(), SystemRight.UnCheck.GetText(), "驳回延期申请生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.DelayApplyReject, null); #endregion } else if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.Discarded) { title = planDelay.CreateUserName + "提报了变更计划单,已废弃"; #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(planDelay.ProjectId); List <Epm_Approver> listApp = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = planDelay.CreateUserName + "提报了变更计划单,已废弃"; app.Content = planDelay.CreateUserName + "提报了变更计划单,已废弃"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.DelayApply.ToString(); app.Action = SystemRight.Invalid.ToString(); app.BusinessTypeName = BusinessType.DelayApply.GetText(); app.BusinessState = (int)(ApprovalState.Discarded); app.BusinessId = planDelay.Id; app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; app.ProjectId = planDelay.ProjectId; app.ProjectName = project.Name; listApp.Add(app); AddApproverBatch(listApp); WriteLog(BusinessType.DelayApply.GetText(), SystemRight.Invalid.GetText(), "废弃延期申请生成待办: " + planDelay.Id); #endregion } #region 消息 var waitSend = GetWaitSendMessageList(planDelay.ProjectId); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = planDelay.Id; modelMsg.BussinesType = BusinessType.DelayApply.ToString(); modelMsg.ProjectId = planDelay.ProjectId; modelMsg.ProjectName = planDelay.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion result.Data = 1; result.Flag = EResultFlag.Success; // todo: 添加消息推送 // todo:写操作日志 } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AuditPlanDelay"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddQuestion(QuestionView model) { Result <int> result = new Result <int>(); try { List <int> statelist = new List <int>() { (int)ApprovalState.WaitAppr, (int)ApprovalState.ApprSuccess }; try { var completion = DataOperateBusiness <Epm_CompletionAcceptance> .Get().GetList(t => t.ProjectId == model.ProjectId && statelist.Contains(t.State.Value)).FirstOrDefault(); if (completion != null) { throw new Exception("沟通项目已发起完工验收,不可操作!"); } if (model == null) { throw new Exception("请填写问题相关内容!"); } if (model.ProjectId <= 0) { throw new Exception("请选择问题项目名称!"); } } catch (Exception ex) { WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "字符串截取位置1: " + model.ProjectId); } model.BusinessTypeNo = GetString(model.BusinessTypeNo); var BusinessTypeName = ((BusinessType)Enum.Parse(typeof(BusinessType), model.BusinessTypeNo)).GetText(); Epm_Question question = new Epm_Question() { ProjectId = model.ProjectId, ProjectName = model.ProjectName, Title = model.Title, Description = model.Description, Proposal = model.Proposal, IsAccident = model.IsAccident, BusinessTypeNo = model.BusinessTypeNo, BusinessTypeName = BusinessTypeName, BusinessId = model.BusinessId, SubmitUserId = CurrentUserID.ToLongReq(), SubmitUserName = CurrentUserName, SubmitCompanyId = CurrentCompanyID.ToLongReq(), SubmitCompanyName = CurrentCompanyName, SubmitTime = DateTime.Now, RecCompanyId = model.RecCompanyId, RecCompanyName = model.RecCompanyName, RecUserId = model.RecUserId, RecUserName = model.RecUserName, State = 1, CrtCompanyId = CurrentCompanyID.ToLongReq(), CrtCompanyName = CurrentCompanyName, CreateTime = DateTime.Now, IsDelete = false, ProblemTypeName = model.ProblemTypeName, ProblemTypeNo = model.ProblemTypeNo }; question = SetCurrentUser(question); if (question == null) { throw new Exception("问题沟通!"); } #region 问题关联模型 if (model.QuestionBims != null && model.QuestionBims.Any()) { model.QuestionBims.ForEach(p => { p.Sort = p.Sort ?? 0; p.State = p.State ?? 0; p.CrtCompanyId = question.CrtCompanyId; p.CrtCompanyName = question.CrtCompanyName; p.CreateTime = DateTime.Now; p.CreateUserId = question.CreateUserId; p.CreateUserName = question.CreateUserName; p.OperateUserId = question.OperateUserId; p.OperateUserName = question.OperateUserName; p.OperateTime = DateTime.Now; p.IsDelete = false; }); } #endregion #region 问题协助人员 if (model.QuestionUsers != null && model.QuestionUsers.Any()) { model.QuestionUsers.ForEach(p => { p.State = p.State ?? 0; p.CrtCompanyId = question.CrtCompanyId; p.CrtCompanyName = question.CrtCompanyName; p.CreateTime = DateTime.Now; p.CreateUserId = question.CreateUserId; p.CreateUserName = question.CreateUserName; p.OperateUserId = question.OperateUserId; p.OperateUserName = question.OperateUserName; p.OperateTime = DateTime.Now; p.IsDelete = false; }); } #endregion try { int rows = DataOperateBusiness <Epm_Question> .Get().Add(question); if (model.QuestionBims != null && model.QuestionBims.Any()) { try { model.QuestionBims.ForEach(p => { p.QuestionId = question.Id; p.BIMId = p.ComponentId.Split('_')[0].ToLongReq(); }); DataOperateBusiness <Epm_QuestionBIM> .Get().AddRange(model.QuestionBims); } catch (Exception ex) { WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "字符串截取位置2: " + model.QuestionBims[0].ComponentId.Split('_')[0].ToLongReq()); } } if (model.QuestionUsers != null && model.QuestionUsers.Any()) { model.QuestionUsers.ForEach(p => p.QuestionId = question.Id); DataOperateBusiness <Epm_QuestionUser> .Get().AddRange(model.QuestionUsers); } //transaction.Commit(); if (model.Attachs.Any()) { AddFilesByTable(question, model.Attachs); } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); // TODO:需要处理替换消息模板以及消息类型 #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); try { var recCompany = DataOperateBusiness <Epm_ProjectCompany> .Get().GetList(t => t.ProjectId == model.ProjectId && t.CompanyId == question.RecCompanyId).FirstOrDefault(); var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); if (recCompany == null) { if (project != null) { app.ApproverId = project.ContactUserId; app.ApproverName = project.ContactUserName; } } else { if (recCompany != null && recCompany.LinkManId.HasValue) { app.ApproverId = recCompany.LinkManId; app.ApproverName = recCompany.LinkMan; } } } catch (Exception ex) { WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "字符串截取位置3: " + model.ProjectId); } app.Title = CurrentUserName + "对" + app.ApproverName + "发起了问题沟通"; app.Content = CurrentUserName + "对" + app.ApproverName + "发起了问题沟通"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Question.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Question.GetText(); app.BusinessState = (int)(EnumState.Normal); app.BusinessId = question.Id; app.ProjectId = question.ProjectId; app.ProjectName = question.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "提交问题生成待办: " + question.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "对" + app.ApproverName + "发起了问题沟通"; modelMsg.Content = CurrentUserName + "对" + app.ApproverName + "发起了问题沟通"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = question.Id; modelMsg.BussinesType = BusinessType.Question.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion } catch (Exception e) { throw new Exception(e.Message); } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddQuestion"); } return(result); }
///<summary> ///添加: ///</summary> /// <param name="model">要添加的model</param> /// <returns>受影响的行数</returns> public Result <int> AddContract(Epm_Contract model, List <Base_Files> fileList = null) { Result <int> result = new Result <int>(); try { base.SetCurrentUser(model); model.CrtCompanyId = CurrentCompanyID.ToLongReq(); model.CrtCompanyName = CurrentCompanyName; model.ProjectId = model.ProjectId ?? 0; //bool dConfig = DataOperateBusiness<Epm_Contract>.Get().Count(i => i.Name == model.Name) > 0; //if (dConfig) //{ // throw new Exception("该合同名称已经存在"); //} //dConfig = DataOperateBusiness<Epm_Contract>.Get().Count(i => i.Code == model.Code) > 0; //if (dConfig) //{ // throw new Exception("该合同编码已经存在"); //} var rows = DataOperateBusiness <Epm_Contract> .Get().Add(model); //新增附件 AddFilesByTable(model, fileList); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Contract.GetText(), SystemRight.Add.GetText(), "新增: " + model.Id); if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.WaitAppr) { bool isApprSuccess = false; //判断是否工程处提交,如果是直接通过 if (IsAgencyUser(CurrentUserID.ToLongReq())) { isApprSuccess = true; model.State = (int)ApprovalState.ApprSuccess; DataOperateBusiness <Epm_Contract> .Get().Update(model); } if (!isApprSuccess && model.ProjectId.Value != 0) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(model.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "上传了项目合同,待审核"; app.Content = CurrentUserName + "上传了项目合同,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Contract.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Contract.GetText(); app.BusinessState = (int)(ApprovalState.WaitAppr); app.BusinessId = model.Id; app.ApproverId = project.PMId; app.ApproverName = project.PMName; app.ProjectId = model.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Contract.GetText(), SystemRight.Add.GetText(), "提交合同生成待办: " + model.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "上传了项目合同,待审核"; modelMsg.Content = CurrentUserName + "上传了项目合同,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Contract.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameterSms = new Dictionary<string, string>(); //parameterSms.Add("UserName", CurrentUserName); //WriteSMS(project.PMId.Value, 0, MessageStep.ContractAdd, parameterSms); #endregion } } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddContract"); } return(result); }
/// <summary> /// 回复问题 /// </summary> /// <param name="model"></param> /// <returns></returns> public Result <bool> ReplyQuestion(Epm_QuestionTrack model) { Result <bool> result = new Result <bool>(); try { Epm_Question question = DataOperateBusiness <Epm_Question> .Get().GetModel(model.QuestionId ?? 0); if (question == null) { throw new Exception("问题不存在或已被删除!"); } if (model.State == 2) { throw new Exception("该问题已关闭,无法在进行回复操作!"); } model = SetCurrentUser(model); DataOperateBusiness <Epm_QuestionTrack> .Get().Add(model); result.Data = true; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "回复问题: " + model.Id); #region 处理待办 var tempApp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == question.Id && t.IsApprover == false).FirstOrDefault(); if (tempApp != null) { ComplateApprover(tempApp.Id); #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.ApproverId = CurrentUserID.ToLongReq(); app.ApproverName = CurrentUserName; app.Title = question.CreateUserName + "发起的问题沟通,已有回复"; app.Content = question.CreateUserName + "发起的问题沟通,已有回复"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Question.ToString(); app.Action = SystemRight.Reply.ToString(); app.BusinessTypeName = BusinessType.Question.GetText(); app.BusinessState = (int)(EnumState.Normal); app.BusinessId = question.Id; app.ProjectId = question.ProjectId; app.ProjectName = question.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Question.GetText(), SystemRight.Add.GetText(), "提交问题生成待办: " + question.Id); #endregion } #endregion #region 消息 var waitSend = GetWaitSendMessageList(question.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = question.CreateUserName + "发起了问题沟通," + CurrentUserName + "有回复"; modelMsg.Content = question.CreateUserName + "发起了问题沟通," + CurrentUserName + "有回复"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Question.ToString(); modelMsg.ProjectId = question.ProjectId.Value; modelMsg.ProjectName = question.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion } catch (Exception ex) { result.Flag = EResultFlag.Failure; result.Data = false; result.Exception = new ExceptionEx(ex, "QuestionClose"); } return(result); }
/// <summary> /// 更新状态 /// </summary> /// <param name="id"></param> /// <param name="state"></param> /// <returns></returns> public Result <int> UpdateContractState(long id, string state) { Result <int> result = new Result <int>(); try { var model = DataOperateBusiness <Epm_Contract> .Get().GetModel(id); if (model != null) { model.OperateUserId = CurrentUserID.ToLongReq(); model.OperateUserName = CurrentUserName; model.OperateTime = DateTime.Now; model.State = (int)state.ToEnumReq <ApprovalState>(); var rows = DataOperateBusiness <Epm_Contract> .Get().Update(model); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Contract.GetText(), SystemRight.Modify.GetText(), "更新状态: " + rows); } else { throw new Exception("该合同id不存在"); } //处理待办 var temp = DataOperateBusiness <Epm_Approver> .Get().GetList(t => t.BusinessId == model.Id && t.IsApprover == false).FirstOrDefault(); if (temp != null) { ComplateApprover(temp.Id); } string title = ""; if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprSuccess) { if (model.ProjectId.Value != 0) { title = model.CreateUserName + "上传的合同信息,审核通过"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的合同信息,审核通过"; app.Content = model.CreateUserName + "上传的合同信息,审核通过"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Contract.ToString(); app.Action = SystemRight.Check.ToString(); app.BusinessTypeName = BusinessType.Contract.GetText(); app.BusinessState = (int)(ApprovalState.ApprSuccess); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Contract.GetText(), SystemRight.Check.GetText(), "审核通过合同生成待办: " + model.Id); #endregion } } else if ((ApprovalState)Enum.ToObject(typeof(ApprovalState), model.State) == ApprovalState.ApprFailure) { if (model.ProjectId.Value != 0) { title = model.CreateUserName + "上传的合同信息已被驳回,请处理"; #region 生成待办 List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = model.CreateUserName + "上传的合同信息已被驳回,请处理"; app.Content = model.CreateUserName + "上传的合同信息已被驳回,请处理"; app.SendUserId = model.CreateUserId; app.SendUserName = model.CreateUserName; app.SendTime = model.CreateTime; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Contract.ToString(); app.Action = SystemRight.UnCheck.ToString(); app.BusinessTypeName = BusinessType.Contract.GetText(); app.BusinessState = (int)(ApprovalState.ApprFailure); app.BusinessId = model.Id; app.ApproverId = model.CreateUserId; app.ApproverName = model.CreateUserName; app.ProjectId = model.ProjectId; app.ProjectName = model.ProjectName; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Contract.GetText(), SystemRight.UnCheck.GetText(), "驳回合同生成待办: " + model.Id); #endregion #region 发送短信 //WriteSMS(model.CreateUserId, 0, MessageStep.ContractReject, null); #endregion } } if (model.ProjectId.Value != 0) { #region 消息 var waitSend = GetWaitSendMessageList(model.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = title; modelMsg.Content = title; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = model.Id; modelMsg.BussinesType = BusinessType.Contract.ToString(); modelMsg.ProjectId = model.ProjectId.Value; modelMsg.ProjectName = model.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion } } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateState"); } return(result); }
/// <summary> /// 新增完工验收 /// </summary> /// <param name="view"></param> /// <returns></returns> public Result <int> AddCompletionAcceptanceNew(CompletionAcceptanceView view) { Result <int> result = new Result <int>(); try { var completionAcceptance = view.CompletionAcceptance; var completionRectifyCompanys = view.CompletionRectifyCompanys; completionAcceptance = base.SetCurrentUser(completionAcceptance); completionAcceptance.CrtCompanyId = CurrentCompanyID.ToLongReq(); completionAcceptance.CrtCompanyName = CurrentCompanyName; completionAcceptance.RecUserId = CurrentUser.Id; completionAcceptance.RecUserName = CurrentUserName; var rows = DataOperateBusiness <Epm_CompletionAcceptance> .Get().Add(completionAcceptance); if (completionRectifyCompanys != null && completionRectifyCompanys.Any()) { completionRectifyCompanys.ForEach(p => { SetCreateUser(p); SetCurrentUser(p); p.AcceptanceId = completionAcceptance.Id; }); DataOperateBusiness <Epm_CompletionRectifyCompany> .Get().AddRange(completionRectifyCompanys); } if (view.BaseFiles != null) { AddFilesByTable(completionAcceptance, view.BaseFiles); } //生成代办消息 if ((PreCompletionScceptanceState)completionAcceptance.State == PreCompletionScceptanceState.WaitApproval) { #region 生成待办 var project = DataOperateBusiness <Epm_Project> .Get().GetModel(completionAcceptance.ProjectId.Value); List <Epm_Approver> list = new List <Epm_Approver>(); Epm_Approver app = new Epm_Approver(); app.Title = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核"; app.Content = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核"; app.SendUserId = CurrentUserID.ToLongReq(); app.SendUserName = CurrentUserName; app.SendTime = DateTime.Now; app.LinkURL = string.Empty; app.BusinessTypeNo = BusinessType.Completed.ToString(); app.Action = SystemRight.Add.ToString(); app.BusinessTypeName = BusinessType.Completed.GetText(); app.BusinessState = (int)(PreCompletionScceptanceState.WaitApproval); app.BusinessId = completionAcceptance.Id; app.ApproverId = project.PMId; app.ApproverName = project.PMName; app.ProjectId = completionAcceptance.ProjectId; app.ProjectName = project.Name; list.Add(app); AddApproverBatch(list); WriteLog(BusinessType.Completed.GetText(), SystemRight.Add.GetText(), "提交完工验收生成待办: " + completionAcceptance.Id); #endregion #region 消息 var waitSend = GetWaitSendMessageList(completionAcceptance.ProjectId.Value); foreach (var send in waitSend) { Epm_Massage modelMsg = new Epm_Massage(); modelMsg.ReadTime = null; modelMsg.RecId = send.Key; modelMsg.RecName = send.Value; modelMsg.RecTime = DateTime.Now; modelMsg.SendId = CurrentUserID.ToLongReq(); modelMsg.SendName = CurrentUserName; modelMsg.SendTime = DateTime.Now; modelMsg.Title = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核"; modelMsg.Content = CurrentUserName + "提交了" + project.Name + "完工验收申请,待审核"; modelMsg.Type = 2; modelMsg.IsRead = false; modelMsg.BussinessId = completionAcceptance.Id; modelMsg.BussinesType = BusinessType.Completed.ToString(); modelMsg.ProjectId = completionAcceptance.ProjectId.Value; modelMsg.ProjectName = completionAcceptance.ProjectName; modelMsg = base.SetCurrentUser(modelMsg); modelMsg = base.SetCreateUser(modelMsg); DataOperateBusiness <Epm_Massage> .Get().Add(modelMsg); } #endregion #region 发送短信 //Dictionary<string, string> parameters = new Dictionary<string, string>(); //parameters.Add("UserName", CurrentUserName); //WriteSMS(project.PMId.Value, 0, MessageStep.ComplationAdd, parameters); #endregion } result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(BusinessType.Completed.GetText(), SystemRight.Add.GetText(), "新增: " + completionAcceptance.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "AddCompletionAcceptanceNew"); } return(result); }