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.
 
 
 
 
 
 

426 lines
14 KiB

  1. using System;
  2. using Learun.Util;
  3. using System.Data;
  4. using Learun.Application.TwoDevelopment.EducationalAdministration;
  5. using System.Web.Mvc;
  6. using Learun.Application.TwoDevelopment.LR_CodeDemo;
  7. using System.Collections.Generic;
  8. using Learun.Application.WorkFlow;
  9. using Learun.Application.Base.SystemModule;
  10. using System.Linq;
  11. using DocumentFormat.OpenXml.EMMA;
  12. using Learun.Application.Organization;
  13. //using Learun.Application.TwoDevelopment.LR_Desktop;
  14. namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
  15. {
  16. /// <summary>
  17. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  18. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  19. /// 创 建:超级管理员
  20. /// 日 期:2021-06-01 11:49
  21. /// 描 述:收文报告
  22. /// </summary>
  23. public class DispatchController : MvcControllerBase
  24. {
  25. private DispatchIBLL dispatchIBLL = new DispatchBLL();
  26. private NWFTaskIBLL nWFTaskIBLL = new NWFTaskBLL();
  27. private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
  28. private DataItemIBLL dataItemIBLL = new DataItemBLL();
  29. private DispatchAuditIBLL dispatchAuditIBLL = new DispatchAuditBLL();
  30. #region 视图功能
  31. /// <summary>
  32. /// 主页面党建
  33. /// <summary>
  34. /// <returns></returns>
  35. [HttpGet]
  36. public ActionResult Index()
  37. {
  38. return View();
  39. }
  40. /// <summary>
  41. /// 校方
  42. /// </summary>
  43. /// <returns></returns>
  44. public ActionResult IndexXF()
  45. {
  46. return View("IndexXF");
  47. }
  48. public ActionResult ReadIndex()
  49. {
  50. var userInfo = LoginUserInfo.Get();
  51. ViewBag.userId = userInfo.userId;
  52. ViewBag.realname = userInfo.realName;
  53. return View();
  54. }
  55. /// <summary>
  56. /// 表单页
  57. /// <summary>
  58. /// <returns></returns>
  59. [HttpGet]
  60. public ActionResult Form()
  61. {
  62. return View();
  63. }
  64. /// <summary>
  65. /// 流程
  66. /// <summary>
  67. /// <returns></returns>
  68. [HttpGet]
  69. public ActionResult FormView()
  70. {
  71. return View();
  72. }
  73. [HttpGet]
  74. public ActionResult ReadForm()
  75. {
  76. return View();
  77. }
  78. [HttpGet]
  79. public ActionResult SelectForm()
  80. {
  81. return View();
  82. }
  83. #endregion
  84. #region 获取数据
  85. /// <summary>
  86. /// 获取页面显示列表数据
  87. /// </summary>
  88. /// <param name="pagination">分页参数</param>
  89. /// <param name="queryJson">查询参数</param>
  90. /// <returns></returns>
  91. [HttpGet]
  92. [AjaxOnly]
  93. public ActionResult GetPageList(string pagination, string queryJson)
  94. {
  95. Pagination paginationobj = pagination.ToObject<Pagination>();
  96. var data = dispatchIBLL.GetPageList(paginationobj, queryJson);
  97. foreach (var item in data)
  98. {
  99. if (item.FlowNo != "0")
  100. {
  101. var NewList = nWFTaskIBLL.GetLogList(item.processId).OrderBy(o => o.F_CreateDate).ToList();
  102. if (NewList.Count > 0)
  103. {
  104. item.CreateTime = NewList.First().F_CreateDate;
  105. item.CreateUser = NewList.First().F_CreateUserName;
  106. }
  107. }
  108. }
  109. var jsonData = new
  110. {
  111. rows = data,
  112. total = paginationobj.total,
  113. page = paginationobj.page,
  114. records = paginationobj.records
  115. };
  116. return Success(jsonData);
  117. }
  118. /// <summary>
  119. /// 获取表单数据
  120. /// </summary>
  121. /// <param name="keyValue">主键</param>
  122. /// <returns></returns>
  123. [HttpGet]
  124. [AjaxOnly]
  125. public ActionResult GetFormData(string keyValue)
  126. {
  127. var DispatchData = dispatchIBLL.GetDispatchEntity(keyValue);
  128. var jsonData = new
  129. {
  130. Dispatch = DispatchData,
  131. };
  132. return Success(jsonData);
  133. }
  134. /// <summary>
  135. /// 获取表单数据
  136. /// </summary>
  137. /// <param name="processId">流程实例主键</param>
  138. /// <returns></returns>
  139. [HttpGet]
  140. [AjaxOnly]
  141. public ActionResult GetFormDataByProcessId(string processId)
  142. {
  143. var DispatchData = dispatchIBLL.GetEntityByProcessId(processId);
  144. var jsonData = new
  145. {
  146. Dispatch = DispatchData,
  147. };
  148. return Success(jsonData);
  149. }
  150. #endregion
  151. #region 提交数据
  152. /// <summary>
  153. /// 删除实体数据
  154. /// </summary>
  155. /// <param name="keyValue">主键</param>
  156. /// <returns></returns>
  157. [HttpPost]
  158. [AjaxOnly]
  159. public ActionResult DeleteForm(string keyValue)
  160. {
  161. dispatchIBLL.DeleteEntity(keyValue);
  162. return Success("删除成功!");
  163. }
  164. /// <summary>
  165. /// 保存实体数据(新增、修改)
  166. /// </summary>
  167. /// <param name="keyValue">主键</param>
  168. /// <param name="strEntity">实体</param>
  169. /// <returns></returns>
  170. [HttpPost]
  171. [ValidateAntiForgeryToken]
  172. [AjaxOnly]
  173. public ActionResult SaveForm(string keyValue, string strEntity)
  174. {
  175. DispatchEntity entity = strEntity.ToObject<DispatchEntity>();
  176. entity.FlowNo = "0";
  177. entity.Reasons = entity.AttachmentName;
  178. if (entity.DisOffice == "1")
  179. {
  180. entity.WorkName = "1";
  181. }
  182. else
  183. {
  184. entity.WorkName = "2";
  185. }
  186. dispatchIBLL.SaveEntity(keyValue, entity);
  187. if (string.IsNullOrEmpty(keyValue))
  188. {
  189. }
  190. return Success("保存成功!");
  191. }
  192. #endregion
  193. #region 扩展数据
  194. /// <summary>
  195. /// 提交单子
  196. /// </summary>
  197. /// <param name="keyValue">表主键</param>
  198. /// <param name="pastatus">审核状态</param>
  199. /// <param name="processId">流程Id</param>
  200. /// <returns></returns>
  201. public ActionResult ModifyStatus(string keyValue, int pastatus, string processId)
  202. {
  203. //var userInfo = LoginUserInfo.Get();
  204. //var RealName = userInfo.realName;
  205. dispatchIBLL.ModifyStatus(keyValue, pastatus, processId);
  206. return Success("提交成功!");
  207. }
  208. /// <summary>
  209. /// 打印
  210. /// <summary>
  211. /// <returns></returns>
  212. [HttpGet]
  213. public ActionResult Print(string keyValue)
  214. {
  215. var dispatchEntity = dispatchIBLL.GetDispatchEntity(keyValue);
  216. if (dispatchEntity == null)
  217. {
  218. return View(new DispatchEntity());
  219. }
  220. #region 获取附件名称
  221. if (dispatchEntity.AttachmentName != null)
  222. {
  223. string str = "";
  224. string[] array = annexesFileIBLL.GetFileNames(dispatchEntity.AttachmentName).Split(',');
  225. if (array.Length > 0)
  226. {
  227. for (int i = 0; i < array.Length; i++)
  228. {
  229. if (array[i].Trim() != "")
  230. {
  231. str += array[i].Substring(0, array[i].IndexOf(".")) + ",";
  232. }
  233. }
  234. str.TrimEnd(',');
  235. }
  236. dispatchEntity.Reasons = str;
  237. }
  238. #endregion
  239. #region 读取标题和办公室
  240. if (dispatchEntity.DisTitle != null)
  241. {
  242. var modelTitle = dataItemIBLL.GetDetailList("DisPatch");
  243. foreach (var item in modelTitle)
  244. {
  245. if (!string.IsNullOrEmpty(dispatchEntity.DisTitle) && item.F_ItemValue == dispatchEntity.DisTitle)
  246. {
  247. dispatchEntity.DisTitle = item.F_ItemName;
  248. }
  249. }
  250. }
  251. if (dispatchEntity.DisOffice != null)
  252. {
  253. var modelOffice = dataItemIBLL.GetDetailList("DisOffice");
  254. foreach (var item in modelOffice)
  255. {
  256. if (!string.IsNullOrEmpty(dispatchEntity.DisOffice) && item.F_ItemValue == dispatchEntity.DisOffice)
  257. {
  258. dispatchEntity.DisOffice = item.F_ItemName;
  259. }
  260. }
  261. }
  262. #endregion
  263. #region 获取校长的签名盖章+ 批示+时间+阅
  264. //var listTaskLog = nWFTaskIBLL.GetLogList(dispatchEntity.processId);
  265. var firstList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).OrderBy(o => o.F_CreateDate).ToList();
  266. for (int i = 1; i < firstList.Count; i++)
  267. {
  268. if (i == 1)
  269. {
  270. dispatchEntity.Render = firstList[i].F_Des;
  271. ViewBag.pSList += firstList[i].F_CreateUserName + firstList[i].F_CreateDate + "阅" + "&";
  272. }
  273. }
  274. var PrintList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).GroupBy(o => o.F_CreateUserName).Select(o => new
  275. {
  276. F_CreateDate = o.FirstOrDefault().F_CreateDate,
  277. F_CreateUserName = o.FirstOrDefault().F_CreateUserName,
  278. });
  279. var newList = PrintList.Where(s => PrintList.Select(mo => mo.F_CreateDate).Contains(s.F_CreateDate)).OrderBy(s => s.F_CreateDate).ToList();
  280. for (int i = 1; i < newList.Count; i++)
  281. {
  282. if (!ViewBag.pSList.Contains(newList[i].F_CreateUserName))
  283. {
  284. ViewBag.pSList += newList[i].F_CreateUserName + newList[i].F_CreateDate + "阅" + "&";
  285. }
  286. }
  287. ViewBag.pSList = ViewBag.pSList.TrimEnd('&');
  288. ViewBag.pSList = new List<string>(ViewBag.pSList.Split('&'));
  289. #endregion
  290. return View(dispatchEntity);
  291. }
  292. #region 查阅
  293. /// <summary>
  294. /// 查阅
  295. /// </summary>
  296. /// <param name="keyValue"></param>
  297. /// <returns></returns>
  298. [HttpPost]
  299. [AjaxOnly]
  300. public ActionResult Read(string keyValue)
  301. {
  302. var userInfo = LoginUserInfo.Get();
  303. var model = dispatchAuditIBLL.Repetition(keyValue, userInfo.realName);
  304. if (model != null)
  305. {
  306. return Fail("请勿重复批阅!");
  307. }
  308. else
  309. {
  310. var dispatchEntity = dispatchIBLL.GetDispatchEntity(keyValue);
  311. var printList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).Select(x => x.F_CreateUserName);
  312. if (printList.Contains(userInfo.realName))
  313. {
  314. return Fail("请勿重复批阅!");
  315. }
  316. else
  317. {
  318. DispatchAuditEntity entityaudit = new DispatchAuditEntity();
  319. entityaudit.DisId = keyValue;
  320. entityaudit.AuditTime = DateTime.Now;
  321. entityaudit.AuditUser = userInfo.userId;
  322. entityaudit.AuditName = userInfo.realName;
  323. dispatchAuditIBLL.SaveEntity("", entityaudit);
  324. dispatchIBLL.SaveEntity(keyValue, dispatchEntity);
  325. return Success("查阅完成!");
  326. }
  327. }
  328. }
  329. #endregion
  330. #region 设置传阅人
  331. [HttpPost]
  332. [ValidateAntiForgeryToken]
  333. [AjaxOnly]
  334. public ActionResult SetRead(string objectId, string userIds)
  335. {
  336. var model = dispatchIBLL.GetDispatchEntity(objectId);
  337. if (!string.IsNullOrEmpty(model.Reader))
  338. {
  339. return Fail("请勿重复设置传阅人!");
  340. }
  341. else
  342. {
  343. model.Reader = userIds;
  344. dispatchIBLL.SaveEntity(objectId, model);
  345. //var userInfo = LoginUserInfo.Get();
  346. //foreach (var item in userIds)
  347. //{
  348. // MessageRemindEntity entity = new MessageRemindEntity
  349. // {
  350. // ReceiptId = item.ToString(),
  351. // ReceiptName = userInfo.realName,
  352. // SenderId = userInfo.userId,
  353. // SenderName = userInfo.realName,
  354. // TheTitle = "查阅提醒",
  355. // TheContent = model.DisTitle,
  356. // //entity.InstanceId = item.F_ScheduleId;
  357. // ConnectionUrl = "/EducationalAdministration/Dispatch/ReadIndex?keyValue=",
  358. // SendTime = DateTime.Now,
  359. // ReadSigns = false
  360. // };
  361. // messageRindIBLL.SaveEntity("", entity);
  362. //}
  363. return Success("设置成功!");
  364. }
  365. }
  366. #endregion
  367. #region 查阅
  368. /// <summary>
  369. /// 查阅
  370. /// </summary>
  371. /// <param name="keyValue"></param>
  372. /// <returns></returns>
  373. [HttpPost]
  374. [AjaxOnly]
  375. public ActionResult ReadLD(string keyValue)
  376. {
  377. var userInfo = LoginUserInfo.Get();
  378. var dispatchEntity = dispatchIBLL.GetDispatchEntity(keyValue);
  379. var printList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).Select(x => x.F_CreateUserName);
  380. if (printList.Contains(userInfo.realName))
  381. {
  382. return Fail("请勿重复阅读!");
  383. }
  384. else
  385. {
  386. DispatchAuditEntity entityaudit = new DispatchAuditEntity();
  387. entityaudit.DisId = keyValue;
  388. entityaudit.AuditTime = DateTime.Now;
  389. entityaudit.AuditUser = userInfo.userId;
  390. entityaudit.AuditName = userInfo.realName;
  391. dispatchAuditIBLL.SaveEntity("", entityaudit);
  392. return Success("阅读成功!");
  393. }
  394. }
  395. #endregion
  396. #endregion
  397. }
  398. }