using Learun.Application.WorkFlow; using Learun.Util; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using Learun.Application.Organization; using Learun.Application.Base.AuthorizeModule; namespace Learun.Application.Web.Areas.LR_NewWorkFlow.Controllers { /// /// 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架 /// Copyright (c) 2013-2018 上海力软信息技术有限公司 /// 创建人:力软-框架开发组 /// 日 期:2018.12.09 /// 描 述:流程进程 /// public class NWFProcessController : MvcControllerBase { private NWFProcessIBLL nWFProcessIBLL = new NWFProcessBLL(); private NWFSchemeIBLL nWFSchemeIBLL = new NWFSchemeBLL(); private NWFTaskIBLL nWFTaskIBLL = new NWFTaskBLL(); private UserIBLL userIbll = new UserBLL(); private UserRelationIBLL userRelationIBLL = new UserRelationBLL(); private DepartmentIBLL departmentIbll = new DepartmentBLL(); #region 视图功能 /// /// 视图功能 /// /// [HttpGet] public ActionResult Index() { return View(); } /// /// 发起流程 /// /// [HttpGet] public ActionResult ReleaseForm() { return View(); } /// /// 流程容器 /// /// [HttpGet] public ActionResult NWFContainerForm() { return View(); } /// /// 查看节点审核信息 /// /// [HttpGet] public ActionResult LookNodeForm() { return View(); } /// /// 创建流程 /// /// [HttpGet] public ActionResult CreateForm() { return View(); } /// /// 审核流程 /// /// [HttpGet] public ActionResult AuditFlowForm() { return View(); } /// /// 加签审核流程 /// /// [HttpGet] public ActionResult SignAuditFlowForm() { return View(); } /// /// 加签审核 /// /// [HttpGet] public ActionResult SignFlowForm() { return View(); } /// /// 合同打印 /// /// [HttpGet] public ActionResult htPrint(string keyValue) { //获取校长的签名盖章 var listTaskLog = nWFTaskIBLL.GetLogList(keyValue); var nwfTaskLogEntity = listTaskLog.FirstOrDefault(a => a.F_TaskUserName == "关亮"); if (nwfTaskLogEntity != null) { ViewBag.StampImg = nwfTaskLogEntity.F_StampImg; ViewBag.SignImg = nwfTaskLogEntity.F_SignImg; } var data = nWFProcessIBLL.GetHTInfo(keyValue); var userInfo = new UserEntity(); if (data != null) { userInfo = userIbll.GetEntityByUserId(data.F_CreateUserName); } var beginTime = data?.LC_htkssj.ToDate(); var endTime = data?.LC_htjssj.ToDate(); var operationTime = data?.OperationTime.ToDate(); ViewBag.UserName = userInfo?.F_RealName; ViewBag.IDCard = userInfo?.F_IdentityCardNo; ViewBag.BeginYear = beginTime?.Year; ViewBag.BeginMonth = beginTime?.Month; ViewBag.BeginDay = beginTime?.Day; ViewBag.EndYear = endTime?.Year; ViewBag.EndMonth = endTime?.Month; ViewBag.EndDay = endTime?.Day; ViewBag.OperationYear = operationTime?.Year; ViewBag.OperationMonth = operationTime?.Month; ViewBag.OperationDay = operationTime?.Day; return View(); } /// /// 流程进度查看(父子流程) /// /// [HttpGet] public ActionResult LookFlowForm() { return View(); } /// /// 监控页面 /// /// [HttpGet] public ActionResult MonitorIndex() { return View(); } /// /// 流程监控统计 /// /// [HttpGet] public ActionResult MonitorIndexStatistics() { return View(); } /// /// 合同归档 /// /// [HttpGet] public ActionResult ContractFiling() { return View(); } /// /// 人事归档 /// /// [HttpGet] public ActionResult PersonalFiling() { return View(); } /// /// 监控详情页面 /// /// [HttpGet] public ActionResult MonitorDetailsIndex() { return View(); } /// /// 查看各个节点表单 /// /// [HttpGet] public ActionResult MonitorForm() { return View(); } /// /// 指定审核人 /// /// [HttpGet] public ActionResult AppointForm() { return View(); } /// /// 添加审核节点 /// /// [HttpGet] public ActionResult AddTaskForm() { return View(); } /// /// 批量审核页面 /// /// [HttpGet] public ActionResult BatchAuditIndex() { return View(); } /// /// 选择下一节点审核人员 /// /// [HttpGet] public ActionResult SelectUserForm() { return View(); } /// /// 签名弹层 /// /// public ActionResult SignForm() { return View(); } #endregion #region 统计页面 [HttpGet] public ActionResult UseCar() { return View(); } [HttpGet] public ActionResult LeaveStatistics() { return View(); } [HttpGet] public ActionResult Transceiver() { return View(); } [HttpGet] public ActionResult MonitorIndexRenShi() { return View(); } [HttpGet] public ActionResult MonitorIndexZiChan() { return View(); } [HttpGet] public ActionResult MonitorIndexGongWen() { return View(); } [HttpGet] public ActionResult MonitorIndexXingZhen() { return View(); } /// /// 用印申请统计 /// /// [HttpGet] public ActionResult MonitorIndexOfyyspd() { return View(); } /// /// 会议室申请统计 /// /// [HttpGet] public ActionResult MonitorIndexOfmeeting() { return View(); } /// /// 党委会党委专题会申请统计 /// /// [HttpGet] public ActionResult MonitorIndexOfdwhsq() { return View(); } #endregion #region 获取数据 /// /// 获取我的流程信息列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetPorcessList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetUseCar(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetUseCar(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetLeaveStatistics(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetLeaveStatistics(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } [HttpGet] [AjaxOnly] public ActionResult GetTransceiver(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetTransceiver(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } public ActionResult GetFirstTaskByProcessId(string processId) { var taskId = nWFProcessIBLL.GetFirstTaskByProcessId(processId); return Success(new { taskId }); } /// /// 获取我的流程信息列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetTaskPageList(string pagination, string queryJson, string categoryId) { Pagination paginationobj = pagination.ToObject(); IEnumerable list = new List(); UserInfo userInfo = LoginUserInfo.Get(); switch (categoryId) { case "1": list = nWFProcessIBLL.GetMyPageList(userInfo.userId, paginationobj, queryJson); break; case "2": list = nWFProcessIBLL.GetMyTaskPageList(userInfo, paginationobj, queryJson); break; case "3": list = nWFProcessIBLL.GetMyFinishTaskPageList(userInfo, paginationobj, queryJson); break; } var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取批量审核任务清单 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetBatchTaskPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetMyTaskPageList(userInfo, paginationobj, queryJson, true); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 获取我的流程信息列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetTask(string taskId) { var data = nWFTaskIBLL.GetEntity(taskId); return Success(data); } #endregion #region 保存更新删除 /// /// 删除流程进程实体 /// /// 流程进程主键 [HttpPost] [AjaxOnly] public ActionResult DeleteEntity(string processId) { nWFProcessIBLL.DeleteEntity(processId); return Success("删除成功"); } #endregion #region 流程表单数据统计 /// /// 用印申请流程表单统计 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetPageListOfyyspd(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetPageListOfyyspd(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 会议室申请流程表单统计 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetPageListOfmeeting(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetPageListOfmeeting(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } /// /// 党委会党委专题会申请流程表单统计 /// /// 分页参数 /// 查询条件 /// [HttpGet] [AjaxOnly] public ActionResult GetPageListOfdwhsq(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var list = nWFProcessIBLL.GetPageListOfdwhsq(paginationobj, queryJson); var jsonData = new { rows = list, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records, }; return Success(jsonData); } #endregion #region 流程API /// /// 获取流程模板 /// /// 流程编码 /// [HttpGet] [AjaxOnly] public ActionResult GetSchemeByCode(string code) { var schemeInfo = nWFSchemeIBLL.GetInfoEntityByCode(code); if (schemeInfo != null) { var data = nWFSchemeIBLL.GetSchemeEntity(schemeInfo.F_SchemeId); return Success(data); } return Fail("找不到该流程模板"); } /// /// 根据流程进程主键获取流程模板 /// /// 流程进程主键 /// [HttpGet] [AjaxOnly] public ActionResult GetSchemeByProcessId(string processId) { var processEntity = nWFProcessIBLL.GetEntity(processId); if (processEntity != null) { if (string.IsNullOrEmpty(processEntity.F_SchemeId)) { var schemeInfo = nWFSchemeIBLL.GetInfoEntityByCode(processEntity.F_SchemeCode); if (schemeInfo != null) { var data = nWFSchemeIBLL.GetSchemeEntity(schemeInfo.F_SchemeId); return Success(data); } } else { var data = nWFSchemeIBLL.GetSchemeEntity(processEntity.F_SchemeId); return Success(data); } } return Fail("找不到该流程模板"); } /// /// 获取流程下一节点审核 /// /// 流程编码 /// 流程进程主键 /// 任务主键 /// 节点ID /// 操作编码 /// [HttpGet] [AjaxOnly] public ActionResult GetNextAuditors(string code, string processId, string taskId, string nodeId, string operationCode) { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetNextAuditors(code, processId, taskId, nodeId, operationCode, userInfo); return Success(data); } /// /// 获取流程进程信息 /// /// 进程主键 /// 任务主键 /// [HttpGet] [AjaxOnly] public ActionResult GetProcessDetails(string processId, string taskId) { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetProcessDetails(processId, taskId, userInfo); if (!string.IsNullOrEmpty(data.childProcessId)) { processId = data.childProcessId; } var taskNode = nWFProcessIBLL.GetTaskUserList(processId); var jsonData = new { info = data, task = taskNode }; return Success(jsonData); } /// /// 获取子流程详细信息 /// /// 父流程进程主键 /// 父流程子流程发起主键 /// 子流程流程模板编码 /// 父流程发起子流程节点Id /// [HttpGet] [AjaxOnly] public ActionResult GetChildProcessDetails(string processId, string taskId, string schemeCode, string nodeId) { UserInfo userInfo = LoginUserInfo.Get(); var data = nWFProcessIBLL.GetChildProcessDetails(processId, taskId, schemeCode, nodeId, userInfo); var taskNode = nWFProcessIBLL.GetTaskUserList(data.childProcessId); var jsonData = new { info = data, task = taskNode }; return Success(jsonData); } /// /// 保存草稿 /// /// 流程进程主键 /// 流程模板编码 /// [HttpPost] [AjaxOnly] public ActionResult SaveDraft(string processId, string schemeCode, string createUserId) { UserInfo userInfo = LoginUserInfo.Get(); if (!string.IsNullOrEmpty(createUserId) && userInfo.userId != createUserId) { var userEntity = userIbll.GetEntityByUserId(createUserId); userInfo.userId = userEntity.F_UserId; userInfo.enCode = userEntity.F_EnCode; userInfo.realName = userEntity.F_RealName; userInfo.nickName = userEntity.F_NickName; userInfo.headIcon = userEntity.F_HeadIcon; userInfo.gender = userEntity.F_Gender; userInfo.mobile = userEntity.F_Mobile; userInfo.telephone = userEntity.F_Telephone; userInfo.email = userEntity.F_Email; userInfo.oICQ = userEntity.F_OICQ; userInfo.weChat = userEntity.F_WeChat; userInfo.companyId = userEntity.F_CompanyId; userInfo.departmentId = userEntity.F_DepartmentId; userInfo.openId = userEntity.F_OpenId; userInfo.isSystem = userEntity.F_SecurityLevel == 1 ? true : false; } nWFProcessIBLL.SaveDraft(processId, schemeCode, userInfo); return Success("流程草稿保存成功"); } /// /// 删除草稿 /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteDraft(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.DeleteDraft(processId, userInfo); return Success("流程草稿删除成功"); } /// /// 创建流程 /// /// 流程模板编码 /// 流程进程主键 /// 流程进程自定义标题 /// 流程进程等级 /// 下一节点审核人 /// 流程创建人 /// [HttpPost] [AjaxOnly] public ActionResult CreateFlow(string schemeCode, string processId, string title, int level, string auditors, string createUserId) { UserInfo userInfo = LoginUserInfo.Get(); if (!string.IsNullOrEmpty(createUserId) && userInfo.userId != createUserId) { if (title == null) { title = ""; } title += "【" + userInfo.realName + "代发】"; var userEntity = userIbll.GetEntityByUserId(createUserId); userInfo.userId = userEntity.F_UserId; userInfo.enCode = userEntity.F_EnCode; userInfo.realName = userEntity.F_RealName; userInfo.nickName = userEntity.F_NickName; userInfo.headIcon = userEntity.F_HeadIcon; userInfo.gender = userEntity.F_Gender; userInfo.mobile = userEntity.F_Mobile; userInfo.telephone = userEntity.F_Telephone; userInfo.email = userEntity.F_Email; userInfo.oICQ = userEntity.F_OICQ; userInfo.weChat = userEntity.F_WeChat; userInfo.companyId = userEntity.F_CompanyId; userInfo.departmentId = userEntity.F_DepartmentId; userInfo.openId = userEntity.F_OpenId; userInfo.isSystem = userEntity.F_SecurityLevel == 1 ? true : false; userInfo.roleIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 1); userInfo.postIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 2); } try { nWFProcessIBLL.CreateFlow(schemeCode, processId, title, level, auditors, userInfo); return Success("流程创建成功"); } catch (System.Exception ex) { nWFProcessIBLL.SaveDraft(processId, schemeCode, userInfo); return Fail(ex.Message); } } /// /// 创建流程(子流程) /// /// 流程模板编码 /// 流程进程主键 /// 父流程进程主键 /// 父流程任务主键 /// [HttpPost] [AjaxOnly] public ActionResult CreateChildFlow(string schemeCode, string processId, string parentProcessId, string parentTaskId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.CreateChildFlow(schemeCode, processId, parentProcessId, parentTaskId, userInfo); return Success("流程创建成功"); } /// /// 重新创建流程 /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult AgainCreateFlow(string processId) { try { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AgainCreateFlow(processId, userInfo); return Success("流程重新创建成功"); } catch (System.Exception ex) { return Fail(ex.Message); } } /// /// 审批流程 /// /// 流程审批操作码agree 同意 disagree 不同意 lrtimeout 超时 /// 流程审批操名称 /// 流程进程主键 /// 流程任务主键 /// 审批意见 /// 下一节点指定审核人 /// [HttpPost] [AjaxOnly] public ActionResult AuditFlow(string operationCode, string operationName, string processId, string taskId, string des, string auditors, string stamp, string signUrl) { UserInfo userInfo = LoginUserInfo.Get(); try { nWFProcessIBLL.AuditFlow(operationCode, operationName, processId, taskId, des, auditors, stamp, signUrl, userInfo); return Success("流程审批成功"); } catch (System.Exception ex) { return Fail(ex.Message); } } /// /// 审批流程 /// /// 流程审批操作码agree 同意 disagree 不同意 /// 任务串 /// [HttpPost] [AjaxOnly] public ActionResult AuditFlows(string operationCode, string taskIds) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AuditFlows(operationCode, taskIds, userInfo); return Success("流程批量审批成功"); } /// /// 流程加签 /// /// 流程进程主键 /// 流程任务主键 /// 加签人员 /// 加签说明 /// [HttpPost] [AjaxOnly] public ActionResult SignFlow(string processId, string taskId, string userId, string des) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.SignFlow(processId, taskId, userId, des, userInfo); return Success("流程加签成功"); } /// /// 流程加签 /// /// 流程进程主键 /// 流程任务主键 /// 加签人员(可多人) /// 加签说明 /// [HttpPost] [AjaxOnly] public ActionResult SignFlowTwo(string processId, string taskId, string userId, string des) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.SignFlowTwo(processId, taskId, userId, des, userInfo); return Success("流程加签成功"); } /// /// 流程加签审核 /// /// 审核操作码 /// 流程进程主键 /// 流程任务主键 /// 加签说明 /// [HttpPost] [AjaxOnly] public ActionResult SignAuditFlow(string operationCode, string processId, string taskId, string des) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.SignAuditFlow(operationCode, processId, taskId, des, userInfo); return Success("加签审批成功"); } /// /// 确认阅读 /// /// 流程进程主键 /// 流程任务主键 /// [HttpPost] [AjaxOnly] public ActionResult ReferFlow(string processId, string taskId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.ReferFlow(processId, taskId, userInfo); return Success("保存成功"); } /// /// 催办流程 /// /// 流程进程主键 /// 当前操作人信息 /// [HttpPost] [AjaxOnly] public ActionResult UrgeFlow(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.UrgeFlow(processId, userInfo); return Success("催办成功"); } /// /// 撤销流程(只有在该流程未被处理的情况下) /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult RevokeFlow(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.RevokeFlow(processId, userInfo); return Success("撤销成功"); } /// /// 获取流程当前任务需要处理的人 /// /// 流程进程主键 /// [HttpGet] [AjaxOnly] public ActionResult GetTaskUserList(string processId) { var data = nWFProcessIBLL.GetTaskUserList(processId); return Success(data); } /// /// 指派流程审核人 /// /// 任务列表 [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult AppointUser(string strList) { IEnumerable list = strList.ToObject>(); UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AppointUser(list, userInfo); return Success("指派成功"); } /// /// 作废流程 /// /// 流程进程主键 /// [HttpPost] [AjaxOnly] public ActionResult DeleteFlow(string processId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.DeleteFlow(processId, userInfo); return Success("作废成功"); } /// /// 撤销审核 /// /// 流程进程主键 /// 任务主键 /// [HttpPost] [AjaxOnly] public ActionResult RevokeAudit(string processId, string taskId) { UserInfo userInfo = LoginUserInfo.Get(); var res = nWFProcessIBLL.RevokeAudit(processId, taskId, userInfo); if (res) { return Success("撤销成功"); } else { return Fail("撤销失败,当前不允许撤销!"); } } /// /// 添加任务 /// /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult AddTask(string processId, string bNodeId, string eNodeId) { UserInfo userInfo = LoginUserInfo.Get(); nWFProcessIBLL.AddTask(processId, bNodeId, eNodeId, userInfo); return Success("添加成功"); } #endregion [HttpGet] public ActionResult GetNextUser(string F_TaskId) { List usernamelist = new List(); List nextlist = nWFTaskIBLL.GetTaskUserList(F_TaskId).Select(m => m.F_UserId).ToList(); foreach (var uid in nextlist) { var userentity = userIbll.GetEntityByUserId(uid); string deptname = departmentIbll.GetEntity(userentity?.F_DepartmentId)?.F_FullName; usernamelist.Add("[" + deptname + "]" + userentity?.F_RealName); } return SuccessString(string.Join(",", usernamelist)); } [HttpGet] public ActionResult GetNextUserMonitor(string F_ProcessId) { var tasklist = nWFTaskIBLL.GetUnFinishTaskList(F_ProcessId).FirstOrDefault(); if (tasklist != null && !string.IsNullOrEmpty(tasklist.F_Id)) { List usernamelist = new List(); List nextlist = nWFTaskIBLL.GetTaskUserList(tasklist.F_Id).Select(m => m.F_UserId).ToList(); foreach (var uid in nextlist) { var userentity = userIbll.GetEntityByUserId(uid); string deptname = departmentIbll.GetEntity(userentity?.F_DepartmentId)?.F_FullName; usernamelist.Add("[" + deptname + "]" + userentity?.F_RealName); } return SuccessString(string.Join(",", usernamelist)); } else { return SuccessString(""); } } /// /// 流程监控统计 /// /// [HttpPost] public ActionResult StatisticsData() { nWFProcessIBLL.StatisticsData(); return Success("操作成功"); } } }