using System; using System.Collections.Generic; using System.Web; using System.Data; using System.Linq; using FangYar.BLL.OA; using FangYar.IDAL; using NPOI.SS.Formula.Functions; using FangYar.BLL; using FangYar.BLL.FIRE; using System.Collections; using System.Text; using System.Threading.Tasks; using System.Drawing; using System.IO; namespace FangYar.WebUI.ashx { /// /// AppHandler 的摘要说明 /// public class AppFlowHandler : IHttpHandler { private RoadFlow.Platform.WorkFlowTask bworkFlowTask = new RoadFlow.Platform.WorkFlowTask(); private RoadFlow.Platform.WorkFlow bworkFlow = new RoadFlow.Platform.WorkFlow(); private RoadFlow.Platform.WorkFlowButtons bworkFlowButtons = new RoadFlow.Platform.WorkFlowButtons(); private RoadFlow.Platform.AppLibrary bappLibrary = new RoadFlow.Platform.AppLibrary(); private RoadFlow.Platform.Organize borganize = new RoadFlow.Platform.Organize(); #region ProcessRequest public void ProcessRequest(HttpContext context) { // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", ""); context.Response.ContentType = "text/plain"; string action = context.Request.Params["Action"]; string returnstr = ""; switch (action) { case "AppLeaveTaskApply"://请假申请 returnstr = AppLeaveTaskApply(context); break; case "AppGetLeaveItem"://获取请假待办详情 returnstr = AppGetLeaveItem(context); break; case "AppLeaveTaskHandle"://请假流程处理 returnstr = AppLeaveTaskHandle(context); break; case "AppGetLeaveAudit"://获取请假信息、流转记录 returnstr = AppGetLeaveAudit(context); break; case "AppCarTaskApply"://用车申请 returnstr = AppCarTaskApply(context); break; case "AppGetCarItem"://获取用车待办详情 returnstr = AppGetCarItem(context); break; case "AppCarTaskHandle"://用车流程处理 returnstr = AppCarTaskHandle(context); break; case "AppGetCarAudit"://获取用车信息、流转记录 returnstr = AppGetCarAudit(context); break; case "AppToleranceTaskApply"://公差申请 returnstr = AppToleranceTaskApply(context); break; case "AppGetToleranceItem"://获取公差待办详情 returnstr = AppGetToleranceItem(context); break; case "AppToleranceTaskHandle"://公差流程处理 returnstr = AppToleranceTaskHandle(context); break; case "AppGetToleranceAudit"://获取公差信息、流转记录 returnstr = AppGetToleranceAudit(context); break; //获取上级单位部门、人员列表 case "AppGetSuperiorOrgEmp": returnstr = AppGetSuperiorOrgEmp(context); break; //获取本级单位部门、人员列表 case "AppGetMyOrgEmp": returnstr = AppGetMyOrgEmp(context); break; case "AppJudgeWhetherSuperiorOrgEmp"://根据用户ID判断是否选择上级机构审批 returnstr = AppJudgeWhetherSuperiorOrgEmp(context); break; case "AppLeaveTaskApplyRKZ"://日喀则请假申请 returnstr = AppLeaveTaskApplyRKZ(context); break; case "AppLeaveTaskHandleRKZ"://日喀则请假流程处理 returnstr = AppLeaveTaskHandleRKZ(context); break; case "AppGetMyOrgLeader"://获取本级单位部门、直属领导列表 returnstr = AppGetMyOrgLeader(context); break; case "AppGetSuperiorOrgLeader"://获取上级单位部门、直属领导列表 returnstr = AppGetSuperiorOrgLeader(context); break; } context.Response.Write(returnstr); } #endregion #region 请销假 //请假申请 private string AppLeaveTaskApply(HttpContext context) { string returnstr = ""; try { bool flag = false; //请假表单字段 string leaveId = context.Request.Params["leaveId"]; if (string.IsNullOrEmpty(leaveId)) { flag = true; leaveId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; string extend2 = context.Request.Params["extend2"]; FangYar.Model.OA_LEAVE leaveModel = new FangYar.Model.OA_LEAVE(); leaveModel.ID = leaveId; leaveModel.PPL_ID = pplId; leaveModel.PPL_NAME = pplName; leaveModel.L_TYPE = lType; leaveModel.S_TIME = sTime + ":00"; leaveModel.E_TIME = eTime + ":59"; leaveModel.L_NUM = lNum; leaveModel.L_OUT = lOut; leaveModel.ACC_PPL = accPplId; leaveModel.REP_PPL = repPplId; leaveModel.L_REASON = lReason; leaveModel.TITLE = title; leaveModel.STATE = "0"; leaveModel.IS_RETURN = "1"; leaveModel.EXTEND2 = extend2; leaveModel.EXTEND4 = "1_"; string str = AppXZLSTQYZFirst(pplId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); leaveModel.EXTEND3 = str2[1]; leaveModel.EXTEND4 = str2[0]; leaveModel.EXTEND5 = str2[0]; } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = leaveModel.EXTEND3; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("e9e69c25-985b-4610-9948-1f61b33128ac"); if (flag) { leaveBll.Add(leaveModel); System.Threading.Thread.Sleep(500); execute.FlowID = "e9e69c25-985b-4610-9948-1f61b33128ac".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = leaveModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { leaveBll.Update(leaveModel); System.Threading.Thread.Sleep(500); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "请假申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "请假申请"); return returnstr; } //获取请假待办详情 private string AppGetLeaveItem(HttpContext context) { string returnstr = ""; try { string flowid = context.Request.Params["flowid"]; string stepid = context.Request.Params["stepid"]; string instanceid = context.Request.Params["instanceid"]; string status = context.Request.Params["status"]; if (status == "0") { //更新打开时间 Guid taskgid; string taskid = context.Request.Params["taskid"]; taskid.IsGuid(out taskgid); RoadFlow.Data.Model.WorkFlowTask task = bworkFlowTask.Get(taskgid); //如果是执行,并且任务ID为GUID,则更新打开时间和状态,检查当前任务是否可以执行。 bworkFlowTask.UpdateOpenTime(taskgid, RoadFlow.Utility.DateTimeNew.Now, true); } var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); Guid stepID; if (!stepid.IsGuid(out stepID)) { stepID = wfInstalled.FirstStepID; } returnstr = "{\"code\":0,\"msg\":\"\""; RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep = wfInstalled.Steps.ToList().Find(p => p.ID == stepID); returnstr += ",\"buttons\":"; //按钮 List buttons = new List(); foreach (var button in currentStep.Buttons) { buttons.Add(button); } returnstr += FangYar.Common.JsonHelper.ToJson(buttons); returnstr += ",\"leaveModel\":"; FangYar.BLL.OA_LEAVE leavebll = new FangYar.BLL.OA_LEAVE(); List data = leavebll.getLeave(instanceid); if (data == null) { return "{\"code\":-1,\"msg\":\"未查询到详情!\",\"buttons\":[],\"leaveModel\":\"\",\"commentData\":\"\"}"; } returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"commentData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"buttons\":[],\"leaveModel\":\"\",\"commentData\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取请假待办详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "获取请假待办详情"); return returnstr; } //请假流程处理 private string AppLeaveTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 string EXTEND = context.Request.Params["EXTEND"];//延假小时 string isEXTEND = context.Request.Params["isEXTEND"];//是否为延假 0销假;1延假 //string EXTEND3 = context.Request.Params["EXTEND3"];// //receiveId = EXTEND3; string isSuperiorApprove = context.Request.Params["isSuperiorApprove"];//是否呈交上级审批 0是;1否 if (isSuperiorApprove == "0") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '0' where id = '" + taskid + "'"); } else if (isSuperiorApprove == "1") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '1' where id = '" + taskid + "'"); } if (isEXTEND == "1") { FangYar.BLL.OA_LEAVE ldal = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE lmodel = ldal.GetModel(instanceid); lmodel.EXTEND = EXTEND; ldal.Update(lmodel); } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA_LEAVE leavebll = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE leaveModel = leavebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; //leavebll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; leavebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = leaveModel.PPL_ID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); var accUsers = leaveModel.ACC_PPL.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } } RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { int backType = currentStep.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { for (int i = 0; i < nextSteps.Count; i++) { switch (nextSteps[i].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[i].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[i].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[i].ID, borganize.GetAllUsersIdString(receiveId)); } } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "请假流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "请假流程处理"); return returnstr; } //获取请假信息、流转记录 private string AppGetLeaveAudit(HttpContext context) { string returnstr = ""; try { string leaveId = context.Request.Params["leaveId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"leaveData\":"; FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); List data = leaveBll.getLeave(leaveId); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"waitData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"leaveData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取请假信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取请假信息、流转记录"); return returnstr; } #endregion #region 用车 //用车申请 private string AppCarTaskApply(HttpContext context) { string returnstr = ""; try { bool flag = false; //用车表单字段 string applyId = context.Request.Params["applyId"]; if (string.IsNullOrEmpty(applyId)) { flag = true; applyId = Guid.NewGuid().ToString().ToGuid().ToString(); } string userId = context.Request.Params["userId"]; string userName = context.Request.Params["userName"]; string userPhone = context.Request.Params["userPhone"]; string carId = context.Request.Params["carId"]; string carNum = context.Request.Params["carNum"]; string userMan = context.Request.Params["userMan"]; string rideNum = context.Request.Params["rideNum"]; string rideMan = context.Request.Params["rideMan"]; string ridePurpose = context.Request.Params["ridePurpose"]; string startPoint = context.Request.Params["startPoint"]; string endPoint = context.Request.Params["endPoint"]; string startTime = context.Request.Params["startTime"]; string endTime = context.Request.Params["endTime"]; string title = context.Request.Params["title"]; string extend = context.Request.Params["extend"]; string extend2 = context.Request.Params["extend2"]; FangYar.Model.TBL_SYS_CARAPPLY carModel = new FangYar.Model.TBL_SYS_CARAPPLY(); if (flag && !string.IsNullOrEmpty(startTime) && !string.IsNullOrEmpty(endTime)) { startTime += ":00"; endTime += ":59"; string repeatSql = "select * from tbl_sys_carapply where STATE!=2 and EXTENDCODE2!=2 and carid = '" + carId + "' and " + " (('" + startTime + "' <= starttime and starttime <= '" + endTime + "' and '" + endTime + "' <= finishtime) " + " or " + " (starttime <= '" + startTime + "' and '" + startTime + "' <= finishtime and finishtime <= '" + endTime + "') " + " or " + " ('" + startTime + "' <= starttime and finishtime <= '" + endTime + "')) "; DataTable repeatDt = FangYar.Common.MySqlHelper.QueryTable(repeatSql); if (repeatDt.Rows.Count > 0) { string userName_R = repeatDt.Rows[0]["USERNAME"].ToString(); string startTime_R = repeatDt.Rows[0]["STARTTIME"].ToString(); string finishTime_R = repeatDt.Rows[0]["FINISHTIME"].ToString(); return "{\"code\":-2,\"msg\":\"【" + carNum + "】,已经被(" + userName_R + ")使用,用车时间段为:" + startTime_R + " - " + finishTime_R + "\"}"; } } carModel.ID = applyId; carModel.USERID = userId; carModel.USERNAME = userName; carModel.USERPHONE = userPhone; carModel.CARID = carId; carModel.CARNUM = carNum; carModel.USERMAN = userMan; if (!string.IsNullOrEmpty(rideNum)) { carModel.RIDENUM = Int32.Parse(rideNum); } else { carModel.RIDENUM = 1; } carModel.RIDEMANS = rideMan; carModel.RIDEPURPOSE = ridePurpose; carModel.STARTPOINT = startPoint; carModel.DESTINATION = endPoint; if (!string.IsNullOrEmpty(startTime)) { carModel.STARTTIME = DateTime.Parse(startTime); } if (!string.IsNullOrEmpty(endTime)) { carModel.FINISHTIME = DateTime.Parse(endTime); } carModel.STATE = "0"; carModel.EXTENDCODE2 = "1"; carModel.TITLE = title; carModel.EXTENDCODE3 = extend; carModel.EXTENDCODE6 = extend2; carModel.EXTENDCODE5 = "1_"; //根据辖区内(外)获取第一个节点 string str = AppXZLSTQYZFirst(userId); if (extend2 == "2")//辖区外 { str = GetOutsideVehicleApprovalFirstNodeApp(userId); } if (str != null && str.Contains(';')) { var str2 = str.Split(';'); carModel.EXTENDCODE4 = str2[1]; carModel.EXTENDCODE5 = str2[0]; carModel.RETURN_STEP = str2[0]; } FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = carModel.EXTENDCODE4; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID //根据辖区内(外)绑定流程 var carFlowId = "114c4a93-49f6-43fe-b677-32635c98256c"; if (extend2 == "2")//辖区外 { carFlowId = "a0bc1f34-a16f-40cc-9d30-76b0145357ae"; } var wfInstalled = bworkFlow.GetWorkFlowRunModel(carFlowId); if (flag) { carBll.Add(carModel); System.Threading.Thread.Sleep(500); execute.FlowID = carFlowId.ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = carModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(userId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { carBll.Update(carModel); System.Threading.Thread.Sleep(500); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "用车申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "用车申请"); return returnstr; } //获取用车待办详情 private string AppGetCarItem(HttpContext context) { string returnstr = ""; try { string flowid = context.Request.Params["flowid"]; string stepid = context.Request.Params["stepid"]; string instanceid = context.Request.Params["instanceid"]; string status = context.Request.Params["status"]; if (status == "0") { //更新打开时间 Guid taskgid; string taskid = context.Request.Params["taskid"]; taskid.IsGuid(out taskgid); RoadFlow.Data.Model.WorkFlowTask task = bworkFlowTask.Get(taskgid); //如果是执行,并且任务ID为GUID,则更新打开时间和状态,检查当前任务是否可以执行。 bworkFlowTask.UpdateOpenTime(taskgid, RoadFlow.Utility.DateTimeNew.Now, true); } var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); Guid stepID; if (!stepid.IsGuid(out stepID)) { stepID = wfInstalled.FirstStepID; } returnstr = "{\"code\":0,\"msg\":\"\""; RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep = wfInstalled.Steps.ToList().Find(p => p.ID == stepID); returnstr += ",\"buttons\":"; //按钮 List buttons = new List(); foreach (var button in currentStep.Buttons) { buttons.Add(button); } returnstr += FangYar.Common.JsonHelper.ToJson(buttons); returnstr += ",\"carModel\":"; FangYar.BLL.TBL_SYS_CARAPPLY carbll = new FangYar.BLL.TBL_SYS_CARAPPLY(); List data = carbll.getCarApply(instanceid); if (data == null) { return "{\"code\":-1,\"msg\":\"未查询到详情!\",\"buttons\":[],\"carModel\":\"\",\"commentData\":\"\"}"; } returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"commentData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"buttons\":[],\"leaveModel\":\"\",\"commentData\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取用车待办详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "获取用车待办详情"); return returnstr; } //用车流程处理 private string AppCarTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 string isSuperiorApprove = context.Request.Params["isSuperiorApprove"];//是否呈交上级审批 0是;1否 if (isSuperiorApprove == "0") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '0' where id = '" + taskid + "'"); } else if (isSuperiorApprove == "1") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '1' where id = '" + taskid + "'"); } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); FangYar.Model.TBL_SYS_CARAPPLY carModel = carBll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; //carBll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; carBll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = carModel.USERID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); emodel.USERS_UID = carModel.USERMAN; empbll.EditEmpIswork(emodel); var accUsers = carModel.RIDEMANS.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } //还车通过后修改车辆的状态 TBL_SYS_CAR carbll = new TBL_SYS_CAR(); Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); if (carmodel != null) { carmodel.ISAPPLY = "0"; } carbll.EditCarIsapply(carmodel); } RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { var steps2 = wfInstalled.Steps.Where(p => p.ID == stepid.ToGuid()); var currentStep2 = steps2.First(); int backType = currentStep2.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { if (execute.ExecuteType != RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree) { //审批通过后调整车辆状态 TBL_SYS_CAR carbll = new TBL_SYS_CAR(); Model.TBL_SYS_CAR carmodel = carbll.GetModel(carModel.CARID); if (carmodel != null) { carmodel.ISAPPLY = "1"; carbll.EditCarIsapply(carmodel); } else { Model.TBL_SYS_CAR carmodel2 = carbll.CarNumGetModel(carModel.CARNUM); if (carmodel2 != null) { carmodel2.ISAPPLY = "1"; carbll.EditCarIsapply(carmodel2); } } } var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { switch (nextSteps[0].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[0].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[0].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "用车流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "用车流程处理"); return returnstr; } //获取用车信息、流转记录 private string AppGetCarAudit(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL_SYS_CARAPPLY carBll = new FangYar.BLL.TBL_SYS_CARAPPLY(); string id = context.Request.Params["carApplyId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"applyData\":"; List data = carBll.getCarApply(id); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"waitData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"toleranceData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取用车信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取用车信息、流转记录"); return returnstr; } #endregion #region 公差 //公差申请 private string AppToleranceTaskApply(HttpContext context) { string returnstr = ""; try { bool flag = false; //公差表单字段 string toleranceId = context.Request.Params["toleranceId"]; if (string.IsNullOrEmpty(toleranceId)) { flag = true; toleranceId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; string carNum = context.Request.Params["carNum"]; string carId = context.Request.Params["carId"]; FangYar.Model.OA.OA_TOLERANCE toleranceModel = new FangYar.Model.OA.OA_TOLERANCE(); toleranceModel.ID = toleranceId; toleranceModel.PPL_ID = pplId; toleranceModel.PPL_NAME = pplName; toleranceModel.L_TYPE = lType; toleranceModel.S_TIME = sTime + ":00"; toleranceModel.E_TIME = eTime + ":59"; toleranceModel.L_NUM = lNum; toleranceModel.L_OUT = lOut; toleranceModel.ACC_PPL = accPplId; toleranceModel.REP_PPL = repPplId; toleranceModel.L_REASON = lReason; toleranceModel.TITLE = title; toleranceModel.STATE = "0"; toleranceModel.CAR_NUM = carNum; toleranceModel.EXTENDCODE3 = carId; string str = AppXZLSTQYZFirst(pplId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); toleranceModel.EXTENDCODE1 = str2[1]; toleranceModel.EXTENDCODE2 = str2[0]; toleranceModel.EXTENDCODE4 = str2[0]; } FangYar.BLL.OA.OA_TOLERANCE carBll = new FangYar.BLL.OA.OA_TOLERANCE(); RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = toleranceModel.EXTENDCODE1; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("4e1cc1d4-f325-4a92-b9fe-d737132330c9"); if (flag) { carBll.Add(toleranceModel); System.Threading.Thread.Sleep(500); execute.FlowID = "4e1cc1d4-f325-4a92-b9fe-d737132330c9".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = toleranceModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { carBll.Update(toleranceModel); System.Threading.Thread.Sleep(500); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "公差申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "公差申请"); return returnstr; } //获取公差待办详情 private string AppGetToleranceItem(HttpContext context) { string returnstr = ""; try { string flowid = context.Request.Params["flowid"]; string stepid = context.Request.Params["stepid"]; string instanceid = context.Request.Params["instanceid"]; string status = context.Request.Params["status"]; if (status == "0") { //更新打开时间 Guid taskgid; string taskid = context.Request.Params["taskid"]; taskid.IsGuid(out taskgid); RoadFlow.Data.Model.WorkFlowTask task = bworkFlowTask.Get(taskgid); //如果是执行,并且任务ID为GUID,则更新打开时间和状态,检查当前任务是否可以执行。 bworkFlowTask.UpdateOpenTime(taskgid, RoadFlow.Utility.DateTimeNew.Now, true); } var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); Guid stepID; if (!stepid.IsGuid(out stepID)) { stepID = wfInstalled.FirstStepID; } returnstr = "{\"code\":0,\"msg\":\"\""; RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep = wfInstalled.Steps.ToList().Find(p => p.ID == stepID); returnstr += ",\"buttons\":"; //按钮 List buttons = new List(); foreach (var button in currentStep.Buttons) { buttons.Add(button); } returnstr += FangYar.Common.JsonHelper.ToJson(buttons); returnstr += ",\"toleranceModel\":"; FangYar.BLL.OA.OA_TOLERANCE bll = new FangYar.BLL.OA.OA_TOLERANCE(); List data = bll.getTolerance(instanceid); if (data == null) { return "{\"code\":-1,\"msg\":\"未查询到详情!\",\"buttons\":[],\"toleranceModel\":\"\",\"commentData\":\"\"}"; } returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"commentData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"buttons\":[],\"leaveModel\":\"\",\"commentData\":\"\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取公差待办详情异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "获取公差待办详情"); return returnstr; } //公差流程处理 private string AppToleranceTaskHandle(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 string isSuperiorApprove = context.Request.Params["isSuperiorApprove"];//是否呈交上级审批 0是;1否 if (isSuperiorApprove == "0") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '0' where id = '" + taskid + "'"); } else if (isSuperiorApprove == "1") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '1' where id = '" + taskid + "'"); } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA.OA_TOLERANCE tolerancebll = new FangYar.BLL.OA.OA_TOLERANCE(); FangYar.Model.OA.OA_TOLERANCE toleranceModel = tolerancebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; tolerancebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { var steps2 = wfInstalled.Steps.Where(p => p.ID == stepid.ToGuid()); var currentStep2 = steps2.First(); int backType = currentStep2.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { switch (nextSteps[0].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[0].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[0].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "公差流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "公差流程处理"); return returnstr; } //获取公差信息、流转记录 private string AppGetToleranceAudit(HttpContext context) { string returnstr = ""; try { string toleranceId = context.Request.Params["toleranceId"]; returnstr = "{\"code\":0,\"msg\":\"\",\"toleranceData\":"; FangYar.BLL.OA.OA_TOLERANCE toleranceBll = new FangYar.BLL.OA.OA_TOLERANCE(); List data = toleranceBll.getTolerance(toleranceId); returnstr += FangYar.Common.JsonHelper.ToJson(data[0]); returnstr += ",\"waitData\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data[1]); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"count\":0,\"toleranceData\":[],\"waitData\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取公差信息、流转记录异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取公差信息、流转记录"); return returnstr; } #endregion #region 日喀则专属流程 //日喀则请假申请 private string AppLeaveTaskApplyRKZ(HttpContext context) { string returnstr = ""; try { bool flag = false; //请假表单字段 string leaveId = context.Request.Params["leaveId"]; if (string.IsNullOrEmpty(leaveId)) { flag = true; leaveId = Guid.NewGuid().ToString().ToGuid().ToString(); } string pplId = context.Request.Params["pplId"]; string pplName = context.Request.Params["pplName"]; string lType = context.Request.Params["lType"]; string sTime = context.Request.Params["sTime"]; string eTime = context.Request.Params["eTime"]; string lNum = context.Request.Params["lNum"]; string lOut = context.Request.Params["lOut"]; string accPplId = context.Request.Params["accId"]; string repPplId = context.Request.Params["repId"]; string lReason = context.Request.Params["reason"]; string title = context.Request.Params["title"]; string extend2 = context.Request.Params["extend2"]; FangYar.Model.OA_LEAVE leaveModel = new FangYar.Model.OA_LEAVE(); leaveModel.ID = leaveId; leaveModel.PPL_ID = pplId; leaveModel.PPL_NAME = pplName; leaveModel.L_TYPE = lType; leaveModel.S_TIME = sTime + ":00"; leaveModel.E_TIME = eTime + ":59"; leaveModel.L_NUM = lNum; leaveModel.L_OUT = lOut; leaveModel.ACC_PPL = accPplId; leaveModel.REP_PPL = repPplId; leaveModel.L_REASON = lReason; leaveModel.TITLE = title; leaveModel.STATE = "0"; leaveModel.IS_RETURN = "1"; leaveModel.EXTEND2 = extend2; leaveModel.EXTEND4 = "1_"; string str = GetObtainTheRKZFirstNodeApp(pplId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); leaveModel.EXTEND3 = str2[1]; leaveModel.EXTEND4 = str2[0]; leaveModel.EXTEND5 = str2[0]; } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); string opation = context.Request.Params["opation"];//操作类型 string receiveId = context.Request.Params["receiveId"];//接收人员 if (string.IsNullOrEmpty(receiveId)) { receiveId = leaveModel.EXTEND3; } switch (opation) { case "apply": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; } FangYar.BLL.OA_LEAVE leaveBll = new FangYar.BLL.OA_LEAVE(); //流程字段 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID var wfInstalled = bworkFlow.GetWorkFlowRunModel("80d051ff-dd3b-497a-bc00-aae330529c73"); if (flag) { leaveBll.Add(leaveModel); System.Threading.Thread.Sleep(500); execute.FlowID = "80d051ff-dd3b-497a-bc00-aae330529c73".ToGuid(); execute.GroupID = Guid.Empty; execute.InstanceID = leaveModel.ID.ToGuid().ToString(); execute.IsSign = false; execute.Note = ""; execute.Sender = userBll.GetModelByUID(pplId); execute.StepID = wfInstalled.FirstStepID; execute.TaskID = Guid.Empty; } else { leaveBll.Update(leaveModel); System.Threading.Thread.Sleep(500); wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); } execute.Title = title ?? ""; RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == eventParams.StepID); var currentStep = steps.First(); var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); execute.Steps.Add(nextSteps[0].ID, borganize.GetAllUsersIdString(receiveId)); var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "请假申请异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "请假申请"); return returnstr; } // 流程发起查询对应步骤和处理人 private string GetObtainTheRKZFirstNodeApp(string userId) { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); string returnstr = ""; try { var user = bll.GetModelByUID(userId); var nextUid = ""; var nextStep = ""; var isSuperior = "0"; var unit_org = bll_org.GetModel(user.ORG_ID);//所在单位部门 if (unit_org.EXTENDCODE1 == "1") //消防站 { nextStep = "1_"; nextUid = ""; var parent_org = bll_org.GetModel(unit_org.PID);//获取上级单位 if (user.TAGS != null && (user.TAGS.Contains("消防员") || user.TAGS.Contains("消防站干部"))) { nextStep = "1_"; nextUid = ""; if (parent_org.EXTENDCODE1 == "0")//上级是支队 消防站为支队直属特勤站 { nextStep = "7_"; nextUid = ""; } } else if (user.TAGS.Contains("消防站主官")) { nextStep = "2_"; nextUid = ""; isSuperior = "1"; if (parent_org.EXTENDCODE1 == "0")//上级是支队 消防站为支队直属特勤站 { nextStep = "3_"; nextUid = ""; isSuperior = "1"; } } } else if (unit_org.EXTENDCODE1 == "2") //大队 { nextStep = "2_"; nextUid = ""; if (user.TAGS != null && (user.TAGS.Contains("文员") || user.TAGS.Contains("消防员") || user.TAGS.Contains("消防站主官") || user.TAGS.Contains("大队干部"))) { nextStep = "2_"; nextUid = ""; } else if (user.TAGS.Contains("大队主官")) { nextStep = "3_"; nextUid = ""; isSuperior = "1"; } } else if (unit_org.EXTENDCODE1 == "0") //支队 { nextStep = "3_"; nextUid = ""; if (user.TAGS != null && (user.TAGS.Contains("文员") || user.TAGS.Contains("消防员") || user.TAGS.Contains("大队主官") || user.TAGS.Contains("支队干部"))) { nextStep = "3_"; nextUid = ""; } else if (user.TAGS.Contains("科室负责人") ) { nextStep = "4_"; nextUid = ""; } else if (user.TAGS.Contains("支队副职") || user.TAGS.Contains("支队分管领导") || user.TAGS.Contains("支队政治部")) { nextStep = "5_"; nextUid = ""; } else if (user.TAGS.Contains("支队主官")) { nextStep = "6_"; nextUid = ""; isSuperior = "1"; } } returnstr += nextStep + ";" + nextUid + ";" + isSuperior; } catch (Exception ex) { returnstr = ""; string str = "流程发起查询对应步骤和处理人:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppFlowLog" }); } return returnstr; } //日喀则请假流程处理 private string AppLeaveTaskHandleRKZ(HttpContext context) { string returnstr = ""; try { //流程字段 string comment = context.Request.Params["comment"];//处理意见 string opation = context.Request.Params["opation"];//操作类型 string flowid = context.Request.Params["flowid"];//流程ID string groupid = context.Request.Params["groupid"];//分组ID string instanceid = context.Request.Params["instanceid"];//实例ID string issign = context.Request.Params["issign"];//是否签章 string senderId = context.Request.Params["senderId"];//发送人员 string receiveId = context.Request.Params["receiveId"];//接收人员 string stepid = context.Request.Params["stepid"];//步骤ID string taskid = context.Request.Params["taskid"];//任务ID string title = context.Request.Params["title"];//标题 string EXTEND = context.Request.Params["EXTEND"];//延假小时 string isEXTEND = context.Request.Params["isEXTEND"];//是否为延假 0销假;1延假 //string EXTEND3 = context.Request.Params["EXTEND3"];// //receiveId = EXTEND3; string isSuperiorApprove = context.Request.Params["isSuperiorApprove"];//是否呈交上级审批 0是;1否 if (isSuperiorApprove == "0") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '0' where id = '" + taskid + "'"); } else if (isSuperiorApprove == "1") { FangYar.Common.MySqlHelper.ExecuteSql("update workflowtask set event_flag = '1' where id = '" + taskid + "'"); } if (isEXTEND == "1") { FangYar.BLL.OA_LEAVE ldal = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE lmodel = ldal.GetModel(instanceid); lmodel.EXTEND = EXTEND; ldal.Update(lmodel); } RoadFlow.Data.Model.WorkFlowExecute.Execute execute = new RoadFlow.Data.Model.WorkFlowExecute.Execute(); FangYar.BLL.OA_LEAVE leavebll = new FangYar.BLL.OA_LEAVE(); FangYar.Model.OA_LEAVE leaveModel = leavebll.GetModel(instanceid); switch (opation) { case "submit": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "save": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Save; break; case "back": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "completed": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed; execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; case "redirect": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Redirect; break; //新增同意 case "agree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree; //leavebll.EditState(instanceid, "1"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; //新增不同意 case "disagree": execute.ExecuteType = RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree; leavebll.EditState(instanceid, "2"); execute.Comment = comment.IsNullOrEmpty() ? "" : comment.Trim(); break; } FangYar.BLL.TBL.SysUsersBLL userBll = new FangYar.BLL.TBL.SysUsersBLL(); var wfInstalled = bworkFlow.GetWorkFlowRunModel(flowid); execute.FlowID = flowid.ToGuid(); execute.GroupID = groupid.ToGuid(); execute.InstanceID = instanceid; execute.IsSign = "1" == issign; execute.Note = ""; execute.Sender = userBll.GetModelByUID(senderId); execute.StepID = stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID; execute.TaskID = taskid.ToGuid(); execute.Title = title ?? ""; if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed) { FangYar.BLL.TBL.SysEmpBLL empbll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.TBL.TBL_SYS_EMP_Model emodel = new FangYar.Model.TBL.TBL_SYS_EMP_Model(); emodel.USERS_UID = leaveModel.PPL_ID; emodel.IS_WORK = "1"; empbll.EditEmpIswork(emodel); var accUsers = leaveModel.ACC_PPL.Split(','); foreach (string uid in accUsers) { emodel.USERS_UID = uid.Replace("u_", ""); empbll.EditEmpIswork(emodel); } } RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams = new RoadFlow.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = execute.FlowID; eventParams.GroupID = execute.GroupID; eventParams.StepID = execute.StepID; eventParams.TaskID = execute.TaskID; eventParams.InstanceID = execute.InstanceID; var steps = wfInstalled.Steps.Where(p => p.ID == execute.StepID); var currentStep = steps.First(); if (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { int backType = currentStep.Behavior.BackType;//退回类型 var prevSteps = bworkFlowTask.GetBackSteps(taskid.ToGuid(), backType, stepid.IsGuid() ? stepid.ToGuid() : wfInstalled.FirstStepID, wfInstalled); foreach (var step in prevSteps) { execute.Steps.Add(step.Key, new List()); } } else { var nextSteps = GetNextSteps(currentStep, wfInstalled, eventParams); if (nextSteps.Count > 0) { for (int i = 0; i < nextSteps.Count; i++) { switch (nextSteps[i].Behavior.HandlerType) { case 5://发起者 receiveId = bworkFlowTask.GetFirstSnderID(wfInstalled.ID, groupid); break; case 6://前一步骤处理者 //defaultMember = btask.GetStepSnderIDString(wfInstalled.ID, currentStep.ID, groupid.ToGuid()); //if (defaultMember.IsNullOrEmpty() && currentStep.ID == wfInstalled.FirstStepID) //{ receiveId = RoadFlow.Platform.Users.PREFIX + RoadFlow.Platform.Users.CurrentUserID.ToString(); //} break; case 7://某一步骤处理者 receiveId = bworkFlowTask.GetStepSnderIDString(wfInstalled.ID, nextSteps[i].Behavior.HandlerStepID, groupid.ToGuid()); break; case 8://字段值 string linkString = nextSteps[i].Behavior.ValueField; if (!linkString.IsNullOrEmpty() && !instanceid.IsNullOrEmpty() && wfInstalled.DataBases.Count() > 0) { receiveId = new RoadFlow.Platform.DBConnection().GetFieldValue(linkString, wfInstalled.DataBases.First().PrimaryKey, instanceid); } break; } execute.Steps.Add(nextSteps[i].ID, borganize.GetAllUsersIdString(receiveId)); } } } var reslut = bworkFlowTask.AppExecute(execute); //步骤提交后事件 if (!currentStep.Event.SubmitAfter.IsNullOrEmpty() && (execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Submit || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Completed || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Agree || execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Disagree)) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.SubmitAfter.Trim(), eventParams); } //步骤退回后事件 if (!currentStep.Event.BackAfter.IsNullOrEmpty() && execute.ExecuteType == RoadFlow.Data.Model.WorkFlowExecute.EnumType.ExecuteType.Back) { object obj = bworkFlowTask.ExecuteFlowCustomEvent(currentStep.Event.BackAfter.Trim(), eventParams); } returnstr += "{\"code\":0,\"msg\":"; returnstr += FangYar.Common.JsonHelper.ToJson(reslut); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\"}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "请假流程处理异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Other, "APP流程操作请求", "请假流程处理"); return returnstr; } // 获取本级单位部门、直属领导列表 public string AppGetMyOrgLeader(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); string userUid = context.Request.Params["usersUid"]; var user = bll.GetModelByUID(userUid); string orgId = "", deptId = "", tags = ""; if (user != null) { orgId = user.ORG_ID; deptId = user.DEPT_ID; tags = user.TAGS; } else { return "{\"code\":-1,\"msg\":\"参数有误!\",\"data\":[]}"; } // 当前用户信息 string deptIdStr = "''"; if (!string.IsNullOrWhiteSpace(deptId)) { var arr = deptId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arr.Length; i++) { deptIdStr += ",'" + arr[i] + "'"; } } FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; FangYar.Model.FIRE.FIRE_ORG model = orgBll.GetModel(orgId);//本级 string pid = model.ORG_ID; if (model.ISORG == "1") { pid = model.PID; } string tagWhere = ""; if (orgId != "D8DC637B8B984848A63F82A018AFAEB0" && orgId != "734389c7ae364584aea9918693bba3de") { if (tags.Contains("支队分管领导")) { tagWhere = " and tags like '%支队主官%'"; //tagWhere = " and (tags like '%支队主官%' or tags like '%支队副职%')"; } else if (tags.Contains("科室负责人")) { tagWhere = " and tags like '%支队分管领导%'"; } else if (tags.Contains("支队干部")) { tagWhere = " and tags like '%科室负责人%'"; } else if(tags.Contains("消防员") || tags.Contains("干部")) { tagWhere = " and tags like '%主官%'"; } } string sql = @"SELECT o.org_id id, o.org_name name, o.pid pid, CASE o.TYPE WHEN 0 THEN 'org' WHEN 1 THEN 'dept' ELSE o.TYPE END AS TYPE, o.sort sort,'' as photo,'' as tags FROM fire_org o ,(select get_Org_child_Dept_list_OrgIds((SELECT CONCAT( IFNULL(( SELECT t.ORG_ID FROM fire_org t WHERE t.pid = '" + orgId + @"' and t.isorg = '1' ),''), ',', '" + orgId + @"' ) FROM DUAL)) cids ) s WHERE find_in_set(o.org_id,cids) union select e.users_uid id,e.emp_name name,IF((ISNULL(e.dept_id) > 0 or LENGTH(trim(e.dept_id))=0),e.org_id,e.dept_id) pid, 'emp' type, (case when e.is_leader is not null then e.is_leader else 1 end) sort,IF((ISNULL(PHOTO) > 0 or LENGTH(trim(PHOTO))=0),'images/imgPerDefaut.jpg',PHOTO) photo,tags from tbl_sys_emp e,(select get_Org_child_Dept_list_OrgIds((SELECT CONCAT( IFNULL(( SELECT t.ORG_ID FROM fire_org t WHERE t.pid = '" + orgId + @"' and t.isorg = '1'),''), ',', '" + orgId + @"' ) FROM DUAL)) cids ) s WHERE IS_ADMIN='0' and find_in_set(e.org_id,cids) and e.users_uid is not null and e.is_del != '1' and USERS_UID<>'" + userUid + "'" + tagWhere + " order by id in (" + deptIdStr + ") DESC,type, sort desc"; DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql.ToString()); returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"pid\":\"" + model.PID + "\",\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取本级单位部门、人员列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取本级单位部门、人员列表"); return returnstr; } // 获取上级单位部门、直属领导列表 public string AppGetSuperiorOrgLeader(HttpContext context) { string returnstr = ""; try { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); string userUid = context.Request.Params["usersUid"]; var user = bll.GetModelByUID(userUid); string orgId = "", deptId = "", tags = ""; Boolean isZd = false; if (user != null) { orgId = user.ORG_ID; deptId = user.DEPT_ID; tags = user.TAGS; } else { return "{\"code\":-1,\"msg\":\"参数有误!\",\"data\":[]}"; } string deptIdStr = "''"; if (!string.IsNullOrWhiteSpace(deptId)) { var arr = deptId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arr.Length; i++) { deptIdStr += ",'" + arr[i] + "'"; } } if (string.IsNullOrEmpty(orgId)) { return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}"; } FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.FIRE.FIRE_ORG model = orgBll.GetModel(orgId); //本级 string pid = model.PID; if (pid == "1") { pid = model.ORG_ID; } if (model.ISORG == "1") { FangYar.Model.FIRE.FIRE_ORG model2 = orgBll.GetModel(model.PID); //父级 FangYar.Model.FIRE.FIRE_ORG model3 = orgBll.GetModel(model2.PID); //爷级 if (model3.PID == "1") { pid = model3.ORG_ID; } else if (model3.PID == "0") {//model2.ORG_ID 总队id //总队和总队机关 传的机关orgid pid = model2.ORG_ID; } } else { FangYar.Model.FIRE.FIRE_ORG model2 = orgBll.GetModel(model.PID); //父级 if (model2.EXTENDCODE1 == "0")//上级是支队 消防站为支队直属特勤站 { isZd = true; } } string tagWhere = ""; if (tags.Contains("支队主官")) { tagWhere = " and tags like '%处室负责人%'"; } else if (tags.Contains("大队主官")) { tagWhere = " and tags like '%科室负责人%'"; } else if (tags.Contains("消防站主官")) { if (isZd) { tagWhere = " and tags like '%科室负责人%'"; } else { tagWhere = " and tags like '%大队主官%'"; } } string sql = @"SELECT o.org_id id, o.org_name name, o.pid pid, CASE o.TYPE WHEN 0 THEN 'org' WHEN 1 THEN 'dept' ELSE o.TYPE END AS TYPE, o.sort sort,'' as photo FROM fire_org o ,(select get_Org_child_Dept_list_OrgIds((SELECT CONCAT( IFNULL(( SELECT t.ORG_ID FROM fire_org t WHERE t.pid = '" + pid + @"' and t.isorg = '1' ),''), ',', '" + pid + @"' ) FROM DUAL)) cids ) s WHERE find_in_set(o.org_id,cids) union select e.users_uid id,e.emp_name name,IF((ISNULL(e.dept_id) > 0 or LENGTH(trim(e.dept_id))=0),e.org_id,e.dept_id) pid, 'emp' type, (case when e.is_leader is not null then e.is_leader else 1 end) sort,IF((ISNULL(PHOTO) > 0 or LENGTH(trim(PHOTO))=0),'images/imgPerDefaut.jpg',PHOTO) photo from tbl_sys_emp e,(select get_Org_child_Dept_list_OrgIds((SELECT CONCAT( IFNULL(( SELECT t.ORG_ID FROM fire_org t WHERE t.pid = '" + pid + @"' and t.isorg = '1'),''), ',', '" + pid + @"' ) FROM DUAL)) cids ) s WHERE IS_ADMIN='0' and find_in_set(e.org_id,cids) and e.users_uid is not null and e.is_del != '1' and USERS_UID<>'" + userUid + "'" + tagWhere + " order by id in (" + deptIdStr + ") DESC,type, sort desc"; DataTable data = FangYar.Common.MySqlHelper.QueryTable(sql.ToString()); returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"pid\":\"" + pid + "\",\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"" + e.Message + "\",\"data\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取上级单位部门、人员列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取上级单位部门、人员列表"); return returnstr; } #endregion #region 通用接口 // 流程发起查询对应步骤和处理人 private string AppXZLSTQYZFirst(string userId) { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); string returnstr = ""; try { var user = bll.GetModelByUID(userId); var nextUid = ""; var nextStep = ""; var isSuperior = "0"; var unit_org = bll_org.GetModel(user.ORG_ID);//所在单位部门 if (unit_org.EXTENDCODE1 == "1") //消防站 { if (unit_org.PID == "f4d9f25b27114172a66a9d04cc158b00"//拉萨市消防救援支队 || unit_org.PID == "40a1e65991764d4dac2d826bfbbfc849"//日喀则市消防救援支队 || unit_org.PID == "5806465fa4e845998f31a10d023f332e"//昌都市消防救援支队 || unit_org.PID == "b5b00dfb27a34e0a8bd86270930e02d6"//林芝市消防救援支队 || unit_org.PID == "82487f0ebb6848e7ac4abc3d7cbc8504"//山南市消防救援支队 || unit_org.PID == "9a1324ec8b244a7f9d6cbca88cd614fd"//那曲市消防救援支队 || unit_org.PID == "833b28c12b42495a99a5e41068eb6805")//阿里地区消防救援支队 { if (user.TAGS != null && (user.TAGS.Contains("消防员") || user.TAGS.Contains("消防士"))) { nextStep = "14_"; nextUid = ""; } else if (user.TAGS.Contains("消防站主官")) { nextStep = "15_"; nextUid = ""; isSuperior = "1"; } else { nextStep = "14_"; nextUid = ""; } } else { if (user.TAGS != null && (user.TAGS.Contains("消防员") || user.TAGS.Contains("消防士"))) { nextStep = "1_"; nextUid = ""; } else if (user.TAGS.Contains("消防站主官")) { nextStep = "3_"; nextUid = ""; isSuperior = "1"; } else { nextStep = "1_"; nextUid = ""; } } } else if (unit_org.EXTENDCODE1 == "2") //大队 { if (user.TAGS != null && user.TAGS.Contains("文员")) { nextStep = "2_"; nextUid = ""; } else if (user.TAGS.Contains("大队主官")) { nextStep = "4_"; nextUid = ""; isSuperior = "1"; } else if (user.TAGS.Contains("干部") || user.TAGS.Contains("大队主官(副职)")) { nextStep = "3_"; nextUid = ""; } else { nextStep = "3_"; nextUid = ""; } } else if (unit_org.EXTENDCODE1 == "0") //支队 { if (user.TAGS != null && user.TAGS.Contains("文员")) { nextStep = "5_"; nextUid = ""; } else if (user.TAGS.Contains("支队主官")) { nextStep = "9_"; nextUid = ""; isSuperior = "1"; } else if (user.TAGS.Contains("支队副职") || user.TAGS.Contains("副支队长") || user.TAGS.Contains("副政委")) { nextStep = "8_"; nextUid = ""; } else if (user.TAGS.Contains("科室负责人") || user.TAGS.Contains("消防站主官")) { nextStep = "7_"; nextUid = ""; } else if (user.TAGS.Contains("干部")) { nextStep = "6_"; nextUid = ""; } else { nextStep = "6_"; nextUid = ""; } } else if (unit_org.EXTENDCODE1 == "3") //总队 { if (user.TAGS != null && user.TAGS.Contains("干部")) { nextStep = "10_"; nextUid = ""; } else if (user.TAGS.Contains("处室负责人")) { nextStep = "11_"; nextUid = ""; } else if (user.TAGS.Contains("消防员") || user.TAGS.Contains("消防士")) { nextStep = "12_"; nextUid = ""; } else if (user.TAGS.Contains("文员")) { nextStep = "13_"; nextUid = ""; } else { nextStep = "12_"; nextUid = ""; } } returnstr += nextStep + ";" + nextUid + ";" + isSuperior; } catch (Exception ex) { returnstr = ""; string str = "流程发起查询对应步骤和处理人:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppFlowLog" }); } return returnstr; } private string GetOutsideVehicleApprovalFirstNodeApp(string userId) { FangYar.BLL.TBL.SysEmpBLL bll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.BLL.FIRE.FIRE_ORG bll_org = new FangYar.BLL.FIRE.FIRE_ORG(); string returnstr = ""; try { var user = bll.GetModelByUID(userId); var nextUid = ""; var nextStep = ""; var isSuperior = "0"; var unit_org = bll_org.GetModel(user.ORG_ID);//所在单位部门 if (unit_org.EXTENDCODE1 == "1") //消防站 { nextStep = "1_"; nextUid = ""; var parent_org = bll_org.GetModel(unit_org.PID);//获取上级单位 if (user.TAGS != null && (user.TAGS.Contains("消防员") || user.TAGS.Contains("消防站干部"))) { nextStep = "1_"; nextUid = ""; if (parent_org.EXTENDCODE1 == "0")//上级是支队 消防站为支队直属特勤站 { nextStep = "9_"; nextUid = ""; } } else if (user.TAGS.Contains("消防站主官")) { nextStep = "2_"; nextUid = ""; isSuperior = "1"; if (parent_org.EXTENDCODE1 == "0")//上级是支队 消防站为支队直属特勤站 { nextStep = "4_"; nextUid = ""; isSuperior = "1"; } } } else if (unit_org.EXTENDCODE1 == "2") //大队 { nextStep = "2_"; nextUid = ""; if (user.TAGS != null && (user.TAGS.Contains("文员") || user.TAGS.Contains("消防员") || user.TAGS.Contains("消防站主官") || user.TAGS.Contains("大队干部") || user.TAGS.Contains("大队主官(副职)"))) { nextStep = "2_"; nextUid = ""; } else if (user.TAGS.Contains("大队主官")) { nextStep = "3_"; nextUid = ""; isSuperior = "1"; } } else if (unit_org.EXTENDCODE1 == "0") //支队 { nextStep = "3_"; nextUid = ""; if (user.TAGS != null && (user.TAGS.Contains("文员") || user.TAGS.Contains("消防员") || user.TAGS.Contains("大队主官") || user.TAGS.Contains("支队干部"))) { nextStep = "3_"; nextUid = ""; } else if (user.TAGS.Contains("科室负责人") || user.TAGS.Contains("支队副职") || user.TAGS.Contains("支队政治部")) { nextStep = "4_"; nextUid = ""; } else if (user.TAGS.Contains("支队主官")) { nextStep = "6_"; nextUid = ""; isSuperior = "1"; } } else if (unit_org.EXTENDCODE1 == "3") //总队 { nextStep = "5_"; nextUid = ""; if (user.TAGS != null && (user.TAGS.Contains("文员") || user.TAGS.Contains("消防员"))) { nextStep = "5_"; nextUid = ""; } else if (user.TAGS.Contains("总队干部")) { nextStep = "6_"; nextUid = ""; } else if (user.TAGS.Contains("处室负责人")) { nextStep = "7_"; nextUid = ""; } else if (user.TAGS.Contains("总队分管领导") || user.TAGS.Contains("总队政治部")) { nextStep = "8_"; nextUid = ""; } } returnstr += nextStep + ";" + nextUid + ";" + isSuperior; } catch (Exception ex) { returnstr = ""; string str = "流程发起查询对应步骤和处理人:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppFlowLog" }); } return returnstr; } // 获取流转步骤 public List GetNextSteps(RoadFlow.Data.Model.WorkFlowInstalledSub.Step currentStep, RoadFlow.Data.Model.WorkFlowInstalled wfInstalled, RoadFlow.Data.Model.WorkFlowCustomEventParams eventParams) { try { List removeIDList = new List(); RoadFlow.Platform.WorkFlowTask btask = new RoadFlow.Platform.WorkFlowTask(); RoadFlow.Platform.Users busers = new RoadFlow.Platform.Users(); var nextSteps = bworkFlow.GetNextSteps(wfInstalled.ID, currentStep.ID).OrderBy(p => p.Position_x).ThenBy(p => p.Position_y).ToList(); foreach (var step in nextSteps) { var lines = wfInstalled.Lines.Where(p => p.ToID == step.ID && p.FromID == currentStep.ID); if (lines.Count() > 0) { var line = lines.First(); if (!line.SqlWhere.IsNullOrEmpty()) { if (wfInstalled.DataBases.Count() == 0) { removeIDList.Add(step.ID); //nosubmitMsg.Append("流程未设置数据连接"); //nosubmitMsg.Append("\\n"); } else { if (!btask.TestLineSql(wfInstalled.DataBases.First().LinkID, wfInstalled.DataBases.First().Table, wfInstalled.DataBases.First().PrimaryKey, eventParams.InstanceID, line.SqlWhere)) { removeIDList.Add(step.ID); //nosubmitMsg.Append(string.Concat("提交条件未满足")); //nosubmitMsg.Append("\\n"); } } } if (!line.CustomMethod.IsNullOrEmpty()) { object obj = btask.ExecuteFlowCustomEvent(line.CustomMethod.Trim(), eventParams); var objType = obj.GetType(); var boolType = typeof(Boolean); if (objType != boolType && "1" != obj.ToString()) { removeIDList.Add(step.ID); } else if (objType == boolType && !(bool)obj) { removeIDList.Add(step.ID); } } #region 组织机构关系判断 string SenderID = RoadFlow.Platform.Users.CurrentUserID; if ("1" == line.Organize_SenderChargeLeader && !busers.IsChargeLeader(SenderID)) { removeIDList.Add(step.ID); } if (!line.Organize_SenderIn.IsNullOrEmpty() && !busers.IsContains(SenderID, line.Organize_SenderIn)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_SenderLeader && !busers.IsLeader(SenderID)) { removeIDList.Add(step.ID); } if (!line.Organize_SenderNotIn.IsNullOrEmpty() && busers.IsContains(SenderID, line.Organize_SenderNotIn)) { removeIDList.Add(step.ID); } string sponserID = "";//发起者ID if (currentStep.ID == wfInstalled.FirstStepID)//如果是第一步则发起者就是发送者 { sponserID = SenderID; } else { sponserID = btask.GetFirstSnderID(eventParams.FlowID, eventParams.GroupID.ToString()); } if ("1" == line.Organize_SponsorChargeLeader && !busers.IsChargeLeader(sponserID)) { removeIDList.Add(step.ID); } if (!line.Organize_SponsorIn.IsNullOrEmpty() && !busers.IsContains(sponserID, line.Organize_SponsorIn)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_SponsorLeader && !busers.IsLeader(sponserID)) { removeIDList.Add(step.ID); } if (!line.Organize_SponsorNotIn.IsNullOrEmpty() && busers.IsContains(sponserID, line.Organize_SponsorNotIn)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSenderChargeLeader && busers.IsChargeLeader(SenderID)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSenderLeader && busers.IsLeader(SenderID)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSponsorChargeLeader && busers.IsChargeLeader(sponserID)) { removeIDList.Add(step.ID); } if ("1" == line.Organize_NotSponsorLeader && busers.IsLeader(sponserID)) { removeIDList.Add(step.ID); } #endregion } } foreach (Guid rid in removeIDList) { nextSteps.RemoveAll(p => p.ID == rid); } return nextSteps; } catch (Exception ex) { string str = "获取流转步骤异常:" + ex; FangYar.Common.MyLogHelper.WriteMsg(new FangYar.Common.LogInfoMo() { message = str, msgType = FangYar.Common.EnumLogMsgTypeEnum.Error, path = "AppFlowLog" }); } return new List(); } // 获取本级单位部门、人员列表 public string AppGetMyOrgEmp(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["OrgId"]; string deptId = context.Request.Params["deptId"] + ""; // 当前用户信息 string usersUid = context.Request.Params["usersUid"]; string deptIdStr = "''"; if (!string.IsNullOrWhiteSpace(deptId)) { var arr = deptId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arr.Length; i++) { deptIdStr += ",'" + arr[i] + "'"; } } FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); returnstr = "{\"code\":0,\"msg\":\"\",\"data\":"; FangYar.Model.FIRE.FIRE_ORG model = orgBll.GetModel(orgId);//本级 string pid = model.ORG_ID; if (model.ISORG == "1") { pid = model.PID; } DataTable data = empBll.getOrgAndDeptEmpByOrgIds2(pid, deptIdStr, usersUid); //if (pid == "D8DC637B8B984848A63F82A018AFAEB0") //{ // data = empBll.getOrgAndDeptEmpByOrgIds2(pid); //} //else //{ // data = empBll.getOrgAndDeptEmpByOrgIds3(pid); //} returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"pid\":\"" + model.PID + "\",\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"error\",\"data\":[]}"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取本级单位部门、人员列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取本级单位部门、人员列表"); return returnstr; } // 获取上级单位部门、人员列表 public string AppGetSuperiorOrgEmp(HttpContext context) { string returnstr = ""; try { string orgId = context.Request.Params["orgId"]; string deptId = context.Request.Params["deptId"]; // 当前用户信息 string usersUid = context.Request.Params["usersUid"]; string deptIdStr = "''"; if (!string.IsNullOrWhiteSpace(deptId)) { var arr = deptId.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arr.Length; i++) { deptIdStr += ",'" + arr[i] + "'"; } } if (string.IsNullOrEmpty(orgId)) { return "{\"code\":\"-1\",\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"orgId参数不能为空!\",\"data\":[]}"; } FangYar.BLL.FIRE.FIRE_ORG orgBll = new FangYar.BLL.FIRE.FIRE_ORG(); FangYar.BLL.TBL.SysEmpBLL empBll = new FangYar.BLL.TBL.SysEmpBLL(); FangYar.Model.FIRE.FIRE_ORG model = orgBll.GetModel(orgId); //本级 string pid = model.PID; if (pid == "1") { pid = model.ORG_ID; } if (model.ISORG == "1") { FangYar.Model.FIRE.FIRE_ORG model2 = orgBll.GetModel(model.PID); //父级 FangYar.Model.FIRE.FIRE_ORG model3 = orgBll.GetModel(model2.PID); //爷级 //if (model3.PID == "1") //{ // pid = model2.PID; //} //else if (model3.PID == "0") //{//model2.ORG_ID 总队id // //总队和总队机关 传的机关orgid // pid = model2.ORG_ID; //} if (model3.PID == "1") { pid = model3.ORG_ID; } else if (model3.PID == "0") {//model2.ORG_ID 总队id //总队和总队机关 传的机关orgid pid = model2.ORG_ID; } } DataTable data = empBll.getOrgAndDeptEmpByOrgIds2(pid, deptIdStr, usersUid); //DataTable data = new DataTable(); //if (pid == "D8DC637B8B984848A63F82A018AFAEB0") //{ // data = empBll.getOrgAndDeptEmpByOrgIds2(pid); //} //else //{ // data = empBll.getOrgAndDeptEmpByOrgIds3(pid); //} returnstr = "{\"code\":0,\"msg\":\"操作成功!\",\"pid\":\"" + pid + "\",\"data\":"; returnstr += FangYar.Common.JsonHelper.ToJson(data); returnstr += "}"; } catch (Exception e) { returnstr = "{\"code\":-1,\"msg\":\"请求异常,请联系平台管理员。\",\"error\":\"" + e.Message + "\",\"data\":[] }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "获取上级单位部门、人员列表异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "获取上级单位部门、人员列表"); return returnstr; } // 判断是否需要上级审批 public string AppJudgeWhetherSuperiorOrgEmp(HttpContext context) { string returnstr = "{\"nextUid\":\"\",\"flag\":\"0\" }"; try { string userId = context.Request.Params["userId"]; string str = AppXZLSTQYZFirst(userId); if (str != null && str.Contains(';')) { var str2 = str.Split(';'); returnstr = "{\"nextUid\":\"" + str2[1] + "\",\"flag\":\"" + str2[2] + "\" }"; } } catch (Exception e) { returnstr = "{\"nextUid\":\"\",\"flag\":\"0\",\"error\":\"" + e.Message + "\" }"; // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Error, "APP流程操作请求", "判断是否需要上级审批异常:" + e); } // 记录操作日志 BLL.SysOperationLogHelp.AddSysOperationLog(context, Common.EnumOperationLogType.Query, "APP流程操作请求", "判断是否需要上级审批"); return returnstr; } #endregion public bool IsReusable { get { return false; } } } }