using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using EMIS.ViewModel; using EMIS.Web.Controls; using Bowin.Web.Controls.Mvc; using EMIS.CommonLogic.MinorGraduation.MinorGraduationManage; using Bowin.Common.JSON; using EMIS.ViewModel.MinorGraduation.MinorGraduationManage; using EMIS.ViewModel.WorkflowManage; using Bowin.Common.Utility; using Bowin.Common.Exceptions; using Bowin.Common.Data; namespace EMIS.Web.Controllers.MinorGraduation.MinorGraduationManage { [Authorization] public class MinorGraduationApproveController : Controller { // // GET: /MinorGraduationApprove/ public IMinorGraduationApplyServices minorGraduationApplyServices { get; set; } public ActionResult List() { return View(); } [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); var gradSchoolyearID = pararms.getExtraGuid("GradSchoolyearDropdown"); var collegeID = pararms.getExtraGuid("CollegeDropdown"); var yearID = pararms.getExtraInt("SchoolyearDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("SchoolyearDictionaryDropDown"); var standardID = pararms.getExtraInt("StandardDictionaryDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("StandardDictionaryDropDown"); //毕业类型 var graduationTypeID = pararms.getExtraInt("DictionaryGraduationType") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationType"); //在校状态 var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus"); //毕业结论 var graduationResult = pararms.getExtraInt("DictionaryGraduationResult") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryGraduationResult"); //审核状态 var approvalStatus = pararms.getExtraInt("DictionaryApprovalStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryApprovalStatus"); return base.Json(minorGraduationApplyServices.GetMinorGraduationApproveViewGrid(configuretView, gradSchoolyearID, collegeID, yearID, standardID, graduationTypeID, inSchoolStatus, graduationResult, approvalStatus, (int)pararms.page, (int)pararms.rows)); } [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); //var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["GradSchoolyearDropdown"].ParseStrTo(); var gradSchoolyearID = Request.Form["GradSchoolyearDropdown"].ParseStrTo(); var collegeID = Request.Form["CollegeDropdown"].ParseStrTo(); var yearID = Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["SchoolyearDictionaryDropDown"].ParseStrTo(); var standardID = Request.Form["StandardDictionaryDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["StandardDictionaryDropDown"].ParseStrTo(); //毕业类型 var graduationTypeID = Request.Form["DictionaryGraduationType"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationType"].ParseStrTo(); //在校状态 var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo(); //毕业结论 var graduationResult = Request.Form["DictionaryGraduationResult"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryGraduationResult"].ParseStrTo(); //审核状态 var approvalStatus = Request.Form["DictionaryApprovalStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryApprovalStatus"].ParseStrTo(); var minorGraduationApplyIDString = Request.Form["SelectedID"]; var minorGraduationApplyIDList = minorGraduationApplyIDString.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => (Guid?)new Guid(x)).ToList(); var dt = minorGraduationApplyServices.GetMinorGraduationApproveViewList(configuretView, gradSchoolyearID, collegeID, yearID, standardID, graduationTypeID, inSchoolStatus, graduationResult, approvalStatus, minorGraduationApplyIDList) .Select(x => new { x.GraduatingSemesterCode, x.StudentNo, x.UserName, x.SexName, x.GraduationTypeName, x.ClassminorName, x.InSchoolStatusName, x.CollegeName, x.MinorGraduationResultName, x.ApprovalResult, x.Remark, x.ApprovalStatusName }).ToTable(); string[] liststring = { "毕业学期", "学号", "姓名", "性别", "毕业类型", "辅修班级", "在校状态", "院系所", "毕业结论", "预审说明", "备注", "审核状态" }; neh.Export(dt, liststring, "辅修毕业审核信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } /// /// 审核(单个页面) /// /// /// [HttpGet] public ActionResult Approve(Guid? minorGraduationApplyID) { //查询对应的毕业审核信息 var minorGraduationApproveView = minorGraduationApplyServices.GetMinorGraduationApproveView(minorGraduationApplyID); if (minorGraduationApproveView == null) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "操作失败,原因:数据有误。", url = Url.Action("List").AddMenuParameter() }); } //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识) var endStatusList = minorGraduationApplyServices.GetBackpointStatus(); var correctEndStatusID = minorGraduationApplyServices.GetCorrectEndStatus(); endStatusList.Add(correctEndStatusID); foreach (var endStatus in endStatusList) { if (minorGraduationApproveView.ApprovalStatus == endStatus) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "无法对已结束的流程进行审核。", url = Url.Action("List").AddMenuParameter() }); } } var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView) var actionViewList = minorGraduationApplyServices.GetActionView((Guid)minorGraduationApplyID, user.UserID); if (actionViewList == null || actionViewList.Count() <= 0) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "对不起,您没权限操作。", url = Url.Action("List").AddMenuParameter() }); } var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList(); ViewBag.ListAction = dropList; return View(minorGraduationApproveView); } /// /// 审核(单个页面) /// /// /// [HttpPost] public ActionResult Approve(MinorGraduationApplyView minorGraduationApplyView) { try { List list = new List(); list.Add(minorGraduationApplyView.MinorGraduationApplyID); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; string action = Request.Form["ddlAction"]; if (string.IsNullOrEmpty(action)) { throw new Exception("请选择处理动作"); } var actionID = action.JsonToObject().ActionID; minorGraduationApplyServices.MinorGraduationApproveConfirm(list, user.UserID, actionID, minorGraduationApplyView.Comment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "审核失败,原因:" + ex.Message + "。" }); } } /// /// 查询对应的流程环节动作List(ActionView) /// /// /// [HttpPost] public ActionResult ApprovalHandle(Guid? minorGraduationApplyID) { var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; //根据当前环节ID、用户ID查询下一步审批动作信息List(ActionView) var actionViewList = minorGraduationApplyServices.GetActionView((Guid)minorGraduationApplyID, user.UserID); var dropList = actionViewList.Select(x => new DropdownListItem { Text = x.ActionName, Value = x.ToJson() }).ToList(); return View(dropList); } /// /// 审批确定(批量) /// /// /// /// /// [HttpPost] public ActionResult ApproveConfirm(string minorGraduationApplyIDs, Guid actionID, string comment) { try { List list = minorGraduationApplyIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; minorGraduationApplyServices.MinorGraduationApproveConfirm(list, user.UserID, actionID, comment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "审核失败,原因:" + ex.Message }); } } } }