Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 
 

233 rindas
8.2 KiB

  1. using Learun.Application.WorkFlow;
  2. using Learun.Util;
  3. using Nancy;
  4. using System.Collections.Generic;
  5. namespace Learun.Application.WorkFlowServer.API
  6. {
  7. /// <summary>
  8. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  9. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  10. /// 创建人:陈彬彬
  11. /// 日 期:2017.05.12
  12. /// 描 述:流程进程实例API
  13. /// </summary>
  14. public class ProcessApi : BaseApi
  15. {
  16. /// <summary>
  17. /// 注册接口
  18. /// </summary>
  19. public ProcessApi()
  20. : base("/workflow")
  21. {
  22. Post["/create"] = Create;
  23. Post["/audit"] = Audit;
  24. Get["/bootstraper"] = Bootstraper;
  25. Get["/taskinfo"] = Taskinfo;
  26. Get["/processinfo"] = ProcessInfo;
  27. Get["/myprocess"] = GetMyProcess;
  28. Get["/mytask"] = GetMyTaskList;
  29. Get["/mytaskmaked"] = GetMyMakeTaskList;
  30. Get["/schemelist"] = GetSchemeList;
  31. Get["/auditer"] = GetAuditer;
  32. }
  33. /// <summary>
  34. /// 工作流引擎
  35. /// </summary>
  36. private WfEngineIBLL wfEngineIBLL = new WfEngineBLL();
  37. private WfProcessInstanceIBLL wfProcessInstanceIBLL = new WfProcessInstanceBLL();
  38. private WfTaskIBLL wfTaskIBLL = new WfTaskBLL();
  39. private WfSchemeIBLL wfSchemeIBLL = new WfSchemeBLL();
  40. #region 获取信息
  41. /// <summary>
  42. /// 初始化流程模板->获取开始节点数据
  43. /// </summary>
  44. /// <param name="_"></param>
  45. /// <returns></returns>
  46. private Response Bootstraper(dynamic _)
  47. {
  48. WfParameter wfParameter = this.GetReqData<WfParameter>();
  49. wfParameter.companyId = this.userInfo.companyId;
  50. wfParameter.departmentId = this.userInfo.departmentId;
  51. wfParameter.userId = this.userInfo.userId;
  52. wfParameter.userName = this.userInfo.realName;
  53. WfResult<WfContent> res = wfEngineIBLL.Bootstraper(wfParameter);
  54. return this.Success<WfResult<WfContent>>(res);
  55. }
  56. /// <summary>
  57. /// 获取流程审核节点的信息
  58. /// </summary>
  59. /// <param name="_"></param>
  60. /// <returns></returns>
  61. private Response Taskinfo(dynamic _)
  62. {
  63. WfParameter wfParameter = this.GetReqData<WfParameter>();
  64. wfParameter.companyId = this.userInfo.companyId;
  65. wfParameter.departmentId = this.userInfo.departmentId;
  66. wfParameter.userId = this.userInfo.userId;
  67. wfParameter.userName = this.userInfo.realName;
  68. WfResult<WfContent> res = wfEngineIBLL.GetTaskInfo(wfParameter);
  69. return this.Success<WfResult<WfContent>>(res);
  70. }
  71. /// <summary>
  72. /// 获取流程实例信息
  73. /// </summary>
  74. /// <param name="_"></param>
  75. /// <returns></returns>
  76. private Response ProcessInfo(dynamic _)
  77. {
  78. WfParameter wfParameter = this.GetReqData<WfParameter>();
  79. wfParameter.companyId = this.userInfo.companyId;
  80. wfParameter.departmentId = this.userInfo.departmentId;
  81. wfParameter.userId = this.userInfo.userId;
  82. wfParameter.userName = this.userInfo.realName;
  83. WfResult<WfContent> res = wfEngineIBLL.GetProcessInfo(wfParameter);
  84. return this.Success<WfResult<WfContent>>(res);
  85. }
  86. /// <summary>
  87. /// 获取我的流程实例信息
  88. /// </summary>
  89. /// <param name="_"></param>
  90. /// <returns></returns>
  91. private Response GetMyProcess(dynamic _)
  92. {
  93. QueryModel parameter = this.GetReqData<QueryModel>();
  94. IEnumerable<WfProcessInstanceEntity> list = new List<WfProcessInstanceEntity>();
  95. list = wfProcessInstanceIBLL.GetMyPageList(this.userInfo.userId, parameter.pagination, parameter.queryJson);
  96. var jsonData = new
  97. {
  98. rows = list,
  99. total = parameter.pagination.total,
  100. page = parameter.pagination.page,
  101. records = parameter.pagination.records,
  102. };
  103. return Success(jsonData);
  104. }
  105. /// <summary>
  106. /// 获取我的任务列表
  107. /// </summary>
  108. /// <param name="_"></param>
  109. /// <returns></returns>
  110. private Response GetMyTaskList(dynamic _)
  111. {
  112. QueryModel parameter = this.GetReqData<QueryModel>();
  113. IEnumerable<WfProcessInstanceEntity> list = new List<WfProcessInstanceEntity>();
  114. list = wfTaskIBLL.GetActiveList(this.userInfo, parameter.pagination, parameter.queryJson);
  115. var jsonData = new
  116. {
  117. rows = list,
  118. total = parameter.pagination.total,
  119. page = parameter.pagination.page,
  120. records = parameter.pagination.records,
  121. };
  122. return Success(jsonData);
  123. }
  124. /// <summary>
  125. /// 获取我已处理的任务列表
  126. /// </summary>
  127. /// <param name="_"></param>
  128. /// <returns></returns>
  129. private Response GetMyMakeTaskList(dynamic _)
  130. {
  131. QueryModel parameter = this.GetReqData<QueryModel>();
  132. IEnumerable<WfProcessInstanceEntity> list = new List<WfProcessInstanceEntity>();
  133. list = wfTaskIBLL.GetHasList(this.userInfo.userId, parameter.pagination, parameter.queryJson);
  134. var jsonData = new
  135. {
  136. rows = list,
  137. total = parameter.pagination.total,
  138. page = parameter.pagination.page,
  139. records = parameter.pagination.records,
  140. };
  141. return Success(jsonData);
  142. }
  143. /// <summary>
  144. /// 获取流程模板数据
  145. /// </summary>
  146. /// <param name="_"></param>
  147. /// <returns></returns>
  148. private Response GetSchemeList(dynamic _)
  149. {
  150. var data = wfSchemeIBLL.GetCustmerSchemeInfoList(userInfo);
  151. return Success(data);
  152. }
  153. /// <summary>
  154. /// 获取下一个节点审核人员信息
  155. /// </summary>
  156. /// <param name="_"></param>
  157. /// <returns></returns>
  158. private Response GetAuditer(dynamic _) {
  159. WfParameter wfParameter = this.GetReqData<WfParameter>();
  160. wfParameter.companyId = this.userInfo.companyId;
  161. wfParameter.departmentId = this.userInfo.departmentId;
  162. wfParameter.userId = this.userInfo.userId;
  163. wfParameter.userName = this.userInfo.realName;
  164. WfResult<List<object>> res = wfEngineIBLL.GetAuditer(wfParameter);
  165. return this.Success(res);
  166. }
  167. #endregion
  168. #region 提交信息
  169. /// <summary>
  170. /// 创建流程实例
  171. /// </summary>
  172. /// <param name="_"></param>
  173. /// <returns></returns>
  174. private Response Create(dynamic _)
  175. {
  176. WfParameter wfParameter = this.GetReqData<WfParameter>();
  177. wfParameter.companyId = this.userInfo.companyId;
  178. wfParameter.departmentId = this.userInfo.departmentId;
  179. wfParameter.userId = this.userInfo.userId;
  180. wfParameter.userName = this.userInfo.realName;
  181. WfResult res = wfEngineIBLL.Create(wfParameter);
  182. return this.Success<WfResult>(res);
  183. }
  184. /// <summary>
  185. /// 审核流程实例
  186. /// </summary>
  187. /// <param name="_"></param>
  188. /// <returns></returns>
  189. private Response Audit(dynamic _)
  190. {
  191. WfParameter wfParameter = this.GetReqData<WfParameter>();
  192. wfParameter.companyId = this.userInfo.companyId;
  193. wfParameter.departmentId = this.userInfo.departmentId;
  194. wfParameter.userId = this.userInfo.userId;
  195. wfParameter.userName = this.userInfo.realName;
  196. WfResult res = wfEngineIBLL.Audit(wfParameter);
  197. return this.Success<WfResult>(res);
  198. }
  199. #endregion
  200. /// <summary>
  201. /// 查询条件对象
  202. /// </summary>
  203. private class QueryModel
  204. {
  205. public Pagination pagination { get; set; }
  206. public string queryJson { get; set; }
  207. }
  208. }
  209. }