using Learun.Application.Base.SystemModule; using Learun.Application.TwoDevelopment.EducationalAdministration; using Learun.Application.TwoDevelopment.LogisticsManagement; using Learun.Application.TwoDevelopment.ReceiveSendFeeManagement; using Learun.Util; using Newtonsoft.Json; using NPOI.HSSF.UserModel; using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; using System; using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; using System.Text; using System.Web; using System.Web.Mvc; namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers { /// /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园 /// Copyright (c) 2013-2018 北京泉江科技有限公司 /// 创 建:超级管理员 /// 日 期:2019-08-08 17:21 /// 描 述:新生信息管理 /// public class StuInfoFreshController : MvcControllerBase { private StuInfoFreshIBLL stuInfoFreshIBLL = new StuInfoFreshBLL(); private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL(); private FinaChargesStandardIBLL finaChargesStandardIBLL = new FinaChargesStandardBLL(); private AccommodationIBLL accommodationIBLL = new AccommodationBLL(); private CdMajorIBLL cdMajorIBLL = new CdMajorBLL(); private CdDeptIBLL cdDeptIBLL = new CdDeptBLL(); #region 视图功能 /// /// 主页面 /// /// [HttpGet] public ActionResult Index() { return View(); } [HttpGet] public ActionResult IndexDC() { return View(); } [HttpGet] public ActionResult SchoolUniform() { return View(); } [HttpGet] public ActionResult StatusView() { return View(); } [HttpGet] public ActionResult PrintSignFlow(string Id) { if (!string.IsNullOrEmpty(Id)) { var vwinfo = stuInfoFreshIBLL.GetStuInfoFreshEntity(Id); vwinfo.MajorName = cdMajorIBLL.GetCdMajorEntityByMajorNo(vwinfo.MajorNo).MajorName; return View(vwinfo); } else { return View(); } } /// /// 根据区域统计 /// /// [HttpGet] public ActionResult StatisticsArea() { return View(); } /// /// 表单页 /// /// [HttpGet] public ActionResult Form() { var url = Config.GetValue("defaultheadimg"); ViewBag.Url = url; return View(); } [HttpGet] public ActionResult FormDC() { var url = Config.GetValue("defaultheadimg"); ViewBag.Url = url; return View(); } /// /// 表单查看页 /// /// [HttpGet] public ActionResult FormView() { var url = Config.GetValue("defaultheadimg"); ViewBag.Url = url; return View(); } /// /// 表单【学子在线】 /// /// [HttpGet] public ActionResult FormOfStudent() { var url = Config.GetValue("defaultheadimg"); ViewBag.Url = url; return View(); } /// /// 新生报到管理页面 /// /// [HttpGet] public ActionResult RegisterIndex() { return View(); } /// /// 新生档案管理页面 /// /// [HttpGet] public ActionResult CollectFileIndex() { return View(); } /// /// 新生领取用品页面 /// /// [HttpGet] public ActionResult GetKeyIndex() { return View(); } /// /// 新生缴费管理页面 /// /// [HttpGet] public ActionResult PayFeeIndex() { return View(); } /// /// 新生缴费管理表单页 /// /// [HttpGet] public ActionResult PayFeeForm() { return View(); } /// /// 助学贷款表单页 /// /// [HttpGet] public ActionResult LoanForm() { return View(); } /// /// 现场缴费表单页 /// /// [HttpGet] public ActionResult OnsitePayForm() { return View(); } /// /// 主页面【学子在线-新生信息完善】 /// /// [HttpGet] public ActionResult IndexOfStudent() { return View(); } /// /// 分配班级 /// /// [HttpGet] public ActionResult AllocationClass() { return View(); } [HttpGet] public ActionResult AllocationClassDC() { return View(); } /// /// 分配宿舍 /// /// [HttpGet] public ActionResult AllocationDormitory() { return View(); } /// /// 分配床位 /// /// [HttpGet] public ActionResult AllocationBed() { return View(); } /// /// 导入床位页 /// /// [HttpGet] public ActionResult ImportBedForm() { return View(); } /// /// 导出学生宿页舍 /// /// [HttpGet] public ActionResult ExportBedForm() { return View(); } /// /// 新生信息统计 /// /// [HttpGet] public ActionResult StatisticIndex() { var academic = Common.GetSemesterAndYear(); ViewBag.Grade = academic.AcademicYearShort.Substring(0, 2); return View(); } /// /// 新生信息班级统计 /// /// [HttpGet] public ActionResult StatisticClassIndex() { var academic = Common.GetSemesterAndYear(); ViewBag.Grade = academic.AcademicYearShort.Substring(0, 2); return View(); } #endregion #region 获取数据 /// /// 获取列表数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetList(string queryJson) { var data = stuInfoFreshIBLL.GetList(queryJson); return Success(data); } /// /// 获取列表分页数据 /// 分页参数 /// /// [HttpGet] [AjaxOnly] public ActionResult GetPageList(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = stuInfoFreshIBLL.GetPageList(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取表单数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetFormData(string keyValue) { var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue); StuInfoFreshData.Files = StuInfoFreshData.ID; //获取头像地址 var url = Config.GetValue("defaultheadimg"); if (StuInfoFreshData.IsPhoto == true && !string.IsNullOrEmpty(StuInfoFreshData.Photo)) { var annexesFileEntity = annexesFileIBLL.GetEntity(StuInfoFreshData.Photo); if (annexesFileEntity != null) { url = "/" + annexesFileEntity.F_FilePath.Substring(annexesFileEntity.F_FilePath.IndexOf("Resource")); } } var StuInfoFreshEmergePeopleData = stuInfoFreshIBLL.GetStuInfoFreshEmergePeopleList(StuInfoFreshData.ID); var StuInfoFreshFamilyData = stuInfoFreshIBLL.GetStuInfoFreshFamilyList(StuInfoFreshData.ID); var jsonData = new { StuInfoFresh = StuInfoFreshData, StuInfoFreshEmergePeople = StuInfoFreshEmergePeopleData, StuInfoFreshFamily = StuInfoFreshFamilyData, Url = url }; return Success(jsonData); } /// /// 获取分配宿舍列表 /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetDormitorys(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = stuInfoFreshIBLL.GetDormitorys(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取分配宿舍列表 /// /// /// /// [HttpGet] [AjaxOnly] public ActionResult GetDormitorys2(string pagination, string queryJson) { Pagination paginationobj = pagination.ToObject(); var data = stuInfoFreshIBLL.GetDormitorys2(paginationobj, queryJson); var jsonData = new { rows = data, total = paginationobj.total, page = paginationobj.page, records = paginationobj.records }; return Success(jsonData); } /// /// 获取分配宿舍左侧树形数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetDormitoryTree() { var data = stuInfoFreshIBLL.GetTree().OrderBy(x => x.value); return Success(data); } /// /// 获取分配床位左侧树形数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetBedTree(string classNo, string gender) { var data = stuInfoFreshIBLL.GetBedTree(classNo, gender).OrderBy(x => x.text); return Success(data); } #endregion #region 提交数据 /// /// 删除实体数据 /// 主键 /// /// [HttpPost] [AjaxOnly] public ActionResult DeleteForm(string keyValue) { stuInfoFreshIBLL.DeleteEntity(keyValue); return Success("删除成功!"); } /// /// 保存实体数据(新增、修改) /// 主键 /// /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveForm(string keyValue, string strEntity, string strstuInfoFreshEmergePeopleList, string strstuInfoFreshFamilyList) { StuInfoFreshEntity entity = strEntity.ToObject(); if (!string.IsNullOrEmpty(entity.Photo)) { entity.IsPhoto = true; } else { entity.IsPhoto = false; } List stuInfoFreshEmergePeopleList = strstuInfoFreshEmergePeopleList.ToObject>(); List stuInfoFreshFamilyList = strstuInfoFreshFamilyList.ToObject>(); var kshList = stuInfoFreshIBLL.Getksh(entity.ksh); if (string.IsNullOrEmpty(keyValue)) { if (kshList != null) { return Fail("保存失败,考生号不可重复"); } } else { if (kshList != null && kshList.ID != keyValue) { return Fail("保存失败,考生号不可重复"); } } stuInfoFreshIBLL.SaveEntity(keyValue, entity, stuInfoFreshEmergePeopleList, stuInfoFreshFamilyList); return Success("保存成功!"); } /// /// 保存实体数据(新增、修改) /// 主键 /// /// [HttpPost] [ValidateAntiForgeryToken] [AjaxOnly] public ActionResult SaveLoanForm(string keyValue, string strEntity) { StuInfoFreshEntity entity = strEntity.ToObject(); stuInfoFreshIBLL.SaveEntity(keyValue, entity); return Success("保存成功!"); } #endregion #region 扩展数据 /// /// 拍照 /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult DoPhoto(string base64url) { var loginuser = LoginUserInfo.Get(); //头像处理 var folderId = Guid.NewGuid().ToString(); string filePath = Config.GetValue("AnnexesFile"); string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string FileEextension = ".png"; string fileGuid = Guid.NewGuid().ToString(); string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, loginuser.account, uploadDate, fileGuid, FileEextension); //创建文件夹 string path = Path.GetDirectoryName(virtualPath); Directory.CreateDirectory(path); AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); if (!System.IO.File.Exists(virtualPath)) { byte[] bytes = Convert.FromBase64String(base64url.Replace("data:image/png;base64,", "")); FileInfo file = new FileInfo(virtualPath); FileStream fs = file.Create(); fs.Write(bytes, 0, bytes.Length); fs.Close(); //文件信息写入数据库 fileAnnexesEntity.F_Id = fileGuid; fileAnnexesEntity.F_FileName = "userphoto.png"; fileAnnexesEntity.F_FilePath = virtualPath; fileAnnexesEntity.F_FileSize = bytes.Length.ToString(); fileAnnexesEntity.F_FileExtensions = FileEextension; fileAnnexesEntity.F_FileType = FileEextension.Replace(".", ""); fileAnnexesEntity.F_CreateUserId = loginuser.userId; fileAnnexesEntity.F_CreateUserName = loginuser.realName; annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); } var data = new { Url = virtualPath, AnnexesFileId = fileGuid }; return Success(data); } /// ///确认报到、取消报到 /// /// [HttpPost] [AjaxOnly] public ActionResult IsRegister(string keyValue, string status) { stuInfoFreshIBLL.IsRegister(keyValue, status); return Success("操作成功"); } /// ///收取学生档案 /// /// [HttpPost] [AjaxOnly] public ActionResult IsCollectFile(string keyValue, string status) { stuInfoFreshIBLL.IsCollectFile(keyValue, status); return Success("操作成功"); } /// ///领取钥匙 /// /// [HttpPost] [AjaxOnly] public ActionResult IsGetKey(string keyValue, string status) { stuInfoFreshIBLL.IsGetKey(keyValue, status); return Success("操作成功"); } /// ///领取校园卡 /// /// [HttpPost] [AjaxOnly] public ActionResult IsGetCard(string keyValue, string status) { stuInfoFreshIBLL.IsGetCard(keyValue, status); return Success("操作成功"); } /// ///缴费 /// /// [HttpPost] [AjaxOnly] public ActionResult IsPayFee(string keyValue, string status) { stuInfoFreshIBLL.IsPayFee(keyValue, status); return Success("操作成功"); } /// ///其他费用缴费 /// /// [HttpPost] [AjaxOnly] public ActionResult IsOtherPayFee(string keyValue, string status) { stuInfoFreshIBLL.IsOtherPayFee(keyValue, status); return Success("操作成功"); } /// ///审核助学贷款 /// /// [HttpPost] [AjaxOnly] public ActionResult DoCheckLoan(string keyValue, string status) { stuInfoFreshIBLL.DoCheckLoan(keyValue, status); return Success("操作成功"); } /// /// 获取新生缴费明细 /// /// [HttpGet] [AjaxOnly] public ActionResult GetPayFeeDetail(string keyValue) { var StuInfoFreshData = stuInfoFreshIBLL.GetStuInfoFreshEntity(keyValue); var FinaChargesStandardList = new List(); if (!string.IsNullOrEmpty(StuInfoFreshData.ClassNo) && !string.IsNullOrEmpty(StuInfoFreshData.MajorNo)) { var ClassInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(StuInfoFreshData.ClassNo); if (ClassInfoEntity != null) { var academicAndYear = Common.GetSemesterAndYear(); FinaChargesStandardList = finaChargesStandardIBLL.GetFinaChargesStandardListByMajorNoOfNotAll(StuInfoFreshData.MajorNo, academicAndYear.AcademicYearShort, academicAndYear.Semester, ClassInfoEntity.Grade).ToList(); } } var PayFeeTotal = FinaChargesStandardList.Select(x => x.Standard).Sum(); var jsonData = new { FinaChargesStandardList = FinaChargesStandardList, PayFeeTotal = PayFeeTotal }; return Success(jsonData); } /// /// 分配班级 /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult DoAllocationClass(string classNo, string dataJson) { var StuInfoFreshList = JsonConvert.DeserializeObject>(dataJson); var ClassInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(classNo); if (ClassInfoEntity == null) { return Fail("分配的班级不存在!"); } //获取当前班级已有人数 var hasList = stuInfoFreshIBLL.GetStuInfoFreshListByClassNo(classNo); var hasLength = hasList.Count(); var tempLength = hasLength; if (StuInfoFreshList.Any()) { foreach (var item in StuInfoFreshList) { tempLength++; item.ClassNo = classNo; item.DeptNo = ClassInfoEntity.DeptNo; item.MajorNo = ClassInfoEntity.MajorNo; item.Grade = ClassInfoEntity.Grade; item.StuNo = string.Format("{0}{1}", classNo, tempLength < 10 ? "0" + tempLength : tempLength.ToString()); } } stuInfoFreshIBLL.DoAllocationClass(StuInfoFreshList); return Success("分配成功!"); } /// /// 分配宿舍 /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult DoAllocationDormitory(string classNo, string dataJson) { var acc_DormitoryBuildEntities = JsonConvert.DeserializeObject>(dataJson); foreach (var entity in acc_DormitoryBuildEntities) { //预分床位数量是否合理 if (entity.PlanBedNum < 1) { return Fail("预分床位数量至少为1位!"); } if (entity.PlanBedNum > entity.RemainBedNum) { return Fail("预分床位数量不能超出可分配床位数量!"); } entity.PlanClassNo = classNo; } stuInfoFreshIBLL.DoAllocationDormitory(acc_DormitoryBuildEntities); return Success("分配成功!"); } /// /// 取消分配宿舍 /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult CancelAllocationDormitory(string classNo, string dataJson) { var acc_DormitoryBuildEntities = JsonConvert.DeserializeObject>(dataJson); foreach (var entity in acc_DormitoryBuildEntities) { //取消已分配床位数量是否合理 if (entity.CancelUseBedNum < 1) { return Fail("取消已分配床位数量至少为1位!"); } if (entity.CancelUseBedNum > entity.UseBedNum) { return Fail("取消已分配床位数量不能超出已分配床位数量!"); } entity.PlanClassNo = classNo; } stuInfoFreshIBLL.CancelAllocationDormitory(acc_DormitoryBuildEntities); return Success("取消分配成功!"); } /// /// 分配床位 /// /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult DoAllocationBed(string dormitoryNo, string keyValue) { stuInfoFreshIBLL.DoAllocationBed(dormitoryNo, keyValue); return Success("分配成功!"); } /// /// 自动分配床位 /// /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult DoAllocationBedOfAuto(string classNo) { stuInfoFreshIBLL.DoAllocationBedOfAuto(classNo); return Success("分配成功!"); } [HttpGet] [AjaxOnly] public ActionResult ConfirmDormitory() { stuInfoFreshIBLL.ConfirmDormitory(); return Success("操作成功!"); } [HttpGet] [AjaxOnly] public ActionResult ConfirmDormitoryTwo() { stuInfoFreshIBLL.ConfirmDormitoryTwo(); return Success("操作成功!"); } [HttpPost] [AjaxOnly] public ActionResult GetUniform(string keyValue, bool Status) { stuInfoFreshIBLL.GetUniform(keyValue, Status); return Success("操作成功"); } [HttpPost] [AjaxOnly] public ActionResult PayUniform(string keyValue, bool Status) { stuInfoFreshIBLL.PayUniform(keyValue, Status); return Success("操作成功"); } /// /// 导入学籍信息 /// /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult ImportStuInfoBasic() { stuInfoFreshIBLL.ImportStuInfoBasic(); return Success("生成学籍信息成功!"); } /// /// 导入床位 /// /// public ActionResult ImportBed(HttpPostedFileBase filedata) { if (filedata == null || filedata.FileName == null || filedata.ContentLength == 0) { if (Request.Files.Count > 0) { filedata = Request.Files[0]; } } if (filedata == null) { return Fail("未获取到文件"); } var pathoffirst = Config.GetValue("AnnexesFile"); var pathofsecond = "/DormitoryBuildImportFile"; var pathofthird = DateTime.Now.ToString("yyyyMMdd"); var filename = filedata.FileName; var exten = Path.GetExtension(filename); var fileguid = Guid.NewGuid().ToString(); var pathoffull = string.Format("{0}/{1}/{2}/{3}{4}", pathoffirst, pathofsecond, pathofthird, fileguid, exten); var pathofdown = string.Format("{0}/{1}/{2}{3}", pathofsecond, pathofthird, fileguid, exten); var directory = Path.GetDirectoryName(pathoffull); if (!Directory.Exists(directory)) { Directory.CreateDirectory(directory); } //保存文件 filedata.SaveAs(pathoffull); //读取文件 var filePath = pathoffull; var strMsg = string.Empty; IWorkbook wk = null; string extension = System.IO.Path.GetExtension(filePath); try { FileStream fs = System.IO.File.OpenRead(filePath); if (extension.Equals(".xls")) { wk = new HSSFWorkbook(fs); } else { wk = new XSSFWorkbook(fs); } fs.Close(); //读取当前表数据 ISheet sheet = wk.GetSheetAt(0); IRow row = sheet.GetRow(0); int offset = 0; //导入床位成功数量 int bedSuccNum = 0; var stuinfofreshlist = stuInfoFreshIBLL.GetList("{}"); var accommodationList = accommodationIBLL.GetList(); for (int i = 1; i <= sheet.LastRowNum; i++) { row = sheet.GetRow(i); if (row != null) { //姓名0、学号1、班级2、宿舍楼3、单元4、楼层5、房间6、床位7 var stuInfoFreshEntity = stuinfofreshlist.FirstOrDefault(m => m.StuNo == row.GetCell(1).ToString()); if (stuInfoFreshEntity == null) { continue; } var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassName(row.GetCell(2).ToString()); if (classInfoEntity == null) { continue; } if (accommodationList.Any()) { var build = accommodationList.FirstOrDefault(x => x.BuildType == "1" && x.Name == row.GetCell(3).ToString()); if (build != null) { var unit = accommodationList.FirstOrDefault(x => x.BuildType == "2" && x.ParentID == build.ID && x.Name == row.GetCell(4).ToString()); if (unit != null) { var floor = accommodationList.FirstOrDefault(x => x.BuildType == "3" && x.ParentID == unit.ID && x.Name == row.GetCell(5).ToString()); if (floor != null) { var room = accommodationList.FirstOrDefault(x => x.BuildType == "4" && x.ParentID == floor.ID && x.Name == row.GetCell(6).ToString()); if (room != null) { var bed = accommodationList.FirstOrDefault(x => x.BuildType == "5" && x.ParentID == room.ID && x.Name == row.GetCell(7).ToString()); if (bed != null) { //分配床位 stuInfoFreshIBLL.DoAllocationBed(bed.ID, stuInfoFreshEntity.ID); bedSuccNum++; //分配宿舍 var alist = new List(); var accommodationEntity = new Acc_DormitoryBuildEntity(); accommodationEntity.ID = room.ID; accommodationEntity.PlanBedNum = 1; accommodationEntity.PlanClassNo = classInfoEntity.ClassNo; accommodationEntity.bedId = bed.ID; alist.Add(accommodationEntity); stuInfoFreshIBLL.ImportDormitory(alist); } } } } } } } } strMsg = "导入床位成功" + bedSuccNum + "个!"; } catch (Exception e) { return Fail("导入床位失败!" + strMsg); } return Success("导入床位成功!" + strMsg); } /// /// 导出学生宿舍信息 /// /// public FileResult ExportBed(string queryJson) { var fileHead = "学生宿舍信息"; var postData = JsonConvert.DeserializeObject(queryJson); if (!string.IsNullOrEmpty(postData.ClassNo)) { var classInfoEntity = classInfoIBLL.GetClassInfoEntityByClassNo(postData.ClassNo); fileHead = classInfoEntity?.ClassName + fileHead; } else if (!string.IsNullOrEmpty(postData.MajorNo)) { var majorEntity = cdMajorIBLL.GetCdMajorEntityByMajorNo(postData.MajorNo); fileHead = majorEntity?.MajorName + fileHead; } else if (!string.IsNullOrEmpty(postData.DeptNo)) { var deptEntity = cdDeptIBLL.GetCdDeptEntityByNo(postData.DeptNo); fileHead = deptEntity?.DeptName + fileHead; } FileStreamResult result = null; HSSFWorkbook book = new HSSFWorkbook(); ISheet sheet = book.CreateSheet("Sheet0"); for (int i = 0; i <= 9; i++) { sheet.SetColumnWidth(i, 256 * 15); } IRow headrow = sheet.CreateRow(0); headrow.CreateCell(0).SetCellValue(fileHead); sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(0, 0, 0, 9)); IRow cellrow = sheet.CreateRow(1); cellrow.CreateCell(0).SetCellValue("姓名"); cellrow.CreateCell(1).SetCellValue("学号"); cellrow.CreateCell(2).SetCellValue("系"); cellrow.CreateCell(3).SetCellValue("专业"); cellrow.CreateCell(4).SetCellValue("班级"); cellrow.CreateCell(5).SetCellValue("宿舍楼"); cellrow.CreateCell(6).SetCellValue("单元"); cellrow.CreateCell(7).SetCellValue("楼层"); cellrow.CreateCell(8).SetCellValue("房间"); cellrow.CreateCell(9).SetCellValue("床位"); //获取数据源 var data = stuInfoFreshIBLL.GetList(queryJson).ToList(); foreach (var item in data) { var i = data.IndexOf(item); IRow row = sheet.CreateRow(2 + i); row.CreateCell(0).SetCellValue(item.StuName); row.CreateCell(1).SetCellValue(item.StuNo); row.CreateCell(2).SetCellValue(item.DeptName); row.CreateCell(3).SetCellValue(item.MajorName); row.CreateCell(4).SetCellValue(item.ClassName); row.CreateCell(5).SetCellValue(item.Build); row.CreateCell(6).SetCellValue(item.Unit); row.CreateCell(7).SetCellValue(item.floor); row.CreateCell(8).SetCellValue(item.Room); row.CreateCell(9).SetCellValue(item.Bed); } var fileguid = Guid.NewGuid().ToString(); var path = Server.MapPath("~/Resource/DormitoryBuildExportFile/" + DateTime.Now.ToString("yyyyMMdd") + "/"); var pathoffull = path + fileguid + ".xls"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } FileStream fswrite = new FileStream(pathoffull, FileMode.OpenOrCreate, FileAccess.Write); book.Write(fswrite); fswrite.Close(); FileStream fsread = new FileStream(pathoffull, FileMode.OpenOrCreate, FileAccess.Read); result = File(fsread, "application/ms-excel", fileHead + ".xls"); return result; } /// /// 删除宿舍信息 /// /// /// /// /// [HttpPost] [AjaxOnly] public ActionResult DeleteBed(string keyValue) { stuInfoFreshIBLL.DeleteBed(keyValue); return Success("删除成功!"); } /// /// 年级下拉框信息【新生信息统计】 /// /// [HttpGet] [AjaxOnly] public ActionResult GetGradeData() { var data = WebHelper.GenerateNearByYear2(); return Success(data); } /// /// 获取列表数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetStatisticList(string queryJson) { var data = stuInfoFreshIBLL.GetList2(queryJson); var list = data.Where(x => !string.IsNullOrEmpty(x.MajorNo)).GroupBy(x => x.MajorNo).Select(x => new StatisticModel { MajorNo = x.Key, MajorName = x.FirstOrDefault()?.MajorName, Grade = x.FirstOrDefault()?.Grade, TotalNum = x.Count(), InfoNum = x.Count(y => y.IsStudentEdit == true), RegisterNum = x.Count(y => y.RegisterStatus == "1"), PayFeeNum = x.Count(y => y.PayFeeStatus == "1" || y.OnsitePayFeeStatus == "1"), GetKeyNum = x.Count(y => y.GetKeyStatus == "1"), GetCardNum = x.Count(y => y.GetCardStatus == "1"), CollectFileNum = x.Count(y => y.CollectFileStatus == "1"), LoanNum = x.Count(y => y.StudentLoanStatus == "1") }).OrderBy(x => x.MajorNo); //var aa = new StatisticModel //{ // MajorNo = "全校", // MajorName = "全校", // Grade = list.FirstOrDefault()?.Grade, // TotalNum = list.Select(x => x.TotalNum).Sum(), // InfoNum = list.Select(x => x.InfoNum).Sum(), // RegisterNum = list.Select(x => x.RegisterNum).Sum(), // PayFeeNum = list.Select(x => x.PayFeeNum).Sum(), // GetKeyNum = list.Select(x => x.GetKeyNum).Sum(), //}; //var allList = new List(); //allList.Add(aa); //allList.AddRange(list); return Success(list); } /// /// 获取列表数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetStatisticListOfClass(string queryJson) { var data = stuInfoFreshIBLL.GetList2(queryJson); var list = data.Where(x => !string.IsNullOrEmpty(x.ClassNo) && !string.IsNullOrEmpty(x.MajorNo)).GroupBy(x => new { x.MajorNo, x.ClassNo }).Select(x => new StatisticModel { ClassNo = x.Key.ClassNo, ClassName = x.FirstOrDefault()?.ClassName, Grade = x.FirstOrDefault()?.Grade, MajorNo = x.Key.MajorNo, MajorName = x.FirstOrDefault()?.MajorName, TotalNum = x.Count(), InfoNum = x.Count(y => y.IsStudentEdit == true), RegisterNum = x.Count(y => y.RegisterStatus == "1"), PayFeeNum = x.Count(y => y.PayFeeStatus == "1" || y.OnsitePayFeeStatus == "1"), GetKeyNum = x.Count(y => y.GetKeyStatus == "1"), GetCardNum = x.Count(y => y.GetCardStatus == "1"), CollectFileNum = x.Count(y => y.CollectFileStatus == "1"), LoanNum = x.Count(y => y.StudentLoanStatus == "1") }).OrderBy(x => x.MajorNo).ThenBy(x => x.ClassNo); return Success(list); } public class StatisticModel { public string MajorNo { get; set; } public string MajorName { get; set; } public string ClassNo { get; set; } public string ClassName { get; set; } public string Grade { get; set; } /// /// 总人数 /// public int TotalNum { get; set; } /// /// 完善个人信息人数 /// public int InfoNum { get; set; } /// /// 报到人数 /// public int RegisterNum { get; set; } /// /// 缴费人数 /// public int PayFeeNum { get; set; } /// /// 领钥匙人数 /// public int GetKeyNum { get; set; } /// /// 已领取校园卡人数 /// public int GetCardNum { get; set; } /// /// 已收取档案人数 /// public int CollectFileNum { get; set; } /// /// 贷款人数 /// public int LoanNum { get; set; } } /// /// 获取列表数据 /// /// [HttpGet] [AjaxOnly] public ActionResult GetStatisticArea(string queryJson) { var data = stuInfoFreshIBLL.GetList(queryJson); var list = data.GroupBy(x => x.ProvinceNo).Select(x => new { ProvinceNo = x.Key, TotalNum = x.Count(), RegisterNum = x.Count(y => y.RegisterStatus == "1"), BoyNum = x.Count(y => y.GenderNo == "1"), GirlNum = x.Count(y => y.GenderNo == "0"), }).OrderByDescending(a => a.TotalNum).ToList(); var item = new { ProvinceNo = "总计", TotalNum = data.Count(), RegisterNum = data.Count(y => y.RegisterStatus == "1"), BoyNum = data.Count(y => y.GenderNo == "1"), GirlNum = data.Count(y => y.GenderNo == "0"), }; var zhounei = data.Where(a => a.ProvinceNo.Contains("5121")); var item1 = new { ProvinceNo = "州内", TotalNum = zhounei.Count(), RegisterNum = zhounei.Count(y => y.RegisterStatus == "1"), BoyNum = zhounei.Count(y => y.GenderNo == "1"), GirlNum = zhounei.Count(y => y.GenderNo == "0"), }; var zhouwai = data.Where(a => !a.ProvinceNo.Contains("5121")); var item2 = new { ProvinceNo = "州外", TotalNum = zhouwai.Count(), RegisterNum = zhouwai.Count(y => y.RegisterStatus == "1"), BoyNum = zhouwai.Count(y => y.GenderNo == "1"), GirlNum = zhouwai.Count(y => y.GenderNo == "0"), }; list.Add(item); list.Add(item1); list.Add(item2); // var jsonData = new // { // rows = list, // total = list.Count(), // page = 1, // records = list.Count(); //}; return Success(list); } #endregion #region 上传图片 [HttpPost] [AjaxOnly] public ActionResult IsPhoto(string stuId, string base64url) { var loginuser = LoginUserInfo.Get(); //头像处理 var folderId = Guid.NewGuid().ToString(); string filePath = Config.GetValue("AnnexesFile"); string uploadDate = DateTime.Now.ToString("yyyyMMdd"); string FileEextension = ".png"; string fileGuid = Guid.NewGuid().ToString(); string virtualPath = string.Format("{0}/{1}/{2}/{3}{4}", filePath, loginuser.account, uploadDate, fileGuid, FileEextension); //创建文件夹 string path = Path.GetDirectoryName(virtualPath); Directory.CreateDirectory(path); AnnexesFileEntity fileAnnexesEntity = new AnnexesFileEntity(); if (!System.IO.File.Exists(virtualPath)) { byte[] bytes = Convert.FromBase64String(base64url.Replace("data:image/png;base64,", "")); FileInfo file = new FileInfo(virtualPath); FileStream fs = file.Create(); fs.Write(bytes, 0, bytes.Length); fs.Close(); //文件信息写入数据库 fileAnnexesEntity.F_Id = fileGuid; fileAnnexesEntity.F_FileName = "userphoto.png"; fileAnnexesEntity.F_FilePath = virtualPath; fileAnnexesEntity.F_FileSize = bytes.Length.ToString(); fileAnnexesEntity.F_FileExtensions = FileEextension; fileAnnexesEntity.F_FileType = FileEextension.Replace(".", ""); fileAnnexesEntity.F_CreateUserId = loginuser.userId; fileAnnexesEntity.F_CreateUserName = loginuser.realName; annexesFileIBLL.SaveEntity(folderId, fileAnnexesEntity); } var result = stuInfoFreshIBLL.IsPhoto(stuId, true, fileGuid); if (result.Item1) { return Success(result.Item2); } else { return Fail(result.Item2); } } #endregion } }