123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using System.Dynamic;
- using System.Data;
- using Bowin.Common.Mvc;
- using Bowin.Common.Utility;
- using Bowin.Common.Data;
- using Bowin.Web.Controls.Mvc;
- using EMIS.Utility;
- using EMIS.Web.Controls;
- using EMIS.ViewModel;
- using EMIS.ViewModel.StudentManage.StudentChange;
- using EMIS.CommonLogic.StudentManage.StudentChange;
- namespace EMIS.Web.Controllers.StudentManage.StudentChange
- {
- [Authorization]
- public class ChangeTotalController : JsonNetController
- {
- public Lazy<IChangeTotalServices> ChangeTotalServices { get; set; }
- /// <summary>
- /// 异动统计页面
- /// </summary>
- /// <returns></returns>
- public ActionResult List()
- {
- var changeTypeDisPlayList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ChangeType).Where(x => x.RecordStatus >= 1).ToList();
- ViewBag.ChangeTypeList = changeTypeDisPlayList;
- return View();
- }
- /// <summary>
- /// 异动统计列表查询
- /// </summary>
- /// <param name="pararms"></param>
- /// <returns></returns>
- [HttpPost]
- public ActionResult List(QueryParamsModel pararms)
- {
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
- var schoolyearID = pararms.getExtraGuid("SchoolyearDropdown");
- var campusID = pararms.getExtraGuid("CampusDropdown");
- var collegeID = pararms.getExtraGuid("CollegeDropdown");
- var changeTotalViewList = ChangeTotalServices.Value.GetChangeTotalViewList(configuretView, schoolyearID, campusID, collegeID);
- var camColList = changeTotalViewList.Select(x => new
- {
- x.CampusID,
- x.CampusCode,
- x.CampusName,
- x.CollegeID,
- x.CollegeNo,
- x.CollegeName
- }).OrderBy(x => x.CollegeNo).Distinct().ToList();
- var changeTypeDisPlayList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ChangeType).Where(x => x.RecordStatus >= 1).ToList();
- var dblist = new List<ExpandoObject>();
- foreach (var camCol in camColList)
- {
- dynamic item = new ExpandoObject();
- ((IDictionary<string, object>)item).Add("CampusID", camCol.CampusID);
- ((IDictionary<string, object>)item).Add("CampusCode", camCol.CampusCode);
- ((IDictionary<string, object>)item).Add("CampusName", camCol.CampusName);
- ((IDictionary<string, object>)item).Add("CollegeID", camCol.CollegeID);
- ((IDictionary<string, object>)item).Add("CollegeNo", camCol.CollegeNo);
- ((IDictionary<string, object>)item).Add("CollegeName", camCol.CollegeName);
- var changeTypeTotal = 0;
- foreach (var changeTypeDisPlay in changeTypeDisPlayList)
- {
- var changeTotalView = changeTotalViewList.Where(x => x.CollegeID == camCol.CollegeID && x.ChangeTypeID == changeTypeDisPlay.Value).SingleOrDefault();
- changeTypeTotal += (changeTotalView == null ? 0 : changeTotalView.ChangeTypeCount.Value);
- ((IDictionary<string, object>)item).Add("ChangeType_" + changeTypeDisPlay.Value, (changeTotalView == null ? 0 : changeTotalView.ChangeTypeCount).ToString());
- }
- ((IDictionary<string, object>)item).Add("ChangeTypeTotal", changeTypeTotal.ToString());
- dblist.Add(item);
- }
- return Json(new { total = dblist.Count, rows = dblist });
- }
- /// <summary>
- /// Excel导出
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- public ActionResult Excel()
- {
- NpoiExcelHelper neh = new NpoiExcelHelper();
- ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
- var schoolyearID = Request.Form["SchoolyearDropdown"] == DropdownList.SELECT_ALL.ToString() ? null : Request.Form["SchoolyearDropdown"].ParseStrTo<Guid>();
- var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
- var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
- var changeTotalViewList = ChangeTotalServices.Value.GetChangeTotalViewList(configuretView, schoolyearID, campusID, collegeID);
- var camColList = changeTotalViewList.Select(x => new
- {
- x.CampusID,
- x.CampusCode,
- x.CampusName,
- x.CollegeID,
- x.CollegeNo,
- x.CollegeName
- }).OrderBy(x => x.CollegeNo).Distinct().ToList();
- var changeTypeDisPlayList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ChangeType).Where(x => x.RecordStatus >= 1).ToList();
- var dt = new DataTable();
- dt.Columns.Add("CampusCode", typeof(string));
- dt.Columns.Add("CampusName", typeof(string));
- dt.Columns.Add("CollegeNo", typeof(string));
- dt.Columns.Add("CollegeName", typeof(string));
- foreach (var changeTypeDisPlay in changeTypeDisPlayList)
- {
- dt.Columns.Add("Change_" + changeTypeDisPlay.Value, typeof(string));
- }
- dt.Columns.Add("ChangeTypeTotal", typeof(string));
- foreach (var camCol in camColList)
- {
- DataRow dr = dt.NewRow();
- dr["CampusCode"] = camCol.CampusCode;
- dr["CampusName"] = camCol.CampusName;
- dr["CollegeNo"] = camCol.CollegeNo;
- dr["CollegeName"] = camCol.CollegeName;
- var changeTypeTotal = 0;
- foreach (var changeTypeDisPlay in changeTypeDisPlayList)
- {
- var changeTotalView = changeTotalViewList.Where(x => x.CollegeID == camCol.CollegeID && x.ChangeTypeID == changeTypeDisPlay.Value).SingleOrDefault();
- changeTypeTotal += (changeTotalView == null ? 0 : changeTotalView.ChangeTypeCount.Value);
- dr["Change_" + changeTypeDisPlay.Value] = (changeTotalView == null ? 0 : changeTotalView.ChangeTypeCount).ToString();
- }
- dr["ChangeTypeTotal"] = changeTypeTotal.ToString();
- dt.Rows.Add(dr);
- }
- var liststring = new List<string> { RSL.Get("CampusCode"), RSL.Get("Campus"), RSL.Get("CollegeCode"), RSL.Get("College") };
- foreach (var changeTypeDisPlay in changeTypeDisPlayList)
- {
- liststring.Add(changeTypeDisPlay.Name);
- }
- liststring.Add("总数");
- neh.Export(dt, liststring.ToArray(), "异动统计信息" + DateTime.Now.ToString("yyyyMMdd"));
- return Json(new ReturnMessage()
- {
- IsSuccess = true,
- Message = "导出成功。"
- });
- }
- }
- }
|