diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs index e70b2484e..8dd58a724 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuInfoBasicController.cs @@ -265,6 +265,15 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers return View(); } + /// + /// 导入页面 + /// + /// + [HttpGet] + public ActionResult ImportForm() + { + return View(); + } #endregion @@ -743,6 +752,29 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers stuInfoBasicIBLL.SynPhoto(); return Success("同步成功!"); } + + + /// + /// 宿舍信息导入模板 + /// + /// + public ActionResult DownTemplate() + { + FileStreamResult result = null; + try + { + var path = Server.MapPath("~/Content/excel/"); + var pathoffull = path + "StuInfoBasicImport.xls"; + FileStream fsread = fsread = new FileStream(pathoffull, FileMode.OpenOrCreate, FileAccess.ReadWrite); + result = File(fsread, "application/ms-excel", "学籍信息批量修改.xls"); + + return result; + } + catch (Exception ex) + { + return null; + } + } #endregion } } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.cshtml new file mode 100644 index 000000000..e45c62394 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.cshtml @@ -0,0 +1,24 @@ +@{ + ViewBag.Title = "Form"; + Layout = "~/Views/Shared/_Form.cshtml"; +} + + +@Html.AppendCssFile("/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.css") +
+
+
上传文件
+
下载模板
+
+
+
+
+ +
+
+

试试将电脑里的文件拖拽到此上传

+
+
+
+
+@Html.AppendJsFile("/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.js") diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.css b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.css new file mode 100644 index 000000000..04b556b7a --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.css @@ -0,0 +1,136 @@ +.lr-form-layout-body { + padding:0 5px 5px 5px; +} +.lr-form-file-queue-wrap { + position:relative; + width:100%; + height:100%; + border:1px solid #ddd; + border-radius:4px; +} +.lr-form-file-queue { + position:relative; +} +.lr-form-file-queue { + position:relative; +} +.lr-form-file-queue-item { + position:relative; + width:100%; + height:50px; + border-bottom:1px solid #ddd; + padding-left:60px; + +} +.lr-file-image { + position:absolute; + top:5px; + left:5px; +} +.lr-file-image img { + width:40px; + height:40px; +} +.lr-file-name{ + line-height:50px; + +} +.lr-msg { + position:absolute; + top:0; + right:5px; + font-size: 25px; + line-height:50px; +} +.lr-msg .fa-check-circle{ + color: #5cb85c; +} +.lr-msg .fa-exclamation-circle { + color: #b94a48; +} +.lr-msg2 { + position:absolute; + top:0; + right:5px; + line-height:50px; +} +.lr-msg2 span { + color:#333; + font-size:14px; + margin-right:5px; +} + +.lr-tool-bar { + position:absolute; + top:0; + right:35px; + font-size: 25px; + line-height:50px; + color:#666; + cursor:pointer; +} +.lr-tool-bar > i { + margin-left:8px; +} + +.lr-tool-bar .fa-minus-circle { + color: #b94a48; +} +.lr-tool-bar .fa-cloud-download { + color: #3498db; +} + +.lr-uploader-progress { + position:absolute; + bottom:2px; + left:60px; + height:4px; + width:500px; + width:calc(100% - 90px); +} +.lr-uploader-progress-bar { + position:relative; + height:100%; + background-color:#039cfd; + border-radius:4px; +} + + +.lr-form-file-queue-bg { + position:absolute; + top:50%; + left:50%; + width:300px; + height:30px; + line-height:30px; + + margin:-15px 0 0 -150px; +} +.lr-form-file-queue-bg h1 { + color: #666; + font-size: 20px; + font-family: Microsoft Yahei; + padding-bottom: 2px; + margin: 0; +} +#lr_down_file_btn { + position:absolute; + right:5px; + background:#fff; + border:1px solid #ddd; + color:#333; +} +#lr_down_file_btn:hover { + color:#337ab7; +} +/*对百度插件的样式重写*/ +.webuploader-container { + position:absolute; +} +.webuploader-pick { + padding:8px 15px; + background-color:#039cfd; +} +.webuploader-pick-hover { + background-color:#027dcb; +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.js new file mode 100644 index 000000000..c9af166f7 --- /dev/null +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/ImportForm.js @@ -0,0 +1,240 @@ +/* + * 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园(http://www.learun.cn) + * Copyright (c) 2013-2018 北京泉江科技有限公司 + * 创建人:陈彬彬 + * 日 期:2017.04.11 + * 描 述:导入Excel + */ +var id = request('id'); + +var keyVaule = ''; + +var bootstrap = function ($, learun) { + "use strict"; + + var page1 = { + init: function () { + page.bind(); + page.initData(); + }, + bind: function () { + $('#lr_add_format').on('click', function () { + currentColRow = null; + learun.layerForm({ + id: 'FormatForm', + title: '添加', + url: top.$.rootUrl + '/LR_SystemModule/CodeRule/FormatForm', + width: 450, + height: 310, + callBack: function (id) { + return top[id].acceptClick(function (data) { + $('#gridtable').jfGridSet('addRow', { row: data }); + }); + } + }); + }); + $('#lr_edit_format').on('click', function () { + currentColRow = $('#gridtable').jfGridGet('rowdata'); + var _id = currentColRow ? currentColRow.itemTypeName : ''; + if (learun.checkrow(_id)) { + learun.layerForm({ + id: 'FormatForm', + title: '修改', + url: top.$.rootUrl + '/LR_SystemModule/CodeRule/FormatForm', + width: 450, + height: 310, + callBack: function (id) { + return top[id].acceptClick(function (data) { + $('#gridtable').jfGridSet('updateRow', { row: data }); + }); + } + }); + } + + }); + $('#lr_delete_format').on('click', function () { + currentColRow = null; + var row = $('#gridtable').jfGridGet('rowdata'); + var _id = row ? row.itemTypeName : ''; + if (learun.checkrow(_id)) { + learun.layerConfirm('是否确认删除该项!', function (res, index) { + if (res) { + $('#gridtable').jfGridSet('removeRow'); + top.layer.close(index); //再执行关闭 + } + }); + } + }); + + $('#gridtable').jfGrid({ + headData: [ + { label: "前缀", name: "itemTypeName", width: 120, align: "left" }, + { label: "格式", name: "formatStr", width: 120, align: "left" }, + { label: "步长", name: "stepValue", width: 100, align: "left" }, + { label: "初始值", name: "initValue", width: 120, align: "left" }, + { label: "说明", name: "description", width: 180, align: "left" } + ] + }); + + /*检测重复项*/ + $('#F_EnCode').on('blur', function () { + $.lrExistField(keyValue, 'F_EnCode', top.$.rootUrl + '/LR_SystemModule/CodeRule/ExistEnCode'); + }); + $('#F_FullName').on('blur', function () { + $.lrExistField(keyValue, 'F_FullName', top.$.rootUrl + '/LR_SystemModule/CodeRule/ExistFullName'); + }); + }, + initData: function () { + if (!!selectedRow) { + keyValue = selectedRow.F_RuleId; + $('#form').lrSetFormData(selectedRow); + var formatdata = JSON.parse(selectedRow.F_RuleFormatJson); + $('#gridtable').jfGridSet('refreshdata', formatdata); + } + } + }; + + var fileInfo = {}; + + // 触发合并文件碎片 + var mergeFileChunks = function (file) { + + + var param = {}; + param['__RequestVerificationToken'] = $.lrToken; + param['fileId'] = fileInfo[file.id].fileGuid; + param['chunks'] = fileInfo[file.id].chunks; + param['ext'] = file.ext; + param['templateId'] = id; + learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/ExcelImport/StuInfoBasicImport", param, function (res) { + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.find('.lr-uploader-progress').remove(); + if (res.code == learun.httpCode.success) { + if (res.data.Success != '0') { + learun.alert.success('导入成功' + res.data.Success + '条'); + } + // 文件保存成功后 + $fileItem.append('
' + res.data.Success + '/' + res.data.Fail + '
'); + // 如果有失败 + if (res.data.Fail != '0') + { + learun.download({ url: top.$.rootUrl + '/LR_SystemModule/ExcelImport/DownImportErrorFile', param: { fileId: fileInfo[file.id].fileGuid, fileName: fileInfo[file.id].name, __RequestVerificationToken: $.lrToken }, method: 'POST' }); + } + } + else { + $fileItem.append('
'); + } + }); + } + // 触发清楚文件碎片 + var reomveFileChunks = function (file) { + var param = {}; + param['__RequestVerificationToken'] = $.lrToken; + param['fileGuid'] = fileInfo[file.id].fileGuid; + param['chunks'] = fileInfo[file.id].chunks; + learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/Annexes/MergeAnnexesFile", param, function (res) { }); + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.find('.lr-uploader-progress').remove(); + $fileItem.append('
'); + } + + var page = { + uploader: null, + init: function () { + /*模板下载*/ + $('#lr_down_file_btn').on('click', function () { + learun.download({ url: top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/DownTemplate', param: { keyValue: id, __RequestVerificationToken: $.lrToken }, method: 'POST' }); + }); + if (!WebUploader.Uploader.support()) { + alert('Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器'); + throw new Error('WebUploader does not support the browser you are using.'); + } + + page.uploader = WebUploader.create({ + auto: true, + swf: top.$.rootUrl + '/Content/webuploader/Uploader.swf', + // 文件接收服务端。 + server: top.$.rootUrl + "/LR_SystemModule/Annexes/UploadAnnexesFileChunk", + // 选择文件的按钮。可选。 + // 内部根据当前运行是创建,可能是input元素,也可能是flash. + pick: '#lr_add_file_btn', + dnd: '#lr_form_file_queue', + paste: 'document.body', + disableGlobalDnd: true, + accept: { + extensions: "xls,xlsx" + }, + multiple: true, + // 不压缩image, 默认如果是jpeg,文件上传前会压缩一把再上传! + resize: false, + // 文件分片上传 + chunked: true, + chunkRetry: 3, + prepareNextFile: true, + chunkSize: '1048576', + // 上传参数 + formData: { + __RequestVerificationToken: $.lrToken + } + }); + page.uploader.on('fileQueued', page.fileQueued); + page.uploader.on('uploadStart', page.uploadStart); + page.uploader.on('uploadBeforeSend', page.uploadBeforeSend); + page.uploader.on('uploadProgress', page.uploadProgress); + page.uploader.on('uploadSuccess', page.uploadSuccess); + page.uploader.on('uploadError', page.uploadError); + page.uploader.on('uploadComplete', page.uploadComplete); + page.uploader.on('error', page.error); + + $('#lr_form_file_queue').lrscroll(); + + }, + fileQueued: function (file) {// 文件加载到队列 + fileInfo[file.id] = { name: file.name }; + $('#lr_form_file_queue .lr-form-file-queue-bg').hide(); + // 添加一条文件记录 + var $item = $('
'); + $item.append('
'); + $item.append('' + file.name + '(' + learun.countFileSize(file.size) + ')'); + + $('#lr_form_file_queue_list').append($item); + }, + uploadStart: function (file) { + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.append('
'); + }, + uploadBeforeSend: function (object, data, headers) { + data.chunk = data.chunk || 0; + data.chunks = data.chunks || 1; + fileInfo[data.id].fileGuid = fileInfo[data.id].fileGuid || WebUploader.Base.guid(); + data.fileGuid = fileInfo[data.id].fileGuid; + fileInfo[data.id].chunks = data.chunks; + }, + uploadProgress: function (file, percentage) { + var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); + $fileItem.find('.lr-uploader-progress-bar').css('width', (percentage * 100 + '%')); + }, + uploadSuccess: function (file, res) { + if (res.code == 200) {// 上传成功 + mergeFileChunks(file); + } + else {// 上传失败 + reomveFileChunks(file); + } + }, + uploadError: function (file, code) { + reomveFileChunks(file); + }, + uploadComplete: function (file) { + }, + error: function (type) { + switch (type) { + case 'Q_TYPE_DENIED': + learun.alert.error('当前文件类型不允许上传'); + break; + }; + } + }; + page.init(); + +} \ No newline at end of file diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.cshtml index c8f6ed840..914c64532 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.cshtml +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.cshtml @@ -100,7 +100,7 @@  拍照  学生简历表  学籍卡打印 - +  信息批量修改 diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js index c5fa514c3..f0a831e5d 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuInfoBasic/Index.js @@ -366,7 +366,19 @@ var bootstrap = function ($, learun) { }); } }); - + $('#lr_import').on('click', + function () { + learun.layerForm({ + id: 'form', + title: '导入', + url: top.$.rootUrl + '/EducationalAdministration/StuInfoBasic/ImportForm', + width: 600, + height: 400, + callBack: function (id) { + return top[id].acceptClick(refreshGirdData); + } + }); + }); }, // 初始化列表 initGird: function () { diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_SystemModule/Controllers/ExcelImportController.cs b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_SystemModule/Controllers/ExcelImportController.cs index 909ff2cb2..94ab4f5b0 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_SystemModule/Controllers/ExcelImportController.cs +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/LR_SystemModule/Controllers/ExcelImportController.cs @@ -6,6 +6,7 @@ using System.Data; using Learun.Application.Base.SystemModule; using System; using System.Drawing; +using Learun.Application.TwoDevelopment.EducationalAdministration; namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers { @@ -20,6 +21,7 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers { private ExcelImportIBLL excelImportIBLL = new ExcelImportBLL(); private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); + private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); #region 视图功能 /// /// 导入模板管理页面 @@ -206,10 +208,10 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers /// [HttpPost] [ValidateAntiForgeryToken] - public ActionResult ExecuteImportExcel(string templateId, string fileId, int chunks,string ext) + public ActionResult ExecuteImportExcel(string templateId, string fileId, int chunks, string ext) { UserInfo userInfo = LoginUserInfo.Get(); - string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "."+ ext, chunks, userInfo); + string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo); if (!string.IsNullOrEmpty(path)) { DataTable dt = ExcelHelper.ExcelImport(path); @@ -236,14 +238,14 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers /// [HttpPost] [ValidateAntiForgeryToken] - public ActionResult ExecuteImportSaralExcel(string fileId, int chunks,string ext) + public ActionResult ExecuteImportSaralExcel(string fileId, int chunks, string ext) { UserInfo userInfo = LoginUserInfo.Get(); - string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "."+ ext, chunks, userInfo); + string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo); if (!string.IsNullOrEmpty(path)) { DataTable dt = ExcelHelper.ExcelImport(path); - string res = excelImportIBLL.ImportSalaryInfo(dt,fileId); + string res = excelImportIBLL.ImportSalaryInfo(dt, fileId); var data = new { Success = res.Split('|')[0], @@ -266,14 +268,14 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers /// [HttpPost] [ValidateAntiForgeryToken] - public ActionResult EmpInfoImport(string fileId, int chunks,string ext) + public ActionResult EmpInfoImport(string fileId, int chunks, string ext) { UserInfo userInfo = LoginUserInfo.Get(); - string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "."+ ext, chunks, userInfo); + string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo); if (!string.IsNullOrEmpty(path)) { DataTable dt = ExcelHelper.ExcelImport(path); - string res = excelImportIBLL.EmpInfoImport(dt,fileId); + string res = excelImportIBLL.EmpInfoImport(dt, fileId); var data = new { Success = res.Split('|')[0], @@ -287,6 +289,36 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers } } + /// + /// 学生学籍信息批量修改 + /// + /// 模板Id + /// 文件主键 + /// 分片数 + /// 文件扩展名 + /// + [HttpPost] + [ValidateAntiForgeryToken] + public ActionResult StuInfoBasicImport(string fileId, int chunks, string ext) + { + UserInfo userInfo = LoginUserInfo.Get(); + string path = annexesFileIBLL.SaveAnnexes(fileId, fileId + "." + ext, chunks, userInfo); + if (!string.IsNullOrEmpty(path)) + { + DataTable dt = ExcelHelper.ExcelImport(path); + string res = stuInfoBasicIBLL.StuInfoBasicImport(dt, fileId); + var data = new + { + Success = res.Split('|')[0], + Fail = res.Split('|')[1] + }; + return JsonResult(data); + } + else + { + return Fail("导入数据失败!"); + } + } /// /// 下载文件(导入文件未被导入的数据) /// @@ -294,7 +326,7 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers /// [HttpPost] [ValidateAntiForgeryToken] - public void DownImportErrorFile(string fileId,string fileName) + public void DownImportErrorFile(string fileId, string fileName) { //设置导出格式 ExcelConfig excelconfig = new ExcelConfig(); @@ -325,7 +357,7 @@ namespace Learun.Application.Web.Areas.LR_SystemModule.Controllers }); } - + } ExcelHelper.ExcelDownload(dt, excelconfig); } diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/StuInfoBasicImport.xls b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/StuInfoBasicImport.xls new file mode 100644 index 000000000..f97076dfb Binary files /dev/null and b/Learun.Framework.Ultimate V7/Learun.Application.Web/Content/excel/StuInfoBasicImport.xls differ diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj index f4e9eabdd..fd925a48c 100644 --- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj +++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj @@ -1229,6 +1229,8 @@ + + @@ -1319,6 +1321,7 @@ + @@ -8010,6 +8013,8 @@ + + diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicBLL.cs index 8502745a8..d7bc8a492 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicBLL.cs @@ -705,7 +705,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } } - + public string StuInfoBasicImport(DataTable dt, string fileId) + { + try + { + return stuInfoBasicService.StuInfoBasicImport(dt, fileId); + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowBusinessException(ex); + } + } + } #endregion } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicIBLL.cs index f8314c069..159aa4526 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicIBLL.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicIBLL.cs @@ -28,7 +28,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// StuInfoBasicEntity GetStuInfoBasicEntity(string keyValue); List GetMajorInfoWithGraduation(); - void CreateGraduateNoByMajor(string CityCode,string SchoolCode,string MajorList); + void CreateGraduateNoByMajor(string CityCode, string SchoolCode, string MajorList); /// /// 获取StuInfoBasic表实体数据 @@ -42,7 +42,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration StuInfoBasicEntity GetStuInfoBasicEntityByStuNo(string enCode); StuInfoBasicEntity GetStuInfoBasicEntityByStuName(string name); - StuInfoBasicEntity GetStuInfoBasicEntityByStuNoOrStuName(string stuno,string stuname); + StuInfoBasicEntity GetStuInfoBasicEntityByStuNoOrStuName(string stuno, string stuname); /// /// 获取左侧树形数据 /// @@ -55,7 +55,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 审核全部 /// void CheckAll(); - void AllowGraduate(string stuNo,string status); + void AllowGraduate(string stuNo, string status); void SynPhoto(); /// /// 删除实体数据 @@ -67,7 +67,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 领取毕业证 /// /// - void GetCard(string keyValue,string status, StuInfoBasicEntity entity); + void GetCard(string keyValue, string status, StuInfoBasicEntity entity); /// /// 图书资料归还 /// @@ -97,7 +97,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// 档案与组织关系转出 /// /// - void IsFileTransfer(string keyValue, string status,string fort); + void IsFileTransfer(string keyValue, string status, string fort); void StuStore(); @@ -108,7 +108,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration /// void SaveEntity(string keyValue, StuInfoBasicEntity entity); void UpdateAccount(); - void UpdateState(string keyValue,string state); + void UpdateState(string keyValue, string state); #endregion void GenerateAccout(); @@ -116,5 +116,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration IEnumerable GetAllList(); IEnumerable GetAllList(string ChangeType); IEnumerable GetStuInfoByClassNo(string classNo); + + string StuInfoBasicImport(DataTable dt, string fileId); } } diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs index 6893b9cf1..59eacba08 100644 --- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs +++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuInfoBasic/StuInfoBasicService.cs @@ -11,6 +11,8 @@ using Learun.Application.Organization; using System.Reflection; using Learun.Application.Base.SystemModule; using Learun.Application.TwoDevelopment.LogisticsManagement; +using Learun.Cache.Base; +using Learun.Cache.Factory; namespace Learun.Application.TwoDevelopment.EducationalAdministration { @@ -1299,6 +1301,86 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration } } + #region 缓存定义 + private ICache cache = CacheFactory.CaChe(); + private string cacheKey = "Learun_adms_excelError_"; // +公司主键 + #endregion + + /// + /// 学生学籍信息修改 + /// + /// + public string StuInfoBasicImport(DataTable dt, string fileId) + { + try + { + int snum = 0; + int fnum = 0; + if (dt.Rows.Count > 0) + { + DataTable failDt = new DataTable(); + dt.Columns.Add("导入错误", typeof(string)); + foreach (DataColumn dc in dt.Columns) + { + failDt.Columns.Add(dc.ColumnName, dc.DataType); + } + IEnumerable stuInfoBasicEntities = this.BaseRepository("CollegeMIS").FindList("select * from StuInfoBasic"); + //修改学生list + List insertedorderlist = new List(); + var db = this.BaseRepository("CollegeMIS").BeginTrans(); + // 循环遍历导入 + foreach (DataRow dr in dt.Rows) + { + try + { + //检测是否有空值 + if (dr[0].ToString() == "" || dr[1].ToString() == "" || dr[2].ToString() == "" || dr[3].ToString() == "") + { + throw (new Exception("行内数据有空值,不能为空!")); + } + if (stuInfoBasicEntities.Count(m => m.IdentityCardNo.ToUpper() == dr[0].ToString().ToUpper()) == 0) + { + throw (new Exception("【身份证号】不存在,请核对!")); + } + //写入要导入的数据 + StuInfoBasicEntity stuUpdateList = new StuInfoBasicEntity(); + stuUpdateList.StuId = stuInfoBasicEntities.FirstOrDefault(s => s.IdentityCardNo.ToUpper() == dr[0].ToString().ToUpper())?.StuId.ToString(); + stuUpdateList.StuCode = dr[1].ToString(); + stuUpdateList.MailAddress = dr[2].ToString(); + stuUpdateList.mobile = dr[3].ToString(); + insertedorderlist.Add(stuUpdateList); + snum++; + } + catch (Exception ex) + { + fnum++; + dr["导入错误"] = ex.Message; + failDt.Rows.Add(dr.ItemArray); + } + } + //执行导入 + db.Update(insertedorderlist); + db.Commit(); + if (failDt.Rows.Count > 0) + { + string errordt = failDt.ToJson(); + cache.Write(cacheKey + fileId, errordt, CacheId.excel); + } + } + return snum + "|" + fnum; + } + catch (Exception ex) + { + if (ex is ExceptionEx) + { + throw; + } + else + { + throw ExceptionEx.ThrowServiceException(ex); + } + } + } #endregion