using Learun.Application.Base.AuthorizeModule; using Learun.Application.Organization; using Learun.Application.WorkFlow; using Learun.Util; using System.Collections.Generic; using System.Web.Mvc; namespace Learun.Application.Web.Areas.LR_WorkFlowModule.Controllers { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创建人:陈彬彬 /// 日 期:2018.01.16 /// 描 述:流程引擎(流程接口) /// public class WfEngineController : MvcControllerBase { private UserRelationIBLL userRelationIBLL = new UserRelationBLL(); private UserIBLL userIBLL = new UserBLL(); /// /// 工作流引擎 /// private WfEngineIBLL wfEngineIBLL = new WfEngineBLL(); private WfProcessInstanceIBLL wfProcessInstanceIBLL = new WfProcessInstanceBLL(); private WfTaskIBLL wfTaskIBLL = new WfTaskBLL(); private WfSchemeIBLL wfSchemeIBLL = new WfSchemeBLL(); #region 获取数据 /// /// 初始化流程模板->获取开始节点数据 /// /// 是否是新发起的实例 /// 流程实例ID /// 流程模板编码 /// [HttpGet] [AjaxOnly] public ActionResult Bootstraper(bool isNew, string processId, string schemeCode) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.isNew = isNew; wfParameter.processId = processId; wfParameter.schemeCode = schemeCode; WfResult res = wfEngineIBLL.Bootstraper(wfParameter); return JsonResult(res); } /// /// 流程任务信息 /// /// 流程实例ID /// 流程模板编码 /// [HttpGet] [AjaxOnly] public ActionResult Taskinfo(string processId, string taskId) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.processId = processId; wfParameter.taskId = taskId; WfResult res = wfEngineIBLL.GetTaskInfo(wfParameter); return JsonResult(res); } /// /// 获取流程实例信息 /// /// 流程实例ID /// 流程模板编码 /// [HttpGet] [AjaxOnly] public ActionResult Processinfo(string processId, string taskId) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.processId = processId; wfParameter.taskId = taskId; WfResult res = wfEngineIBLL.GetProcessInfo(wfParameter); return JsonResult(res); } /// /// 获取流程实例信息(流程监控) /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult ProcessinfoByMonitor(string processId, string taskId) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.processId = processId; wfParameter.taskId = taskId; WfResult res = wfEngineIBLL.GetProcessInfoByMonitor(wfParameter); return JsonResult(res); } /// /// 获取下一个节点审核人员 /// /// /// /// [HttpPost] [AjaxOnly] [ValidateInput(false)] public ActionResult Auditer(bool isNew, string processId, string schemeCode, string taskId,string formData) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.isNew = isNew; wfParameter.processId = processId; wfParameter.schemeCode = schemeCode; wfParameter.taskId = taskId; wfParameter.formData = formData; WfResult> res = wfEngineIBLL.GetAuditer(wfParameter); if (res.status == 1) { List nodelist = new List(); var list = res.data; foreach (var item1 in list) { var item = item1.ToJson().ToJObject(); if (item["auditors"].IsEmpty()) { var point = new { all = true, name = item["name"], nodeId = item["nodeId"] }; nodelist.Add(point); } else { List userlist = new List(); foreach (var auditor in item["auditors"]) { switch (auditor["type"].ToString()) {//获取人员信息1.岗位2.角色3.用户 case "1": case "2": var userRelationList = userRelationIBLL.GetUserIdList(auditor["auditorId"].ToString()); string userIds = ""; foreach (var userRelation in userRelationList) { if (userIds != "") { userIds += ","; } userIds += userRelation.F_UserId; } var userList = userIBLL.GetListByUserIds(userIds); if (userList != null) { foreach (var user in userList) { if (user != null) { userlist.Add(new { id = user.F_UserId, name = user.F_RealName }); } } } break; case "3": userlist.Add(new { id = auditor["auditorId"], name = auditor["auditorName"] }); break; } } var point = new { name = item["name"], nodeId = item["nodeId"], list = userlist }; nodelist.Add(point); } } return JsonResult(nodelist); } else { return Fail("获取数据失败!"); } } #endregion #region 提交数据 /// /// 创建流程实例 /// /// 是否是新发起的实例 /// 流程实例ID /// 流程模板编码 /// 流程实例名称 /// 流程重要等级 /// 备注说明 /// 表单数据 /// [HttpPost] [AjaxOnly] [ValidateInput(false)] public ActionResult Create(bool isNew,string processId,string schemeCode,string processName,int processLevel,string description,string auditers, string formData) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.isNew = isNew; wfParameter.processId = processId; wfParameter.schemeCode = schemeCode; wfParameter.processName = processName; wfParameter.processLevel = processLevel; wfParameter.description = description; wfParameter.auditers = auditers; wfParameter.formData = formData; WfResult res = wfEngineIBLL.Create(wfParameter); return JsonResult(res); } /// /// 创建流程实例 /// /// 流程实例ID /// 流程模板编码 /// 流程实例名称 /// 加签人员Id /// 备注说明 /// 表单数据 /// [HttpPost] [AjaxOnly] [ValidateInput(false)] public ActionResult Audit(string taskId, string verifyType, string description, string auditorId, string auditorName,string auditers, string formData) { WfParameter wfParameter = new WfParameter(); UserInfo userInfo = LoginUserInfo.Get(); wfParameter.companyId = userInfo.companyId; wfParameter.departmentId = userInfo.departmentId; wfParameter.userId = userInfo.userId; wfParameter.userName = userInfo.realName; wfParameter.taskId = taskId; wfParameter.verifyType = verifyType; wfParameter.auditorId = auditorId; wfParameter.auditorName = auditorName; wfParameter.description = description; wfParameter.auditers = auditers; wfParameter.formData = formData; WfResult res = wfEngineIBLL.Audit(wfParameter); return JsonResult(res); } #endregion } }