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 Bowin.Common.Mapping; using Bowin.Common.JSON; using EMIS.CommonLogic.ChargeManage.ChargeSituation; using EMIS.ViewModel.ChargeManage.ChargeSituation; using EMIS.CommonLogic.CalendarManage; using Bowin.Common.Utility; using Bowin.Common.Data; using EMIS.ViewModel.WorkflowManage; using EMIS.Utility; namespace EMIS.Web.Controllers.ChargeManage.ChargeSituation { [Authorization] public class ChargeDelayController : Controller { public IChargeDelayServices ChargeDelayServices { get; set; } /// /// 缓交名单页面 /// /// [HttpGet] public ActionResult List() { return View(); } /// /// 缓交名单列表查询 /// /// /// [HttpPost] public ActionResult List(QueryParamsModel pararms) { ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms); 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 educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation"); var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform"); var learnSystem = pararms.getExtraString("DictionaryLearnSystem"); var chargeYearID = pararms.getExtraInt("ChargeYearDropDown") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("ChargeYearDropDown"); var chargeProjectID = pararms.getExtraGuid("ChargeProjectComboGrid"); //在校状态 var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus"); //审批状态 var chargeDelayStatus = pararms.getExtraInt("DictionaryChargeDelayStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryChargeDelayStatus"); return base.Json(ChargeDelayServices.GetChargeDelayList(configuretView, collegeID, yearID, standardID, educationID, learningformID, learnSystem, chargeYearID, chargeProjectID, inSchoolStatus, chargeDelayStatus, (int)pararms.page, (int)pararms.rows)); } /// /// 查询应收名单中对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额) /// /// /// /// /// [HttpPost] public ActionResult ChargeDelayStandard(Guid? userID, int? chargeYearID, Guid? chargeProjectID) { try { var result = ChargeDelayServices.GetChargeDelayStandardView(userID, chargeYearID, chargeProjectID); return Json(new ReturnMessage() { IsSuccess = true, Data = result }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = ex.Message + "。" }); } } /// /// 编辑(申请、修改) /// /// /// [HttpGet] public ActionResult Edit(Guid? chargeDelayID) { ChargeDelayView chargeDelayView = new ChargeDelayView(); if (chargeDelayID.HasValue && chargeDelayID != Guid.Empty) { chargeDelayView = ChargeDelayServices.GetChargeDelayEditView(chargeDelayID); } else { chargeDelayView.ChargeYear = BaseExtensions.GetCurrentYearID(); } return View(chargeDelayView); } /// /// 编辑(申请、修改) /// /// /// [HttpPost] public ActionResult Edit(ChargeDelayView chargeDelayView) { try { ChargeDelayServices.ChaegeDelayEdit(chargeDelayView); return Json(new ReturnMessage() { IsSuccess = true, Message = "保存成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "保存失败,原因:" + ex.Message + "。" }); } } /// /// 删除 /// /// /// [HttpPost] public ActionResult Delete(string chargeDelayIDs) { try { List list = new List(); for (int i = 0; i < chargeDelayIDs.Split(',').Length; i++) { string id = chargeDelayIDs.Split(',')[i]; if (!string.IsNullOrEmpty(id)) { Guid chargeDelayID = new Guid(id); list.Add(chargeDelayID); } } ChargeDelayServices.ChargeDelayDelete(list); return base.Json("删除成功。"); } catch (Exception ex) { return base.Json("删除失败,原因:" + ex.Message + "。"); } } /// /// 提交 /// /// /// [HttpPost] public ActionResult Submit(string chargeDelayIDs) { try { List list = chargeDelayIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)).Select(x => new Guid(x)).ToList(); var user = HttpContext.User as EMIS.Utility.FormValidate.CustomPrincipal; string result = ChargeDelayServices.SubmitChargeDelay(list, user.UserID, ""); return Json(new ReturnMessage() { IsSuccess = true, Message = "提交成功" + result + "。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "提交失败,原因:" + ex.Message + "。" }); } } /// /// 审核页面(单个) /// /// /// [HttpGet] public ActionResult Approve(Guid? chargeDelayID) { //查询对应的缓交信息View var chargeDelayView = ChargeDelayServices.GetChargeDelayEditView(chargeDelayID); if (chargeDelayView == null) { return RedirectToAction("MsgShow", "Common", new { WindowID = Request["WindowID"], msg = "操作失败,原因:数据有误。", url = Url.Action("List").AddMenuParameter() }); } //对已结束的流程状态进行判断(包括正常结束、非正常结束[BP]标识) var endStatusList = ChargeDelayServices.GetBackpointStatus(); var correctEndStatusID = ChargeDelayServices.GetCorrectEndStatus(); endStatusList.Add(correctEndStatusID); foreach (var endStatus in endStatusList) { if (chargeDelayView.RecordStatus == 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 = ChargeDelayServices.GetActionView((Guid)chargeDelayID, 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; var newChargeDelayView = new ChargeDelayView(); chargeDelayView.DynamicCloneTo(newChargeDelayView); return View(newChargeDelayView); } /// /// 审核页面(单个) /// /// /// [HttpPost] public ActionResult Approve(ChargeDelayView chargeDelayView) { try { List list = new List(); list.Add(chargeDelayView.ChargeDelayID); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; string action = Request.Form["ddlAction"]; if (string.IsNullOrEmpty(action)) { throw new Exception("请选择处理动作"); } var actionID = action.JsonToObject().ActionID; ChargeDelayServices.ApproveChargeDelay(list, user.UserID, actionID, chargeDelayView.Comment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "审核失败,原因:" + ex.Message + "。" }); } } /// /// 审核确定(批量) /// /// /// /// /// [HttpPost] public ActionResult BatchApprove(string chargeDelayIDs, Guid actionID, string comment) { try { List list = chargeDelayIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); var user = EMIS.Utility.FormValidate.CustomPrincipal.Current; ChargeDelayServices.ApproveChargeDelay(list, user.UserID, actionID, comment); return Json(new ReturnMessage() { IsSuccess = true, Message = "审核成功。" }); } catch (Exception ex) { return Json(new ReturnMessage() { IsSuccess = false, Message = "审核失败,原因:" + ex.Message + "。" }); } } /// /// 导出Excel /// /// [HttpPost] public ActionResult Excel() { NpoiExcelHelper neh = new NpoiExcelHelper(); ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null); 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 educationID = Request.Form["DictionaryEducation"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo(); var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo(); var learnSystem = Request.Form["DictionaryLearnSystem"].ToString(); var chargeYearID = Request.Form["ChargeYearDropDown"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["ChargeYearDropDown"].ParseStrTo(); var chargeProjectID = Request.Form["ChargeProjectComboGrid"].ParseStrTo(); //在校状态 var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo(); //审批状态 var chargeDelayStatus = Request.Form["DictionaryChargeDelayStatus"].ParseStrTo() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryChargeDelayStatus"].ParseStrTo(); var dt = ChargeDelayServices.GetChargeDelayList(configuretView, collegeID, yearID, standardID, educationID, learningformID, learnSystem, chargeYearID, chargeProjectID, inSchoolStatus, chargeDelayStatus) .Select(x => new { x.StudentNo, x.UserName, x.SexName, x.ClassNo, x.ClassName, x.GradeMajorCode, x.GradeMajoyStr, x.CollegeCode, x.CollegeStr, x.ChargeYear, x.ChargeProjectStr, x.Amount, x.ChargeAmount, x.ActualAmount, x.ChargeTagName, x.PaidAmount, x.DelayAmount, x.GradeStr, x.StandardID, x.StandardCode, x.MajorStr, x.EducationName, x.LearningformName, x.LearnSystem, x.InSchoolStatusName, x.StudentStatusName, x.Reason, x.RecordStatusName }).ToTable(); string[] liststring = { "学号", "姓名", "性别", "班级编号", "班级名称", "年级专业编号", "年级专业名称", RSL.Get("CollegeCode"), RSL.Get("CollegeName"), "缴费学年", "收费项目", "应收金额", "调整金额", "实收金额", "缴费标记", "已缴金额", "缓交金额", "年级", "专业ID(Value)", "专业代码", "专业名称", RSL.Get("EducationID"), "学习形式", "学制", "在校状态", "学籍状态", "缓交原因", "状态" }; neh.Export(dt, liststring, "缓交名单信息" + DateTime.Now.ToString("yyyyMMdd")); return Json(new ReturnMessage() { IsSuccess = true, Message = "导出成功。" }); } } }