using learun.iapplication; using learun.util; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; namespace learun.webapi.Controllers { /// /// 版 本 Learun-ADMS-Core 力软管理后台 /// Copyright (c) 2019-present 力软信息技术(苏州)有限公司 /// 创建人:tobin /// 日 期:2020.04.17 /// 描 述:流程api /// [Route("newwf/[action]")] public class NewWorkFlowController : MvcControllerBase { private readonly NWFSchemeIBLL _nWFSchemeIBLL; private readonly NWFProcessIBLL _nWFProcessIBLL; private readonly FormSchemeIBLL _formSchemeIBLL; /// /// 初始化 /// /// 流程模板 /// 流程实例 /// 表单模板 public NewWorkFlowController(NWFSchemeIBLL nWFSchemeIBLL, NWFProcessIBLL nWFProcessIBLL, FormSchemeIBLL formSchemeIBLL) { _nWFSchemeIBLL = nWFSchemeIBLL; _nWFProcessIBLL = nWFProcessIBLL; _formSchemeIBLL = formSchemeIBLL; } /// /// 获取我的流程实例信息 /// /// 分页参数 /// 查询条件 /// [HttpGet] public async Task MyProcessList(Pagination pagination, string queryJson) { var list = await _nWFProcessIBLL.GetMyPageList(pagination, queryJson); var jsonData = new { rows = list, pagination.total, pagination.page, pagination.records }; return Success(jsonData); } /// /// /获取我的任务列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] public async Task MyTaskList(Pagination pagination, string queryJson) { var list = await _nWFProcessIBLL.GetMyTaskPageList(pagination, queryJson); var jsonData = new { rows = list, pagination.total, pagination.page, pagination.records }; return Success(jsonData); } /// /// 获取我已处理的任务列表 /// /// 分页参数 /// 查询条件 /// [HttpGet] public async Task MyMakeTaskList(Pagination pagination, string queryJson) { var list = await _nWFProcessIBLL.GetMyFinishTaskPageList(pagination, queryJson); var jsonData = new { rows = list, pagination.total, pagination.page, pagination.records }; return Success(jsonData); } /// /// 获取流程模板 /// /// 分页参数 /// 查询条件 /// [HttpGet] public async Task SchemePageList(Pagination pagination, string queryJson) { var list = await _nWFSchemeIBLL.GetAppInfoPageList(pagination, queryJson); var jsonData = new { rows = list, pagination.total, pagination.page, pagination.records }; return Success(jsonData); } /// /// 获取流程模板 /// /// 流程编码 /// [HttpGet] public async Task SchemeByCode(string code) { var schemeInfo = await _nWFSchemeIBLL.GetInfoEntityByCode(code); if (schemeInfo != null) { var data = await _nWFSchemeIBLL.GetSchemeEntity(schemeInfo.F_SchemeId); return Success(data); } return Fail("找不到该流程模板"); } /// /// 获取流程下一节点审核人员 /// /// 流程编码 /// 流程进程主键 /// 任务主键 /// 节点ID /// 操作编码 /// [HttpGet] public async Task NextAuditors(string code, string processId, string taskId, string nodeId, string operationCode) { var data = await _nWFProcessIBLL.GetNextAuditors(code, processId, taskId, nodeId, operationCode); return Success(data); } /// /// 获取流程进程信息 /// /// 进程主键 /// 任务主键 /// [HttpGet] public async Task ProcessDetails(string processId, string taskId) { var data = await _nWFProcessIBLL.GetProcessDetails(processId, taskId); if (!string.IsNullOrEmpty(data.childProcessId)) { processId = data.childProcessId; } var taskNode = await _nWFProcessIBLL.GetTaskUserList(processId); var jsonData = new { info = data, task = taskNode }; return Success(jsonData); } /// /// 创建流程实例 /// /// 流程模板编码 /// 流程实例主键 /// 流程标题 /// 流程等级 /// 下一节点审核人信息 /// 自定义表单请求参数 /// [HttpPost] public async Task Create([FromForm]string code, [FromForm]string processId, [FromForm]string title, [FromForm]int level, [FromForm]string auditors, [FromForm]string formreq) { await SaveForm(formreq); await _nWFProcessIBLL.CreateFlow(code, processId, title, level, auditors, this.GetUserId()); return this.SuccessInfo("创建成功"); } /// /// 重新创建流程 /// /// 流程实例主键 /// 自定义表单请求参数 /// [HttpPost] public async Task AgainCreateFlow([FromForm]string processId, [FromForm]string formreq) { await SaveForm(formreq); await _nWFProcessIBLL.AgainCreateFlow(processId); return SuccessInfo("重新创建成功"); } /// /// 创建流程(子流程) /// /// 流程模板编码 /// 流程实例主键 /// 父级流程实例主键 /// 父级流程任务主键 /// 表单请求数据 /// [HttpPost] public async Task CreateChildFlow([FromForm]string code, [FromForm]string processId, [FromForm]string parentProcessId, [FromForm]string parentTaskId, [FromForm]string formreq) { await SaveForm(formreq); await _nWFProcessIBLL.CreateChildFlow(code, processId, parentProcessId, parentTaskId); return SuccessInfo("子流程创建成功"); } /// /// 保存草稿(流程) /// /// 流程模板编码 /// 流程实例主键 /// 表单请求数据 /// [HttpPost] public async Task SaveDraft([FromForm]string code, [FromForm]string processId, [FromForm]string formreq) { await SaveForm(formreq); if (!string.IsNullOrEmpty(processId)) { await _nWFProcessIBLL.SaveDraft(processId, code, this.GetUserId()); } return SuccessInfo("保存成功"); } /// /// 删除草稿 /// /// 流程实例主键 /// [HttpPost] public async Task DeleteDraft([FromForm]string processId) { await _nWFProcessIBLL.DeleteDraft(processId); return SuccessInfo("草稿删除成功"); } /// /// 审批流程 /// /// 审核编码 /// 审核编码中文意思 /// 流程实例主键 /// 任务主键 /// 审核备注信息 /// 下一节点审核人信息 /// 审核人签名信息 /// 自定义表单信息 /// [HttpPost] public async Task AuditFlow([FromForm]string operationCode, [FromForm]string operationName, [FromForm]string processId, [FromForm]string taskId, [FromForm]string des, [FromForm]string auditors, [FromForm]string signUrl, [FromForm]string formreq) { await SaveForm(formreq); await _nWFProcessIBLL.AuditFlow(operationCode, operationName, processId, taskId, des, auditors, "", signUrl); return SuccessInfo("审批成功"); } /// /// 流程加签 /// /// 流程实例主键 /// 任务主键 /// 审核备注信息 /// 加签人ID /// 自定义表单信息 /// [HttpPost] public async Task SignFlow([FromForm]string processId, [FromForm]string taskId, [FromForm]string des, [FromForm]string userId, [FromForm]string formreq) { await SaveForm(formreq); await _nWFProcessIBLL.SignFlow(processId, taskId, userId, des); return SuccessInfo("加签成功"); } /// /// 流程加签审核 /// /// 审核码 /// 流程实例主键 /// 任务主键 /// 审核备注信息 /// 加签人ID /// 自定义表单信息 /// [HttpPost] public async Task SignAuditFlow([FromForm]string operationCode, [FromForm]string processId, [FromForm]string taskId, [FromForm]string des, [FromForm]string userId, [FromForm]string formreq) { await SaveForm(formreq); await _nWFProcessIBLL.SignAuditFlow(operationCode, processId, taskId, des); return SuccessInfo("加签审批成功"); } /// /// 催办流程 /// /// 流程实例主键 /// [HttpPost] public async Task UrgeFlow([FromForm]string processId) { await _nWFProcessIBLL.UrgeFlow(processId); return SuccessInfo("催办成功"); } /// /// 撤销流程(只有在该流程未被处理的情况下) /// /// 流程实例主键 /// [HttpPost] public async Task RevokeFlow([FromForm]string processId) { await _nWFProcessIBLL.RevokeFlow(processId); return SuccessInfo("撤销成功"); } /// /// 确认阅读 /// /// 流程实例主键 /// 任务主键 /// [HttpPost] public async Task ReferFlow([FromForm]string processId, [FromForm]string taskId) { await _nWFProcessIBLL.ReferFlow(processId, taskId); return SuccessInfo("确认成功"); } /// /// 保存自定义表单数据 /// /// 请求参数 private async Task SaveForm(string formreq) { FormParam formParam = formreq.ToObject(); await _formSchemeIBLL.SaveInstanceForm(formParam.schemeInfoId, formParam.processIdName, formParam.keyValue, formParam.formData); } /// /// 自定义表单提交参数 /// private class FormParam { /// /// 流程模板id /// public string schemeInfoId { get; set; } /// /// 关联字段名称 /// public string processIdName { get; set; } /// /// 数据主键值 /// public string keyValue { get; set; } /// /// 表单数据 /// public string formData { get; set; } } } }