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.
 
 
 
 
 
 

335 lines
9.9 KiB

  1. using Learun.Application.Base.AuthorizeModule;
  2. using Learun.Application.Organization;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. namespace Learun.Application.WorkFlow
  7. {
  8. /// <summary>
  9. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  10. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  11. /// 创建人:陈彬彬
  12. /// 日 期:2017.04.17
  13. /// 描 述:任务实例
  14. /// </summary>
  15. public class WfTaskBLL : WfTaskIBLL
  16. {
  17. private WfTaskService wfTaskService = new WfTaskService();
  18. private UserIBLL userIBLL = new UserBLL();
  19. private UserRelationIBLL userRelationIBLL = new UserRelationBLL();
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取未完成的流程实例任务列表
  23. /// </summary>
  24. /// <param name="processId">流程实例主键</param>
  25. /// <returns></returns>
  26. public IEnumerable<WfTaskEntity> GetList(string processId)
  27. {
  28. try
  29. {
  30. return wfTaskService.GetList(processId);
  31. }
  32. catch (Exception ex)
  33. {
  34. if (ex is ExceptionEx)
  35. {
  36. throw;
  37. }
  38. else
  39. {
  40. throw ExceptionEx.ThrowBusinessException(ex);
  41. }
  42. }
  43. }
  44. /// <summary>
  45. /// 获取当前任务节点主键
  46. /// </summary>
  47. /// <param name="processId">流程实例主键</param>
  48. /// <returns></returns>
  49. public List<string> GetCurrentNodeIds(string processId)
  50. {
  51. try
  52. {
  53. return wfTaskService.GetCurrentNodeIds(processId);
  54. }
  55. catch (Exception ex)
  56. {
  57. if (ex is ExceptionEx)
  58. {
  59. throw;
  60. }
  61. else
  62. {
  63. throw ExceptionEx.ThrowBusinessException(ex);
  64. }
  65. }
  66. }
  67. /// <summary>
  68. /// 获取任务实体
  69. /// </summary>
  70. /// <param name="keyValue">主键</param>
  71. /// <returns></returns>
  72. public WfTaskEntity GetEntity(string keyValue)
  73. {
  74. try
  75. {
  76. return wfTaskService.GetEntity(keyValue);
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowBusinessException(ex);
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// 获取任务实体
  92. /// </summary>
  93. /// <param name="processId">流程实例主键</param>
  94. /// <param name="nodeId">节点主键</param>
  95. /// <returns></returns>
  96. public WfTaskEntity GetEntity(string processId, string nodeId)
  97. {
  98. try
  99. {
  100. return wfTaskService.GetEntity(processId, nodeId);
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowBusinessException(ex);
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// 获取任务实体
  116. /// </summary>
  117. /// <param name="processId">流程实例主键</param>
  118. /// <param name="nodeId">节点主键</param>
  119. /// <returns></returns>
  120. public WfTaskEntity GetEntityUnFinish(string processId, string nodeId)
  121. {
  122. try
  123. {
  124. return wfTaskService.GetEntityUnFinish(processId, nodeId);
  125. }
  126. catch (Exception ex)
  127. {
  128. if (ex is ExceptionEx)
  129. {
  130. throw;
  131. }
  132. else
  133. {
  134. throw ExceptionEx.ThrowBusinessException(ex);
  135. }
  136. }
  137. }
  138. /// <summary>
  139. /// 获取委托信息列表
  140. /// </summary>
  141. /// <param name="userId"></param>
  142. /// <returns></returns>
  143. public List<UserInfo> GetDelegateTask(string userId)
  144. {
  145. try
  146. {
  147. List<UserInfo> list = wfTaskService.GetDelegateTask(userId);
  148. foreach (var item in list)
  149. {
  150. UserEntity userEntity = userIBLL.GetEntityByUserId(item.userId);
  151. item.companyId = userEntity.F_CompanyId;
  152. item.departmentId = userEntity.F_DepartmentId;
  153. item.roleIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 1);
  154. item.postIds = userRelationIBLL.GetObjectIds(userEntity.F_UserId, 2);
  155. }
  156. return list;
  157. }
  158. catch (Exception ex)
  159. {
  160. if (ex is ExceptionEx)
  161. {
  162. throw;
  163. }
  164. else
  165. {
  166. throw ExceptionEx.ThrowBusinessException(ex);
  167. }
  168. }
  169. }
  170. /// <summary>
  171. /// 获取未处理任务列表
  172. /// </summary>
  173. /// <param name="userInfo">用户信息</param>
  174. /// <param name="pagination">翻页信息</param>
  175. /// <param name="queryJson">查询条件</param>
  176. /// <returns></returns>
  177. public IEnumerable<WfProcessInstanceEntity> GetActiveList(UserInfo userInfo, Pagination pagination, string queryJson)
  178. {
  179. try
  180. {
  181. List<UserInfo> delegateList = GetDelegateTask(userInfo.userId);
  182. return wfTaskService.GetActiveList(userInfo, pagination, queryJson, delegateList);
  183. }
  184. catch (Exception ex)
  185. {
  186. if (ex is ExceptionEx)
  187. {
  188. throw;
  189. }
  190. else
  191. {
  192. throw ExceptionEx.ThrowBusinessException(ex);
  193. }
  194. }
  195. }
  196. /// <summary>
  197. /// 获取已处理任务列表
  198. /// </summary>
  199. /// <param name="userId">用户主键</param>
  200. /// <param name="pagination">翻页信息</param>
  201. /// <param name="queryJson">查询条件</param>
  202. /// <returns></returns>
  203. public IEnumerable<WfProcessInstanceEntity> GetHasList(string userId, Pagination pagination, string queryJson)
  204. {
  205. try
  206. {
  207. return wfTaskService.GetHasList(userId, pagination, queryJson);
  208. }
  209. catch (Exception ex)
  210. {
  211. if (ex is ExceptionEx)
  212. {
  213. throw;
  214. }
  215. else
  216. {
  217. throw ExceptionEx.ThrowBusinessException(ex);
  218. }
  219. }
  220. }
  221. #endregion
  222. #region 提交数据
  223. /// <summary>
  224. /// 保存或更新流程实例任务
  225. /// </summary>
  226. /// <param name="keyValue">主键</param>
  227. /// <param name="entity">实体</param>
  228. public void SaveEntity(WfTaskEntity entity)
  229. {
  230. try
  231. {
  232. wfTaskService.SaveEntity(entity);
  233. }
  234. catch (Exception ex)
  235. {
  236. if (ex is ExceptionEx)
  237. {
  238. throw;
  239. }
  240. else
  241. {
  242. throw ExceptionEx.ThrowBusinessException(ex);
  243. }
  244. }
  245. }
  246. /// <summary>
  247. /// 保存或更新流程实例任务
  248. /// </summary>
  249. /// <param name="entity">实体</param>
  250. /// <param name="companyId">公司主键</param>
  251. /// <param name="departmentId">部门主键</param>
  252. public void SaveEntitys(WfTaskEntity entity, string companyId, string departmentId)
  253. {
  254. try
  255. {
  256. wfTaskService.SaveEntitys(entity, companyId, departmentId);
  257. }
  258. catch (Exception ex)
  259. {
  260. if (ex is ExceptionEx)
  261. {
  262. throw;
  263. }
  264. else
  265. {
  266. throw ExceptionEx.ThrowBusinessException(ex);
  267. }
  268. }
  269. }
  270. /// <summary>
  271. /// 更新任务状态
  272. /// </summary>
  273. /// <param name="keyValue">主键</param>
  274. /// <param name="state">状态 1 完成 2 关闭(会签 </param>
  275. public void UpdateState(string keyValue, int state)
  276. {
  277. try
  278. {
  279. wfTaskService.UpdateState(keyValue, state);
  280. }
  281. catch (Exception ex)
  282. {
  283. if (ex is ExceptionEx)
  284. {
  285. throw;
  286. }
  287. else
  288. {
  289. throw ExceptionEx.ThrowBusinessException(ex);
  290. }
  291. }
  292. }
  293. /// <summary>
  294. /// 更新任务完成状态
  295. /// </summary>
  296. /// <param name="processId">流程实例主键</param>
  297. /// <param name="nodeId">节点主键</param>
  298. /// <param name="taskId">任务节点Id</param>
  299. /// <param name="userId">用户主键</param>
  300. /// <param name="userName">用户名称</param>
  301. public void UpdateStateByNodeId(string processId, string nodeId, string taskId, string userId, string userName)
  302. {
  303. try
  304. {
  305. wfTaskService.UpdateStateByNodeId(processId, nodeId, taskId, userId, userName);
  306. }
  307. catch (Exception ex)
  308. {
  309. if (ex is ExceptionEx)
  310. {
  311. throw;
  312. }
  313. else
  314. {
  315. throw ExceptionEx.ThrowBusinessException(ex);
  316. }
  317. }
  318. }
  319. #endregion
  320. }
  321. }