public ActionResult SubmitForm(string keyValue, PlanApplyEntity entity) { string workflow = entity.ApplyType == "部门工作计划" ? "06" : "07"; CommonSaveForm(keyValue, workflow, entity); //创建完流程实例后 if (string.IsNullOrEmpty(keyValue)) { keyValue = entity.ID; } string errorMsg = ""; if (workflow == "06") {//部门工作计划 errorMsg = DepartFlow(keyValue, entity); } else {//个人工作计划 errorMsg = PersonFlow(keyValue, entity); } if (!string.IsNullOrWhiteSpace(errorMsg)) { return(Error("请联系系统管理员,确认" + errorMsg + "!")); } return(Success("操作成功。")); }
public ActionResult SaveForm(string keyValue, PlanApplyEntity entity) { string workflow = entity.ApplyType == "部门工作计划" ? "06" : "07"; CommonSaveForm(keyValue, workflow, entity); return(Success("操作成功。")); }
/// <summary> /// 个人工作计划推送流程 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> /// <returns></returns> private string PersonFlow(string keyValue, PlanApplyEntity entity) { var errorMsg = ""; //此处需要判断当前人角色。 string wfFlag = string.Empty; //当前用户 Operator curUser = OperatorProvider.Provider.Current(); //参与人员 string participant = string.Empty; //流程推进 if (userbll.HaveRoleListByKey(curUser.UserId, "'100108'").Rows.Count > 0) { //公司级用户 wfFlag = "1"; // 申请=>公司负责人审批 errorMsg = "公司负责人"; var deptUser = userbll.GetUserListByRole(curUser.DeptCode, "'100104'", ""); participant = string.Join(",", deptUser.Select(x => x.Account)); } else if (userbll.HaveRoleListByKey(curUser.UserId, "'100104'").Rows.Count > 0) { //部门负责人 wfFlag = "1"; // 申请=>上级领导审批 errorMsg = "上级领导"; //找当前用户上级部门负责人。 var dept = new DepartmentBLL().GetEntity(curUser.ParentId); if (dept != null) { var deptUser = userbll.GetUserListByRole(dept.EnCode, "'100104'", ""); participant = string.Join(",", deptUser.Select(x => x.Account)); } } else { //其他用户 wfFlag = "1"; // 申请=>本部门负责人审批 errorMsg = "部门负责人"; var deptUser = userbll.GetUserListByRole(curUser.DeptCode, "'100104'", ""); participant = string.Join(",", deptUser.Select(x => x.Account)); } if (!string.IsNullOrEmpty(participant)) { entity.CheckUserAccount = participant; planApplyBll.SaveForm(keyValue, entity); int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId); if (count > 0) { htworkflowbll.UpdateFlowStateByObjectId("hrs_planapply", "flowstate", keyValue); //更新业务流程状态 } errorMsg = ""; } return(errorMsg); }
/// <summary> /// 保存表单(新增、修改) /// </summary> /// <param name="keyValue">主键值</param> /// <param name="entity">实体对象</param> /// <returns></returns> public void SaveForm(string keyValue, PlanApplyEntity entity) { try { service.SaveForm(keyValue, entity); } catch (Exception) { throw; } }
public ActionResult SubmitChangeForm(string keyValue, PlanApplyEntity entity) { string workflow = entity.ApplyType == "部门工作计划" ? "06" : "07"; //保存历史记录 var oldEntity = planApplyBll.GetEntity(keyValue); if (oldEntity != null) { var newApplyId = Request["NewId"]; oldEntity.ID = newApplyId; oldEntity.BaseId = entity.ID; planApplyBll.SaveForm("", oldEntity); var planDetailsBll = new PlanDetailsBLL(); var list = planDetailsBll.GetList(string.Format(" and baseid in(select id from hrs_plandetails d where d.applyid='{0}') and not exists(select 1 from hrs_planapply a where a.id=hrs_plandetails.applyid)", keyValue)).ToList(); foreach (var epd in list) {//纠正因未提交丢失的历史数据。 epd.ApplyId = newApplyId; planDetailsBll.SaveForm(epd.ID, epd); } } //删除旧流程创建新流程 htworkflowbll.DeleteWorkFlowObj(keyValue); CommonSaveForm(keyValue, workflow, entity); //创建完流程实例后 if (string.IsNullOrEmpty(keyValue)) { keyValue = entity.ID; } string errorMsg = ""; if (workflow == "06") {//部门工作计划 errorMsg = DepartFlow(keyValue, entity); } else {//个人工作计划 errorMsg = PersonFlow(keyValue, entity); } if (!string.IsNullOrWhiteSpace(errorMsg)) { return(Error("请联系系统管理员,确认" + errorMsg + "!")); } return(Success("操作成功。")); }
/// <summary> /// 公用方法,保存数据 /// </summary> public void CommonSaveForm(string keyValue, string workFlow, PlanApplyEntity entity) { //提交通过 string userId = OperatorProvider.Provider.Current().UserId; //保存基本信息 planApplyBll.SaveForm(keyValue, entity); //创建流程实例 if (!htworkflowbll.IsHavaWFCurrentObject(entity.ID)) { bool isSucess = htworkflowbll.CreateWorkFlowObj(workFlow, entity.ID, userId); if (isSucess) { htworkflowbll.UpdateFlowStateByObjectId("hrs_planapply", "flowstate", entity.ID); //更新业务流程状态 } } }
/// <summary> /// 部门工作计划推送流程 /// </summary> /// <param name="keyValue"></param> /// <param name="entity"></param> /// <returns></returns> private string DepartFlow(string keyValue, PlanApplyEntity entity) { var errorMsg = ""; //此处需要判断当前人角色。 string wfFlag = string.Empty; //当前用户 Operator curUser = OperatorProvider.Provider.Current(); //参与人员 string participant = string.Empty; //EHS部门encode DataItemModel ehsDepart = dataitemdetailbll.GetDataItemListByItemCode("'EHSDepartment'").Where(p => p.ItemName == curUser.OrganizeId).ToList().FirstOrDefault(); //分管领导 //var fgLeaderUser = userbll.GetListForCon(x => x.RoleName.Contains("公司级用户") && x.RoleName.Contains("安全管理员")).Select(x => x.Account).ToList(); //安全管理员、部门负责人 //var isSafer = userbll.HaveRoleListByKey(curUser.UserId, "'100105'").Rows.Count > 0; var isManager = userbll.HaveRoleListByKey(curUser.UserId, "'100104'").Rows.Count > 0; //流程推进 if (ehsDepart != null && ehsDepart.ItemValue == curUser.DeptCode && isManager == true) { wfFlag = "3"; //申请=>审批 errorMsg = ">分管领导"; //分管领导 var fgLeaderUser = userbll.GetListForCon(x => x.RoleName.Contains("公司级用户") && x.RoleName.Contains("安全管理员")).Select(x => x.Account).ToList(); participant = string.Join(",", fgLeaderUser); } else if ((ehsDepart != null && ehsDepart.ItemValue == curUser.DeptCode) || (curUser.RoleName.Contains("部门级") && isManager == true)) { //EHS部 wfFlag = "2"; //申请=>EHS负责人审核 errorMsg = ">EHS负责人"; var deptUser = userbll.GetUserListByRole(ehsDepart.ItemValue, "'100104'", ""); participant = string.Join(",", deptUser.Select(x => x.Account)); } else if (curUser.RoleName.Contains("承包商")) { //承包商走所有工程的责任部门 wfFlag = "1";//申请=>部门负责人审核 errorMsg = "工程责任部门负责人"; var projectList = new OutsouringengineerBLL().GetList().Where(x => x.OUTPROJECTID == curUser.DeptId).ToList(); var deptUser = new List <UserEntity>(); for (int i = 0; i < projectList.Count; i++) { var pDept = new DepartmentBLL().GetEntity(projectList[i].ENGINEERLETDEPTID); if (pDept != null) { deptUser = userbll.GetUserListByRole(pDept.EnCode, "'100104'", "").ToList(); } if (!string.IsNullOrWhiteSpace(participant)) { participant += "," + string.Join(",", deptUser.Select(x => x.Account)); } else { participant += string.Join(",", deptUser.Select(x => x.Account)); } } } else { //安全管理员 wfFlag = "1";//申请=>部门负责人审核 errorMsg = "部门负责人"; if (curUser.RoleName.Contains("部门级")) { var deptUser = userbll.GetUserListByRole(curUser.DeptCode, "'100104'", ""); participant = string.Join(",", deptUser.Select(x => x.Account)); } else { var pDept = new DepartmentBLL().GetParentDeptBySpecialArgs(curUser.ParentId, "部门"); var deptUser = userbll.GetUserListByRole(pDept.DeptCode, "'100104'", ""); participant = string.Join(",", deptUser.Select(x => x.Account)); } } if (!string.IsNullOrEmpty(participant)) { entity.CheckUserAccount = participant; planApplyBll.SaveForm(keyValue, entity); int count = htworkflowbll.SubmitWorkFlow(keyValue, participant, wfFlag, curUser.UserId); if (count > 0) { htworkflowbll.UpdateFlowStateByObjectId("hrs_PlanApply", "flowstate", keyValue); //更新业务流程状态 } errorMsg = ""; } return(errorMsg); }