You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

294 lines
12 KiB

  1. using Learun.Application.Base.AuthorizeModule;
  2. using Learun.Application.Organization;
  3. using Learun.Application.WorkFlow;
  4. using Learun.Util;
  5. using System.Collections.Generic;
  6. using System.Web.Mvc;
  7. namespace Learun.Application.Web.Areas.LR_WorkFlowModule.Controllers
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  12. /// 创建人:陈彬彬
  13. /// 日 期:2018.01.16
  14. /// 描 述:流程引擎(流程接口)
  15. /// </summary>
  16. public class WfEngineController : MvcControllerBase
  17. {
  18. private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
  19. private UserIBLL userIBLL = new UserBLL();
  20. /// <summary>
  21. /// 工作流引擎
  22. /// </summary>
  23. private WfEngineIBLL wfEngineIBLL = new WfEngineBLL();
  24. private WfProcessInstanceIBLL wfProcessInstanceIBLL = new WfProcessInstanceBLL();
  25. private WfTaskIBLL wfTaskIBLL = new WfTaskBLL();
  26. private WfSchemeIBLL wfSchemeIBLL = new WfSchemeBLL();
  27. #region 获取数据
  28. /// <summary>
  29. /// 初始化流程模板->获取开始节点数据
  30. /// </summary>
  31. /// <param name="isNew">是否是新发起的实例</param>
  32. /// <param name="processId">流程实例ID</param>
  33. /// <param name="schemeCode">流程模板编码</param>
  34. /// <returns></returns>
  35. [HttpGet]
  36. [AjaxOnly]
  37. public ActionResult Bootstraper(bool isNew, string processId, string schemeCode)
  38. {
  39. WfParameter wfParameter = new WfParameter();
  40. UserInfo userInfo = LoginUserInfo.Get();
  41. wfParameter.companyId = userInfo.companyId;
  42. wfParameter.departmentId = userInfo.departmentId;
  43. wfParameter.userId = userInfo.userId;
  44. wfParameter.userName = userInfo.realName;
  45. wfParameter.isNew = isNew;
  46. wfParameter.processId = processId;
  47. wfParameter.schemeCode = schemeCode;
  48. WfResult<WfContent> res = wfEngineIBLL.Bootstraper(wfParameter);
  49. return JsonResult(res);
  50. }
  51. /// <summary>
  52. /// 流程任务信息
  53. /// </summary>
  54. /// <param name="processId">流程实例ID</param>
  55. /// <param name="taskId">流程模板编码</param>
  56. /// <returns></returns>
  57. [HttpGet]
  58. [AjaxOnly]
  59. public ActionResult Taskinfo(string processId, string taskId)
  60. {
  61. WfParameter wfParameter = new WfParameter();
  62. UserInfo userInfo = LoginUserInfo.Get();
  63. wfParameter.companyId = userInfo.companyId;
  64. wfParameter.departmentId = userInfo.departmentId;
  65. wfParameter.userId = userInfo.userId;
  66. wfParameter.userName = userInfo.realName;
  67. wfParameter.processId = processId;
  68. wfParameter.taskId = taskId;
  69. WfResult<WfContent> res = wfEngineIBLL.GetTaskInfo(wfParameter);
  70. return JsonResult(res);
  71. }
  72. /// <summary>
  73. /// 获取流程实例信息
  74. /// </summary>
  75. /// <param name="processId">流程实例ID</param>
  76. /// <param name="taskId">流程模板编码</param>
  77. /// <returns></returns>
  78. [HttpGet]
  79. [AjaxOnly]
  80. public ActionResult Processinfo(string processId, string taskId)
  81. {
  82. WfParameter wfParameter = new WfParameter();
  83. UserInfo userInfo = LoginUserInfo.Get();
  84. wfParameter.companyId = userInfo.companyId;
  85. wfParameter.departmentId = userInfo.departmentId;
  86. wfParameter.userId = userInfo.userId;
  87. wfParameter.userName = userInfo.realName;
  88. wfParameter.processId = processId;
  89. wfParameter.taskId = taskId;
  90. WfResult<WfContent> res = wfEngineIBLL.GetProcessInfo(wfParameter);
  91. return JsonResult(res);
  92. }
  93. /// <summary>
  94. /// 获取流程实例信息(流程监控)
  95. /// </summary>
  96. /// <param name="processId"></param>
  97. /// <param name="taskId"></param>
  98. /// <returns></returns>
  99. [HttpGet]
  100. [AjaxOnly]
  101. public ActionResult ProcessinfoByMonitor(string processId, string taskId)
  102. {
  103. WfParameter wfParameter = new WfParameter();
  104. UserInfo userInfo = LoginUserInfo.Get();
  105. wfParameter.companyId = userInfo.companyId;
  106. wfParameter.departmentId = userInfo.departmentId;
  107. wfParameter.userId = userInfo.userId;
  108. wfParameter.userName = userInfo.realName;
  109. wfParameter.processId = processId;
  110. wfParameter.taskId = taskId;
  111. WfResult<WfContent> res = wfEngineIBLL.GetProcessInfoByMonitor(wfParameter);
  112. return JsonResult(res);
  113. }
  114. /// <summary>
  115. /// 获取下一个节点审核人员
  116. /// </summary>
  117. /// <param name="processId"></param>
  118. /// <param name="taskId"></param>
  119. /// <returns></returns>
  120. [HttpPost]
  121. [AjaxOnly]
  122. [ValidateInput(false)]
  123. public ActionResult Auditer(bool isNew, string processId, string schemeCode, string taskId,string formData)
  124. {
  125. WfParameter wfParameter = new WfParameter();
  126. UserInfo userInfo = LoginUserInfo.Get();
  127. wfParameter.companyId = userInfo.companyId;
  128. wfParameter.departmentId = userInfo.departmentId;
  129. wfParameter.userId = userInfo.userId;
  130. wfParameter.userName = userInfo.realName;
  131. wfParameter.isNew = isNew;
  132. wfParameter.processId = processId;
  133. wfParameter.schemeCode = schemeCode;
  134. wfParameter.taskId = taskId;
  135. wfParameter.formData = formData;
  136. WfResult<List<object>> res = wfEngineIBLL.GetAuditer(wfParameter);
  137. if (res.status == 1)
  138. {
  139. List<object> nodelist = new List<object>();
  140. var list = res.data;
  141. foreach (var item1 in list) {
  142. var item = item1.ToJson().ToJObject();
  143. if (item["auditors"].IsEmpty())
  144. {
  145. var point = new
  146. {
  147. all = true,
  148. name = item["name"],
  149. nodeId = item["nodeId"]
  150. };
  151. nodelist.Add(point);
  152. }
  153. else {
  154. List<object> userlist = new List<object>();
  155. foreach (var auditor in item["auditors"]) {
  156. switch (auditor["type"].ToString()) {//获取人员信息1.岗位2.角色3.用户
  157. case "1":
  158. case "2":
  159. var userRelationList = userRelationIBLL.GetUserIdList(auditor["auditorId"].ToString());
  160. string userIds = "";
  161. foreach (var userRelation in userRelationList)
  162. {
  163. if (userIds != "")
  164. {
  165. userIds += ",";
  166. }
  167. userIds += userRelation.F_UserId;
  168. }
  169. var userList = userIBLL.GetListByUserIds(userIds);
  170. if (userList != null) {
  171. foreach (var user in userList)
  172. {
  173. if (user != null)
  174. {
  175. userlist.Add(new { id = user.F_UserId, name = user.F_RealName });
  176. }
  177. }
  178. }
  179. break;
  180. case "3":
  181. userlist.Add(new { id = auditor["auditorId"], name = auditor["auditorName"] });
  182. break;
  183. }
  184. }
  185. var point = new
  186. {
  187. name = item["name"],
  188. nodeId = item["nodeId"],
  189. list = userlist
  190. };
  191. nodelist.Add(point);
  192. }
  193. }
  194. return JsonResult(nodelist);
  195. }
  196. else
  197. {
  198. return Fail("获取数据失败!");
  199. }
  200. }
  201. #endregion
  202. #region 提交数据
  203. /// <summary>
  204. /// 创建流程实例
  205. /// </summary>
  206. /// <param name="isNew">是否是新发起的实例</param>
  207. /// <param name="processId">流程实例ID</param>
  208. /// <param name="schemeCode">流程模板编码</param>
  209. /// <param name="processName">流程实例名称</param>
  210. /// <param name="processLevel">流程重要等级</param>
  211. /// <param name="description">备注说明</param>
  212. /// <param name="formData">表单数据</param>
  213. /// <returns></returns>
  214. [HttpPost]
  215. [AjaxOnly]
  216. [ValidateInput(false)]
  217. public ActionResult Create(bool isNew,string processId,string schemeCode,string processName,int processLevel,string description,string auditers, string formData) {
  218. WfParameter wfParameter = new WfParameter();
  219. UserInfo userInfo = LoginUserInfo.Get();
  220. wfParameter.companyId = userInfo.companyId;
  221. wfParameter.departmentId = userInfo.departmentId;
  222. wfParameter.userId = userInfo.userId;
  223. wfParameter.userName = userInfo.realName;
  224. wfParameter.isNew = isNew;
  225. wfParameter.processId = processId;
  226. wfParameter.schemeCode = schemeCode;
  227. wfParameter.processName = processName;
  228. wfParameter.processLevel = processLevel;
  229. wfParameter.description = description;
  230. wfParameter.auditers = auditers;
  231. wfParameter.formData = formData;
  232. WfResult res = wfEngineIBLL.Create(wfParameter);
  233. return JsonResult(res);
  234. }
  235. /// <summary>
  236. /// 创建流程实例
  237. /// </summary>
  238. /// <param name="taskId">流程实例ID</param>
  239. /// <param name="verifyType">流程模板编码</param>
  240. /// <param name="description">流程实例名称</param>
  241. /// <param name="auditorId">加签人员Id</param>
  242. /// <param name="auditorName">备注说明</param>
  243. /// <param name="formData">表单数据</param>
  244. /// <returns></returns>
  245. [HttpPost]
  246. [AjaxOnly]
  247. [ValidateInput(false)]
  248. public ActionResult Audit(string taskId, string verifyType, string description, string auditorId, string auditorName,string auditers, string formData)
  249. {
  250. WfParameter wfParameter = new WfParameter();
  251. UserInfo userInfo = LoginUserInfo.Get();
  252. wfParameter.companyId = userInfo.companyId;
  253. wfParameter.departmentId = userInfo.departmentId;
  254. wfParameter.userId = userInfo.userId;
  255. wfParameter.userName = userInfo.realName;
  256. wfParameter.taskId = taskId;
  257. wfParameter.verifyType = verifyType;
  258. wfParameter.auditorId = auditorId;
  259. wfParameter.auditorName = auditorName;
  260. wfParameter.description = description;
  261. wfParameter.auditers = auditers;
  262. wfParameter.formData = formData;
  263. WfResult res = wfEngineIBLL.Audit(wfParameter);
  264. return JsonResult(res);
  265. }
  266. #endregion
  267. }
  268. }