using Learun.Application.WorkFlow;
using Learun.Util;
using Nancy;
using System.Collections.Generic;
namespace Learun.Application.WorkFlowServer.API
{
///
/// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
/// Copyright (c) 2013-2018 北京泉江科技有限公司
/// 创建人:陈彬彬
/// 日 期:2017.05.12
/// 描 述:流程进程实例API
///
public class ProcessApi : BaseApi
{
///
/// 注册接口
///
public ProcessApi()
: base("/workflow")
{
Post["/create"] = Create;
Post["/audit"] = Audit;
Get["/bootstraper"] = Bootstraper;
Get["/taskinfo"] = Taskinfo;
Get["/processinfo"] = ProcessInfo;
Get["/myprocess"] = GetMyProcess;
Get["/mytask"] = GetMyTaskList;
Get["/mytaskmaked"] = GetMyMakeTaskList;
Get["/schemelist"] = GetSchemeList;
Get["/auditer"] = GetAuditer;
}
///
/// 工作流引擎
///
private WfEngineIBLL wfEngineIBLL = new WfEngineBLL();
private WfProcessInstanceIBLL wfProcessInstanceIBLL = new WfProcessInstanceBLL();
private WfTaskIBLL wfTaskIBLL = new WfTaskBLL();
private WfSchemeIBLL wfSchemeIBLL = new WfSchemeBLL();
#region 获取信息
///
/// 初始化流程模板->获取开始节点数据
///
///
///
private Response Bootstraper(dynamic _)
{
WfParameter wfParameter = this.GetReqData();
wfParameter.companyId = this.userInfo.companyId;
wfParameter.departmentId = this.userInfo.departmentId;
wfParameter.userId = this.userInfo.userId;
wfParameter.userName = this.userInfo.realName;
WfResult res = wfEngineIBLL.Bootstraper(wfParameter);
return this.Success>(res);
}
///
/// 获取流程审核节点的信息
///
///
///
private Response Taskinfo(dynamic _)
{
WfParameter wfParameter = this.GetReqData();
wfParameter.companyId = this.userInfo.companyId;
wfParameter.departmentId = this.userInfo.departmentId;
wfParameter.userId = this.userInfo.userId;
wfParameter.userName = this.userInfo.realName;
WfResult res = wfEngineIBLL.GetTaskInfo(wfParameter);
return this.Success>(res);
}
///
/// 获取流程实例信息
///
///
///
private Response ProcessInfo(dynamic _)
{
WfParameter wfParameter = this.GetReqData();
wfParameter.companyId = this.userInfo.companyId;
wfParameter.departmentId = this.userInfo.departmentId;
wfParameter.userId = this.userInfo.userId;
wfParameter.userName = this.userInfo.realName;
WfResult res = wfEngineIBLL.GetProcessInfo(wfParameter);
return this.Success>(res);
}
///
/// 获取我的流程实例信息
///
///
///
private Response GetMyProcess(dynamic _)
{
QueryModel parameter = this.GetReqData();
IEnumerable list = new List();
list = wfProcessInstanceIBLL.GetMyPageList(this.userInfo.userId, parameter.pagination, parameter.queryJson);
var jsonData = new
{
rows = list,
total = parameter.pagination.total,
page = parameter.pagination.page,
records = parameter.pagination.records,
};
return Success(jsonData);
}
///
/// 获取我的任务列表
///
///
///
private Response GetMyTaskList(dynamic _)
{
QueryModel parameter = this.GetReqData();
IEnumerable list = new List();
list = wfTaskIBLL.GetActiveList(this.userInfo, parameter.pagination, parameter.queryJson);
var jsonData = new
{
rows = list,
total = parameter.pagination.total,
page = parameter.pagination.page,
records = parameter.pagination.records,
};
return Success(jsonData);
}
///
/// 获取我已处理的任务列表
///
///
///
private Response GetMyMakeTaskList(dynamic _)
{
QueryModel parameter = this.GetReqData();
IEnumerable list = new List();
list = wfTaskIBLL.GetHasList(this.userInfo.userId, parameter.pagination, parameter.queryJson);
var jsonData = new
{
rows = list,
total = parameter.pagination.total,
page = parameter.pagination.page,
records = parameter.pagination.records,
};
return Success(jsonData);
}
///
/// 获取流程模板数据
///
///
///
private Response GetSchemeList(dynamic _)
{
var data = wfSchemeIBLL.GetCustmerSchemeInfoList(userInfo);
return Success(data);
}
///
/// 获取下一个节点审核人员信息
///
///
///
private Response GetAuditer(dynamic _) {
WfParameter wfParameter = this.GetReqData();
wfParameter.companyId = this.userInfo.companyId;
wfParameter.departmentId = this.userInfo.departmentId;
wfParameter.userId = this.userInfo.userId;
wfParameter.userName = this.userInfo.realName;
WfResult> res = wfEngineIBLL.GetAuditer(wfParameter);
return this.Success(res);
}
#endregion
#region 提交信息
///
/// 创建流程实例
///
///
///
private Response Create(dynamic _)
{
WfParameter wfParameter = this.GetReqData();
wfParameter.companyId = this.userInfo.companyId;
wfParameter.departmentId = this.userInfo.departmentId;
wfParameter.userId = this.userInfo.userId;
wfParameter.userName = this.userInfo.realName;
WfResult res = wfEngineIBLL.Create(wfParameter);
return this.Success(res);
}
///
/// 审核流程实例
///
///
///
private Response Audit(dynamic _)
{
WfParameter wfParameter = this.GetReqData();
wfParameter.companyId = this.userInfo.companyId;
wfParameter.departmentId = this.userInfo.departmentId;
wfParameter.userId = this.userInfo.userId;
wfParameter.userName = this.userInfo.realName;
WfResult res = wfEngineIBLL.Audit(wfParameter);
return this.Success(res);
}
#endregion
///
/// 查询条件对象
///
private class QueryModel
{
public Pagination pagination { get; set; }
public string queryJson { get; set; }
}
}
}