123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using EMIS.CommonLogic.Students;
- using EMIS.ViewModel;
- using EMIS.Web.Controls;
- using EMIS.Utility;
- using System.Dynamic;
- using EMIS.ViewModel.DifferentDynamic;
- using Bowin.Common.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Linq;
- using EMIS.Entities;
- namespace EMIS.Web.Controllers.DifferentDynamic
- {
- /// <summary>
- /// 异动统计
- /// </summary>
- [Authorization]
- public class DifferentDynamicStatisticsController : JsonNetController
- {
- public IDifferentDynamicServices DifferentDynamicServices { get; set; }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- var differentDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ChangeType);
- ViewBag.DifferentDynamicTypes = differentDynamicTypes;
- return View();
- }
- /// <summary>
- /// 列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- var configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var campusID = pararms.getExtraGuid("CampusDropdown"); //校区
- var collegeID = pararms.getExtraGuid("CollegeDropdown"); //院系所
- var schoolYearID = pararms.getExtraGuid("SchoolYearDropdown"); //异动学期
- var result = DifferentDynamicServices.GetDifferentDynamicStatistics(configuretView, campusID, collegeID, schoolYearID);
- var differentDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ChangeType);
- var list = WrapResult(result, differentDynamicTypes);
- return Json(new { total = list.Count, rows = list });
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="result"></param>
- /// <param name="differentDynamicTypes"></param>
- /// <returns></returns>
- private List<ExpandoObject> WrapResult(ICollection<DifferentDynamicStatisticsView> result, IEnumerable<Sys_DictionaryItem> differentDynamicTypes)
- {
- var list = new List<ExpandoObject>();
- if (result == null || result.Count == 0)
- {
- return list;
- }
- var colleges = result.Select(s => new { s.CollegeID, s.CollegeName }).OrderBy(o => o.CollegeName).Distinct().ToList();
- foreach (var college in colleges)
- {
- dynamic item = new ExpandoObject();
- item.CollegeName = college.CollegeName;
- DifferentDynamicStatisticsView covarianceItem = null;
- foreach (var differentDynamicType in differentDynamicTypes)
- {
- covarianceItem = result.FirstOrDefault(w => w.CollegeID == college.CollegeID && w.DifferentDynamicType == differentDynamicType.Value);
- var quantity = covarianceItem == null ? 0 : covarianceItem.Quantity;
- ((IDictionary<string, object>)item).Add("Item" + differentDynamicType.Value, quantity.ToString());
- }
- list.Add(item);
- }
- return list;
- }
- /// <summary>
- ///
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
-
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>(); //校区
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>(); //院系所
- var schoolYearID = Request.Form["SchoolYearDropdown"].ParseStrTo<Guid>(); //异动学期
- var result = DifferentDynamicServices.GetDifferentDynamicStatistics(configuretView, campusID, collegeID, schoolYearID);
- var differentDynamicTypes = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ChangeType);
- var dt = WrapResult(result, differentDynamicTypes).ToTable();
- var columns = new List<string> { RSL.Get("College") };
- foreach (var item in differentDynamicTypes)
- {
- columns.Add(item.Name);
- }
- neh.Export(dt, columns.ToArray(), "异动统计");
- return RedirectToAction("MsgShow", "Common", new
- {
- msg = "导出成功!",
- url = Url.Action("List").AddMenuParameter()
- });
- }
- }
- }
|