|
- using System;
- using Learun.Util;
- using System.Data;
- using Learun.Application.TwoDevelopment.EducationalAdministration;
- using System.Web.Mvc;
- using Learun.Application.TwoDevelopment.LR_CodeDemo;
- using System.Collections.Generic;
- using Learun.Application.WorkFlow;
- using Learun.Application.Base.SystemModule;
- using System.Linq;
- using DocumentFormat.OpenXml.EMMA;
- using Learun.Application.Organization;
- //using Learun.Application.TwoDevelopment.LR_Desktop;
-
- namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
- {
- /// <summary>
- /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
- /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
- /// 创 建:超级管理员
- /// 日 期:2021-06-01 11:49
- /// 描 述:收文报告
- /// </summary>
- public class DispatchController : MvcControllerBase
- {
- private DispatchIBLL dispatchIBLL = new DispatchBLL();
- private NWFTaskIBLL nWFTaskIBLL = new NWFTaskBLL();
- private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();
- private DataItemIBLL dataItemIBLL = new DataItemBLL();
- private DispatchAuditIBLL dispatchAuditIBLL = new DispatchAuditBLL();
-
- #region 视图功能
-
- /// <summary>
- /// 主页面党建
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Index()
- {
- return View();
- }
- /// <summary>
- /// 校方
- /// </summary>
- /// <returns></returns>
- public ActionResult IndexXF()
- {
- return View("IndexXF");
- }
-
- public ActionResult ReadIndex()
- {
- var userInfo = LoginUserInfo.Get();
- ViewBag.userId = userInfo.userId;
- ViewBag.realname = userInfo.realName;
- return View();
- }
-
- /// <summary>
- /// 表单页
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Form()
- {
- return View();
- }
-
- /// <summary>
- /// 流程
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult FormView()
- {
- return View();
- }
-
- [HttpGet]
- public ActionResult ReadForm()
- {
- return View();
- }
-
-
- [HttpGet]
- public ActionResult SelectForm()
- {
- return View();
- }
-
- #endregion
-
- #region 获取数据
-
- /// <summary>
- /// 获取页面显示列表数据
- /// </summary>
- /// <param name="pagination">分页参数</param>
- /// <param name="queryJson">查询参数</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetPageList(string pagination, string queryJson)
- {
- Pagination paginationobj = pagination.ToObject<Pagination>();
- var data = dispatchIBLL.GetPageList(paginationobj, queryJson);
- foreach (var item in data)
- {
- if (item.FlowNo != "0")
- {
- var NewList = nWFTaskIBLL.GetLogList(item.processId).OrderBy(o => o.F_CreateDate).ToList();
- if (NewList.Count > 0)
- {
- item.CreateTime = NewList.First().F_CreateDate;
- item.CreateUser = NewList.First().F_CreateUserName;
- }
- }
- }
- var jsonData = new
- {
- rows = data,
- total = paginationobj.total,
- page = paginationobj.page,
- records = paginationobj.records
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormData(string keyValue)
- {
- var DispatchData = dispatchIBLL.GetDispatchEntity(keyValue);
- var jsonData = new
- {
- Dispatch = DispatchData,
- };
- return Success(jsonData);
- }
- /// <summary>
- /// 获取表单数据
- /// </summary>
- /// <param name="processId">流程实例主键</param>
- /// <returns></returns>
- [HttpGet]
- [AjaxOnly]
- public ActionResult GetFormDataByProcessId(string processId)
- {
- var DispatchData = dispatchIBLL.GetEntityByProcessId(processId);
- var jsonData = new
- {
- Dispatch = DispatchData,
- };
- return Success(jsonData);
- }
- #endregion
-
- #region 提交数据
-
- /// <summary>
- /// 删除实体数据
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult DeleteForm(string keyValue)
- {
- dispatchIBLL.DeleteEntity(keyValue);
- return Success("删除成功!");
- }
- /// <summary>
- /// 保存实体数据(新增、修改)
- /// </summary>
- /// <param name="keyValue">主键</param>
- /// <param name="strEntity">实体</param>
- /// <returns></returns>
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SaveForm(string keyValue, string strEntity)
- {
- DispatchEntity entity = strEntity.ToObject<DispatchEntity>();
- entity.FlowNo = "0";
- entity.Reasons = entity.AttachmentName;
- if (entity.DisOffice == "1")
- {
- entity.WorkName = "1";
- }
- else
- {
- entity.WorkName = "2";
- }
- dispatchIBLL.SaveEntity(keyValue, entity);
-
- if (string.IsNullOrEmpty(keyValue))
- {
- }
- return Success("保存成功!");
- }
- #endregion
-
- #region 扩展数据
-
- /// <summary>
- /// 提交单子
- /// </summary>
- /// <param name="keyValue">表主键</param>
- /// <param name="pastatus">审核状态</param>
- /// <param name="processId">流程Id</param>
- /// <returns></returns>
- public ActionResult ModifyStatus(string keyValue, int pastatus, string processId)
- {
- //var userInfo = LoginUserInfo.Get();
- //var RealName = userInfo.realName;
- dispatchIBLL.ModifyStatus(keyValue, pastatus, processId);
- return Success("提交成功!");
- }
-
- /// <summary>
- /// 打印
- /// <summary>
- /// <returns></returns>
- [HttpGet]
- public ActionResult Print(string keyValue)
- {
- var dispatchEntity = dispatchIBLL.GetDispatchEntity(keyValue);
-
- if (dispatchEntity == null)
- {
- return View(new DispatchEntity());
- }
- #region 获取附件名称
- if (dispatchEntity.AttachmentName != null)
- {
- string str = "";
- string[] array = annexesFileIBLL.GetFileNames(dispatchEntity.AttachmentName).Split(',');
- if (array.Length > 0)
- {
- for (int i = 0; i < array.Length; i++)
- {
- if (array[i].Trim() != "")
- {
- str += array[i].Substring(0, array[i].IndexOf(".")) + ",";
- }
- }
- str.TrimEnd(',');
- }
- dispatchEntity.Reasons = str;
- }
- #endregion
-
- #region 读取标题和办公室
- if (dispatchEntity.DisTitle != null)
- {
- var modelTitle = dataItemIBLL.GetDetailList("DisPatch");
- foreach (var item in modelTitle)
- {
- if (!string.IsNullOrEmpty(dispatchEntity.DisTitle) && item.F_ItemValue == dispatchEntity.DisTitle)
- {
- dispatchEntity.DisTitle = item.F_ItemName;
- }
- }
- }
- if (dispatchEntity.DisOffice != null)
- {
- var modelOffice = dataItemIBLL.GetDetailList("DisOffice");
- foreach (var item in modelOffice)
- {
- if (!string.IsNullOrEmpty(dispatchEntity.DisOffice) && item.F_ItemValue == dispatchEntity.DisOffice)
- {
- dispatchEntity.DisOffice = item.F_ItemName;
- }
- }
- }
- #endregion
-
- #region 获取校长的签名盖章+ 批示+时间+阅
- //var listTaskLog = nWFTaskIBLL.GetLogList(dispatchEntity.processId);
- var firstList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).OrderBy(o => o.F_CreateDate).ToList();
- for (int i = 1; i < firstList.Count; i++)
- {
- if (i == 1)
- {
- dispatchEntity.Render = firstList[i].F_Des;
- ViewBag.pSList += firstList[i].F_CreateUserName + firstList[i].F_CreateDate + "阅" + "&";
- }
- }
- var PrintList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).GroupBy(o => o.F_CreateUserName).Select(o => new
- {
- F_CreateDate = o.FirstOrDefault().F_CreateDate,
- F_CreateUserName = o.FirstOrDefault().F_CreateUserName,
- });
- var newList = PrintList.Where(s => PrintList.Select(mo => mo.F_CreateDate).Contains(s.F_CreateDate)).OrderBy(s => s.F_CreateDate).ToList();
- for (int i = 1; i < newList.Count; i++)
- {
- if (!ViewBag.pSList.Contains(newList[i].F_CreateUserName))
- {
- ViewBag.pSList += newList[i].F_CreateUserName + newList[i].F_CreateDate + "阅" + "&";
- }
- }
- ViewBag.pSList = ViewBag.pSList.TrimEnd('&');
- ViewBag.pSList = new List<string>(ViewBag.pSList.Split('&'));
- #endregion
- return View(dispatchEntity);
- }
-
- #region 查阅
- /// <summary>
- /// 查阅
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult Read(string keyValue)
- {
- var userInfo = LoginUserInfo.Get();
- var model = dispatchAuditIBLL.Repetition(keyValue, userInfo.realName);
- if (model != null)
- {
- return Fail("请勿重复批阅!");
- }
- else
- {
- var dispatchEntity = dispatchIBLL.GetDispatchEntity(keyValue);
- var printList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).Select(x => x.F_CreateUserName);
- if (printList.Contains(userInfo.realName))
- {
- return Fail("请勿重复批阅!");
- }
- else
- {
- DispatchAuditEntity entityaudit = new DispatchAuditEntity();
- entityaudit.DisId = keyValue;
- entityaudit.AuditTime = DateTime.Now;
- entityaudit.AuditUser = userInfo.userId;
- entityaudit.AuditName = userInfo.realName;
- dispatchAuditIBLL.SaveEntity("", entityaudit);
-
- dispatchIBLL.SaveEntity(keyValue, dispatchEntity);
- return Success("查阅完成!");
- }
- }
- }
- #endregion
-
- #region 设置传阅人
- [HttpPost]
- [ValidateAntiForgeryToken]
- [AjaxOnly]
- public ActionResult SetRead(string objectId, string userIds)
- {
- var model = dispatchIBLL.GetDispatchEntity(objectId);
- if (!string.IsNullOrEmpty(model.Reader))
- {
- return Fail("请勿重复设置传阅人!");
- }
- else
- {
- model.Reader = userIds;
- dispatchIBLL.SaveEntity(objectId, model);
- //var userInfo = LoginUserInfo.Get();
- //foreach (var item in userIds)
- //{
- // MessageRemindEntity entity = new MessageRemindEntity
- // {
- // ReceiptId = item.ToString(),
- // ReceiptName = userInfo.realName,
- // SenderId = userInfo.userId,
- // SenderName = userInfo.realName,
- // TheTitle = "查阅提醒",
- // TheContent = model.DisTitle,
- // //entity.InstanceId = item.F_ScheduleId;
- // ConnectionUrl = "/EducationalAdministration/Dispatch/ReadIndex?keyValue=",
- // SendTime = DateTime.Now,
- // ReadSigns = false
- // };
- // messageRindIBLL.SaveEntity("", entity);
- //}
- return Success("设置成功!");
- }
- }
- #endregion
-
- #region 查阅
- /// <summary>
- /// 查阅
- /// </summary>
- /// <param name="keyValue"></param>
- /// <returns></returns>
- [HttpPost]
- [AjaxOnly]
- public ActionResult ReadLD(string keyValue)
- {
- var userInfo = LoginUserInfo.Get();
- var dispatchEntity = dispatchIBLL.GetDispatchEntity(keyValue);
- var printList = nWFTaskIBLL.GetLogList(dispatchEntity.processId).Select(x => x.F_CreateUserName);
- if (printList.Contains(userInfo.realName))
- {
- return Fail("请勿重复阅读!");
- }
- else
- {
- DispatchAuditEntity entityaudit = new DispatchAuditEntity();
- entityaudit.DisId = keyValue;
- entityaudit.AuditTime = DateTime.Now;
- entityaudit.AuditUser = userInfo.userId;
- entityaudit.AuditName = userInfo.realName;
- dispatchAuditIBLL.SaveEntity("", entityaudit);
- return Success("阅读成功!");
- }
- }
- #endregion
-
- #endregion
-
- }
- }
|