();
+ //行数据
+ DataTable rowData = dataJson.ToTable();
+
+ foreach (jfGridModel columnModel in columnList)
+ {
+ excelconfig.ColumnEntity.Add(new ColumnModel()
+ {
+ Column = columnModel.name,
+ ExcelColumn = columnModel.label,
+ Alignment = columnModel.align,
+ });
+ }
+ ExcelHelper.ExcelDownload(rowData, excelconfig);
+ }
+
+ ///
+ /// 成绩导入
+ ///
+ /// 1必修;2选修;3补考成绩;4二次补考成绩
+ ///
+ ///
+ ///
+ ///
+ [HttpPost]
+ [ValidateAntiForgeryToken]
+ public ActionResult ExecuteImportExcel(int type, string fileGuid, int chunks, string queryJson)
+ {
+ string path = annexesFileIBLL.SaveAnnexes(fileGuid, fileGuid, chunks, LoginUserInfo.Get());
+ if (!string.IsNullOrEmpty(path))
+ {
+ DataTable dt = ExcelHelper.ExcelImport(path);
+ (DataTable failDt, int snum, int fnum) res;
+ if (type == 1 || type == 2)
+ {
+ //必修选修
+ res = stuScoreIBLL.ExecuteImportExcel(type, dt, fileGuid, queryJson);
+ }
+ else if (type == 3)
+ {
+ //补考
+ res = stuScoreNotPassIBLL.ExecuteImportExcelForNotPass(dt, fileGuid, queryJson);
+ }
+ else
+ {
+ //二次补考
+ res = stuScoreNotPassTwoIBLL.ExecuteImportExcelForNotPassTwo(dt, fileGuid, queryJson);
+ }
+ var data = new
+ {
+ Success = res.snum,
+ Fail = res.failDt.Rows.Count
+ };
+ return Success(data);
+ }
+ else
+ {
+ return Fail("导入数据失败!");
+ }
+ }
+
+
#endregion
}
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.cshtml
index e53f22674..8e711f3d0 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.cshtml
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.cshtml
@@ -89,6 +89,7 @@
提交教务处
去审核成绩
设置成绩比例
+ 导入
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.js
index 6ead81c74..7d9394e28 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndex.js
@@ -15,6 +15,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
+var rowJson;
+var columnJson;
+var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -442,6 +445,63 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScore/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
+ //导入
+ $("#lr_importScore").on("click", function () {
+ var query = judgeSelect();
+ if (query) {
+ //判断成绩比例是否合理
+ var OrdinaryScoreScale = $('#OrdinaryScoreScale').html();
+ var TermInScoreScale = $('#TermInScoreScale').html();
+ var TermEndScoreScale = $('#TermEndScoreScale').html();
+ var OtherScoreScale = $('#OtherScoreScale').html();
+ var totalScale = Number(OrdinaryScoreScale) + Number(TermInScoreScale) + Number(TermEndScoreScale) + Number(OtherScoreScale);
+ if (totalScale !== 100) {
+ learun.alert.warning("成绩比例设置不合理!");
+ return false;
+ } else {
+ //判断是否已审核;判断是否被其他教师占用
+ $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScore/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
+ if (data != null) {
+ if (data.CheckMark == 1) {
+ learun.alert.warning("学生成绩已审核!");
+ return false;
+ }
+ if (data.IsEditable == 0) {
+ if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
+ modifyDate = data.ModifyDate;
+ } else {
+ learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
+ return false;
+ }
+ }
+ rowJson = $('#gridtable').jfGridGet('showData');
+ columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
+
+ //条件
+ var $content = $('body').find('.lr-layout-tool-left');
+ queryJson = $content.lrGetFormData();
+
+ learun.layerForm({
+ id: 'indexImport',
+ title: "导入学生成绩",
+ url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=1',
+ width: 600,
+ height: 400,
+ maxmin: true,
+ btn: null,
+ end: function () {
+ refreshGirdData2();
+ }
+ });
+
+ } else {
+ learun.alert.warning("学生成绩不存在!");
+ return false;
+ }
+ });
+ }
+ }
+ });
},
bindSelect: function () {
//校区
@@ -503,7 +563,7 @@ var bootstrap = function ($, learun) {
url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetList',
headData: headDataFinally,
mainId: 'ScoreId',
- isPage: false,
+ isPage: true,
sidx: 'StuNo',
sord: 'asc'
});
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.cshtml
index 922eab34b..4525d463d 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.cshtml
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.cshtml
@@ -89,6 +89,7 @@
提交教务处
去审核成绩
设置成绩比例
+ 导入
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js
index b0e0da3de..047963286 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js
@@ -15,6 +15,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
+var rowJson;
+var columnJson;
+var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -442,6 +445,63 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScore/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
+ //导入
+ $("#lr_importScore").on("click", function () {
+ var query = judgeSelect();
+ if (query) {
+ //判断成绩比例是否合理
+ var OrdinaryScoreScale = $('#OrdinaryScoreScale').html();
+ var TermInScoreScale = $('#TermInScoreScale').html();
+ var TermEndScoreScale = $('#TermEndScoreScale').html();
+ var OtherScoreScale = $('#OtherScoreScale').html();
+ var totalScale = Number(OrdinaryScoreScale) + Number(TermInScoreScale) + Number(TermEndScoreScale) + Number(OtherScoreScale);
+ if (totalScale !== 100) {
+ learun.alert.warning("成绩比例设置不合理!");
+ return false;
+ } else {
+ //判断是否已审核;判断是否被其他教师占用
+ $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScore/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
+ if (data != null) {
+ if (data.CheckMark == 1) {
+ learun.alert.warning("学生成绩已审核!");
+ return false;
+ }
+ if (data.IsEditable == 0) {
+ if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
+ modifyDate = data.ModifyDate;
+ } else {
+ learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
+ return false;
+ }
+ }
+ rowJson = $('#gridtable').jfGridGet('showData');
+ columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
+
+ //条件
+ var $content = $('body').find('.lr-layout-tool-left');
+ queryJson = $content.lrGetFormData();
+
+ learun.layerForm({
+ id: 'indexImport',
+ title: "导入学生成绩",
+ url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=1',
+ width: 600,
+ height: 400,
+ maxmin: true,
+ btn: null,
+ end: function () {
+ refreshGirdData2();
+ }
+ });
+
+ } else {
+ learun.alert.warning("学生成绩不存在!");
+ return false;
+ }
+ });
+ }
+ }
+ });
},
bindSelect: function () {
//校区
@@ -504,7 +564,7 @@ var bootstrap = function ($, learun) {
url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetList',
headData: headDataFinally,
mainId: 'ScoreId',
- isPage: false,
+ isPage: true,
sidx: 'StuNo',
sord: 'asc'
});
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.cshtml
new file mode 100644
index 000000000..67a7ef54f
--- /dev/null
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.cshtml
@@ -0,0 +1,27 @@
+@{
+ ViewBag.Title = "Form";
+ Layout = "~/Views/Shared/_Form.cshtml";
+}
+
+
+@Html.AppendCssFile("/Areas/LR_SystemModule/Views/ExcelImport/ImportForm.css")
+
+@*必修成绩录入导入*@
+
+
+@Html.AppendJsFile("/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js")
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js
new file mode 100644
index 000000000..f5f1fdf00
--- /dev/null
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js
@@ -0,0 +1,196 @@
+/*
+ * 描 述:附件上传管理
+ */
+var gridId = request('gridtable');
+var type = request('type');//1:成绩录入;2:选修成绩录入
+var bootstrap = function ($, learun) {
+ "use strict";
+
+ var fileInfo = {};
+
+ // 触发合并文件碎片
+ var mergeFileChunks = function (file) {
+ var param = {};
+ param['type'] = type;
+ param['__RequestVerificationToken'] = $.lrToken;
+ param['fileGuid'] = fileInfo[file.id].fileGuid;
+ param['fileName'] = fileInfo[file.id].name;
+ param['chunks'] = fileInfo[file.id].chunks;
+ var queryJson = JSON.stringify(learun.frameTab.currentIframe().queryJson);
+
+ param['queryJson'] = queryJson;
+ learun.httpAsyncPost(top.$.rootUrl + "/EducationalAdministration/StuScore/ExecuteImportExcel", 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 {
+ learun.alert.error(res.info);
+ $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 DeleteFile = function (fileId) {
+ var param = {};
+ param['__RequestVerificationToken'] = $.lrToken;
+ param['fileId'] = fileInfo[fileId].fileGuid;
+ learun.httpAsyncPost(top.$.rootUrl + "/LR_SystemModule/Annexes/DeleteAnnexesFile", param, function (res) { });
+ var file = page.uploader.getFile(fileId);
+ if (!!file) {
+ page.uploader.removeFile(file);
+ }
+ delete fileInfo[fileId];
+ var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + fileId);
+ $fileItem.remove();
+ if ($('#lr_form_file_queue_list>div').length == 0) {
+ $('#lr_form_file_queue .lr-form-file-queue-bg').show();
+ }
+ }
+
+ var page = {
+ uploader: null,
+ init: function () {
+ if (!WebUploader.Uploader.support()) {
+ alert('Web Uploader 不支持您的浏览器!如果你使用的是IE浏览器,请尝试升级 flash 播放器');
+ throw new Error('WebUploader does not support the browser you are using.');
+ }
+ /*导入模板下载*/
+ $('#lr_down_file_btn').on('click', function () {
+ var columnJson = learun.frameTab.currentIframe().columnJson;
+ columnJson = JSON.stringify(columnJson.filter(item => item.name !== 'CheckMark'));
+ var rowJson = JSON.stringify(learun.frameTab.currentIframe().rowJson);
+ var fileName = "成绩录入数据";
+ if (type == '2') {
+ fileName = "选修成绩录入数据";
+ }
+ else if (type == '3') {
+ fileName = "补考成绩录入";
+ }
+ else if (type == '4') {
+ fileName = "二次补考成绩录入";
+ }
+ learun.download({
+ method: "POST",
+ url: '/EducationalAdministration/StuScore/ExportExcel',
+ param: {
+ fileName: fileName,
+ columnJson: columnJson,
+ dataJson: rowJson,
+ //exportField: String(exportField)
+ }
+ });
+ });
+
+ 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: false,
+ // 不压缩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').mCustomScrollbar({ // 优化滚动条
+ // theme: "minimal-dark"
+ //});
+
+ },
+ 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();
+}
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.cshtml
index 87d030286..e33d9dbdf 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.cshtml
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.cshtml
@@ -89,6 +89,7 @@
提交成绩
提交教务处
去审核成绩
+ 导入
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.js
index a3874407a..50f66f6ea 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndex.js
@@ -15,6 +15,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
+var rowJson;
+var columnJson;
+var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -342,6 +345,54 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPass/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
+ //导入
+ $("#lr_importScore").on("click", function () {
+ var query = judgeSelect();
+ if (query) {
+
+ //判断是否已审核;判断是否被其他教师占用
+ $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPass/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
+ if (data != null) {
+ if (data.CheckMark == 1) {
+ learun.alert.warning("学生成绩已审核!");
+ return false;
+ }
+ if (data.IsEditable == 0) {
+ if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
+ modifyDate = data.ModifyDate;
+ } else {
+ learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
+ return false;
+ }
+ }
+ rowJson = $('#gridtable').jfGridGet('showData');
+ columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
+
+ //条件
+ var $content = $('body').find('.lr-layout-tool-left');
+ queryJson = $content.lrGetFormData();
+
+ learun.layerForm({
+ id: 'indexImport',
+ title: "导入学生成绩",
+ url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=3',
+ width: 600,
+ height: 400,
+ maxmin: true,
+ btn: null,
+ end: function () {
+ refreshGirdData2();
+ }
+ });
+
+ } else {
+ learun.alert.warning("学生成绩不存在!");
+ return false;
+ }
+ });
+
+ }
+ });
},
bindSelect: function () {
//校区
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.cshtml
index 0fb324a54..650c71496 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.cshtml
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.cshtml
@@ -89,6 +89,7 @@
提交成绩
提交教务处
去审核成绩
+ 导入
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.js
index d84b493c0..2843ae7b0 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.js
@@ -15,6 +15,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
+var rowJson;
+var columnJson;
+var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -342,6 +345,54 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPass/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
+ //导入
+ $("#lr_importScore").on("click", function () {
+ var query = judgeSelect();
+ if (query) {
+
+ //判断是否已审核;判断是否被其他教师占用
+ $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPass/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
+ if (data != null) {
+ if (data.CheckMark == 1) {
+ learun.alert.warning("学生成绩已审核!");
+ return false;
+ }
+ if (data.IsEditable == 0) {
+ if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
+ modifyDate = data.ModifyDate;
+ } else {
+ learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
+ return false;
+ }
+ }
+ rowJson = $('#gridtable').jfGridGet('showData');
+ columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
+
+ //条件
+ var $content = $('body').find('.lr-layout-tool-left');
+ queryJson = $content.lrGetFormData();
+
+ learun.layerForm({
+ id: 'indexImport',
+ title: "导入学生成绩",
+ url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=3',
+ width: 600,
+ height: 400,
+ maxmin: true,
+ btn: null,
+ end: function () {
+ refreshGirdData2();
+ }
+ });
+
+ } else {
+ learun.alert.warning("学生成绩不存在!");
+ return false;
+ }
+ });
+
+ }
+ });
},
bindSelect: function () {
//校区
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.cshtml
index 1992775db..317268f49 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.cshtml
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.cshtml
@@ -91,6 +91,7 @@
提交成绩
提交教务处
去审核成绩
+ 导入
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.js
index e3726b5b8..a9da3cdd0 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndex.js
@@ -15,6 +15,10 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
+var rowJson;
+var columnJson;
+var queryJson;
+
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -342,6 +346,53 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPassTwo/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
+ //导入
+ $("#lr_importScore").on("click", function () {
+ var query = judgeSelect();
+ if (query) {
+
+ //判断是否已审核;判断是否被其他教师占用
+ $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPassTwo/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
+ if (data != null) {
+ if (data.CheckMark == 1) {
+ learun.alert.warning("学生成绩已审核!");
+ return false;
+ }
+ if (data.IsEditable == 0) {
+ if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
+ modifyDate = data.ModifyDate;
+ } else {
+ learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
+ return false;
+ }
+ }
+ rowJson = $('#gridtable').jfGridGet('showData');
+ columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
+
+ //条件
+ var $content = $('body').find('.lr-layout-tool-left');
+ queryJson = $content.lrGetFormData();
+
+ learun.layerForm({
+ id: 'indexImport',
+ title: "导入学生成绩",
+ url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=4',
+ width: 600,
+ height: 400,
+ maxmin: true,
+ btn: null,
+ end: function () {
+ refreshGirdData2();
+ }
+ });
+
+ } else {
+ learun.alert.warning("学生成绩不存在!");
+ return false;
+ }
+ });
+ }
+ });
},
bindSelect: function () {
//校区
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.cshtml b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.cshtml
index 76bbc6e7f..f2e8cb7d9 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.cshtml
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.cshtml
@@ -89,6 +89,7 @@
提交成绩
提交教务处
去审核成绩
+ 导入
diff --git a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.js b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.js
index e3726b5b8..a9da3cdd0 100644
--- a/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.js
+++ b/Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.js
@@ -15,6 +15,10 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
+var rowJson;
+var columnJson;
+var queryJson;
+
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -342,6 +346,53 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPassTwo/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
+ //导入
+ $("#lr_importScore").on("click", function () {
+ var query = judgeSelect();
+ if (query) {
+
+ //判断是否已审核;判断是否被其他教师占用
+ $.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPassTwo/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
+ if (data != null) {
+ if (data.CheckMark == 1) {
+ learun.alert.warning("学生成绩已审核!");
+ return false;
+ }
+ if (data.IsEditable == 0) {
+ if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
+ modifyDate = data.ModifyDate;
+ } else {
+ learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
+ return false;
+ }
+ }
+ rowJson = $('#gridtable').jfGridGet('showData');
+ columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
+
+ //条件
+ var $content = $('body').find('.lr-layout-tool-left');
+ queryJson = $content.lrGetFormData();
+
+ learun.layerForm({
+ id: 'indexImport',
+ title: "导入学生成绩",
+ url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=4',
+ width: 600,
+ height: 400,
+ maxmin: true,
+ btn: null,
+ end: function () {
+ refreshGirdData2();
+ }
+ });
+
+ } else {
+ learun.alert.warning("学生成绩不存在!");
+ return false;
+ }
+ });
+ }
+ });
},
bindSelect: function () {
//校区
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 20c6beff4..e63b9296a 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
@@ -1369,6 +1369,7 @@
+
@@ -8101,6 +8102,7 @@
+
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs
index ff60ce650..8bc664d5b 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs
@@ -3,6 +3,8 @@ using System;
using System.Data;
using System.Collections.Generic;
using static Learun.Application.TwoDevelopment.EducationalAdministration.StuScoreService;
+using Learun.Cache.Base;
+using Learun.Cache.Factory;
namespace Learun.Application.TwoDevelopment.EducationalAdministration
{
@@ -17,6 +19,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
{
private StuScoreService stuScoreService = new StuScoreService();
+ #region 缓存定义
+ private ICache cache = CacheFactory.CaChe();
+ private string cacheKey = "Learun_adms_excelError_";
+ #endregion
+
#region 获取数据
///
@@ -1074,5 +1081,33 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
#endregion
+ ///
+ /// 成绩导入
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(int type, DataTable dt, string fileGuid, string queryJson)
+ {
+ try
+ {
+ return stuScoreService.ExecuteImportExcel(type, dt, fileGuid, queryJson);
+
+ }
+ catch (Exception ex)
+ {
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowBusinessException(ex);
+ }
+
+ }
+ }
}
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs
index e2945073e..f1c62a208 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs
@@ -250,6 +250,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
void DoCheckScore(string queryJson, int checkMark);
#endregion
+ (DataTable failDt, int snum, int fnum) ExecuteImportExcel(int type, DataTable dt, string fileGuid, string queryJson);
IEnumerable GetLessonNoDataFromStuNo(string academicYearNo, string semester, string stuNo);
void UpEmpNos(string xn, string xq, string classNo, string LessonNo, string EmpNo, string HisEmpNo, string Grade);
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs
index d9d7035da..8ec654687 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs
@@ -9,6 +9,8 @@ using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
+using Learun.Cache.Base;
+using Learun.Cache.Factory;
namespace Learun.Application.TwoDevelopment.EducationalAdministration
{
@@ -21,6 +23,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
///
public class StuScoreService : RepositoryFactory
{
+ #region 缓存定义
+ private ICache cache = CacheFactory.CaChe();
+ private string cacheKey = "Learun_adms_excelError_";
+ #endregion
+
#region 构造函数和属性
private string fieldSql;
@@ -1991,5 +1998,329 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
}
}
+
+ ///
+ /// 成绩导入--必修课 选修课
+ ///
+ /// 1:必修,2:选修
+ ///
+ ///
+ ///
+ ///
+ public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(int type, DataTable dt, string fileGuid, string queryJson)
+ {
+ if (type == 1)
+ {
+ //必修
+ return ExecuteImportExcelForRequired(dt, fileGuid, queryJson);
+ }
+ else
+ {
+ //选修
+ return ExecuteImportExcelForElective(dt, fileGuid, queryJson);
+ }
+
+ }
+
+ ///
+ /// 导入学生成绩--必修课
+ ///
+ ///
+ ///
+ private (DataTable failDt, int snum, int fnum) ExecuteImportExcelForRequired(DataTable dt, string fileGuid, string queryJson)
+ {
+ //成功记录数
+ int snum = 0;
+ //总记录数
+ int num = 0;
+ var db = this.BaseRepository("CollegeMIS");
+ var msg = "";
+ try
+ {
+ db.BeginTrans();
+ // 创建一个datatable容器用于保存导入失败的数据
+ DataTable failDt = new DataTable();
+
+ var queryParam = queryJson.ToJObject();
+ var F_SchoolId = queryParam["F_SchoolId"].ToString();
+ var AcademicYearNo = queryParam["AcademicYearNo"].ToString();
+ var Semester = queryParam["Semester"].ToString();
+ var LessonNo = queryParam["LessonNo"].ToString();
+ var ClassNo = queryParam["ClassNo"].ToString();
+ var classInfoList = db.FindList();
+ var lessonInfoList = db.FindList();
+ var classInfoEntity = classInfoList.FirstOrDefault(x => x.ClassNo == ClassNo);
+ var lessonInfoEntity = lessonInfoList.FirstOrDefault(x => x.LessonNo == LessonNo && x.CheckMark == true);
+
+ if (classInfoEntity != null)
+ {
+ //获取成绩比例数据
+ var stuSelectLessonListEntity = db.FindEntity(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.OpenLessonDeptNo == classInfoEntity.DeptNo && x.OpenLessonMajorNo == classInfoEntity.MajorNo && x.LessonNo == LessonNo && x.LessonSortNo == "1" && x.ClassNo == ClassNo);
+ if (stuSelectLessonListEntity != null)
+ {
+ //当前班级学生成绩
+ var list = GetList(queryJson).ToList();
+
+ foreach (DataColumn dc in dt.Columns)
+ {
+ failDt.Columns.Add(dc.ColumnName, dc.DataType);
+ }
+ failDt.Columns.Add("导入错误", typeof(string));
+ dt.Columns.Add("导入错误", typeof(string));
+
+ foreach (DataRow dr in dt.Rows)
+ {
+ try
+ {
+ var stuno = dr["学号"].ToString().Trim();
+ var academicYearNo_dr = dr["学年"].ToString().Trim();
+ var semester_dr = dr["学期"].ToString().Trim();
+ var lessoninfo_dr = dr["课程名称"].ToString().Trim();
+ var classinfo_dr = dr["班级"].ToString().Trim();
+ //var lessonNo_dr = lessonInfoList.FirstOrDefault(x => x.LessonName == lessoninfo_dr)?.LessonNo;
+ //var classNo_dr = classInfoList.FirstOrDefault(x => x.ClassName == classinfo_dr)?.ClassNo;
+
+ if (!string.IsNullOrEmpty(stuno))
+ {
+ num++;
+ if (!academicYearNo_dr.Equals(AcademicYearNo) || !semester_dr.Equals(Semester))
+ {
+ dr["导入错误"] = "学年学期与查询条件不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+
+ if (!classinfo_dr.Equals(classInfoEntity.ClassName))
+ {
+ dr["导入错误"] = "班级与查询条件班级(" + classInfoEntity.ClassName + ")不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ if (!lessoninfo_dr.Equals(lessonInfoEntity.LessonName))
+ {
+ dr["导入错误"] = "课程与查询条件课程(" + lessonInfoEntity.LessonName + ")不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+
+ if (!lessoninfo_dr.Equals(lessonInfoEntity.LessonName) || !classinfo_dr.Equals(classInfoEntity.ClassName))
+ {
+ dr["导入错误"] = "课程:" + lessonInfoEntity.LessonName + ",班级:" + classInfoEntity.ClassName + "找不到学号为" + stuno + "的学生";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ var item = list.Find(x => x.StuNo == stuno && x.LessonNo == LessonNo && x.ClassNo == ClassNo);
+ var OrdinaryScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["平时成绩"].ToString().Trim()) ? "0" : dr["平时成绩"].ToString().Trim());
+ var TermInScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["期中成绩"].ToString().Trim()) ? "0" : dr["期中成绩"].ToString().Trim());
+ var TermEndScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["期末成绩"].ToString().Trim()) ? "0" : dr["期末成绩"].ToString().Trim());
+ var OtherScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["其他成绩"].ToString().Trim()) ? "0" : dr["其他成绩"].ToString().Trim());
+ if (OrdinaryScore < 0 || TermInScore < 0 || TermEndScore < 0 || OtherScore < 0)
+ {
+ dr["导入错误"] = "成绩必须大于0!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ var Score = Math.Round(Convert.ToDouble(OrdinaryScore * (stuSelectLessonListEntity.OrdinaryScoreScale / 100) +
+ TermInScore * (stuSelectLessonListEntity.TermInScoreScale / 100) +
+ TermEndScore * (stuSelectLessonListEntity.TermEndScoreScale / 100) +
+ OtherScore * (stuSelectLessonListEntity.OtherScoreScale / 100)), MidpointRounding.AwayFromZero);
+ var remark = dr["备注"].ToString().Trim();
+ db.ExecuteBySql($"update StuScore set OrdinaryScore={OrdinaryScore},TermInScore={TermInScore},TermEndScore={TermEndScore},OtherScore={OtherScore},Score={Score},Remark='{remark}' where ScoreId='{item.ScoreId}' ");
+
+ }
+ else
+ {
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ dr["导入错误"] = "出现异常:" + e.Message;
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ }
+ db.Commit();
+
+ // 写入缓存如果有未导入的数据
+ if (failDt.Rows.Count > 0)
+ {
+ string errordt = failDt.ToJson();
+
+ cache.Write(cacheKey + fileGuid, errordt, CacheId.excel);
+ }
+ snum = (num - failDt.Rows.Count) > 0 ? num - failDt.Rows.Count : 0;
+ }
+ }
+
+ return (failDt, snum, failDt.Rows.Count);
+ }
+ catch (Exception ex)
+ {
+ db.Rollback();
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowServiceException(ex);
+ }
+ }
+ }
+
+ ///
+ /// 导入学生成绩--选修课
+ ///
+ ///
+ ///
+ private (DataTable failDt, int snum, int fnum) ExecuteImportExcelForElective(DataTable dt, string fileGuid, string queryJson)
+ {
+
+ //成功记录数
+ int snum = 0;
+ //总记录数
+ int num = 0;
+ var db = this.BaseRepository("CollegeMIS");
+ var msg = "";
+ try
+ {
+ db.BeginTrans();
+
+ //创建一个datatable容器用于保存导入失败的数据
+ DataTable failDt = new DataTable();
+
+ var queryParam = queryJson.ToJObject();
+ var F_SchoolId = queryParam["F_SchoolId"].ToString();
+ var AcademicYearNo = queryParam["AcademicYearNo"].ToString();
+ var Semester = queryParam["Semester"].ToString();
+ var LessonNo = queryParam["LessonNo"].ToString();
+ var LessonSection = queryParam["LessonSection"].ToString();
+ var ClassRoomNo = queryParam["ClassRoomNo"].ToString();
+
+ var classRoomList = db.FindList();
+ var lessonInfoList = db.FindList();
+ var lessonInfoEntity = lessonInfoList.FirstOrDefault(x => x.LessonNo == LessonNo && x.CheckMark == true);
+ var classRoomEntity = classRoomList.FirstOrDefault(x => x.ClassroomNo == ClassRoomNo);
+
+ //成绩比例数据
+ var stuSelectLessonListOfElectiveEntity = this.BaseRepository("CollegeMIS").FindEntity(x => x.F_SchoolId == F_SchoolId && x.AcademicYearNo == AcademicYearNo && x.Semester == Semester && x.LessonNo == LessonNo && x.LessonSortNo == "2" && x.ClassRoomNo == ClassRoomNo && x.LessonSection == LessonSection);
+
+ if (stuSelectLessonListOfElectiveEntity != null)
+ {
+ //查询学生成绩数据
+ var list = GetList(queryJson).ToList();
+
+ foreach (DataColumn dc in dt.Columns)
+ {
+ failDt.Columns.Add(dc.ColumnName, dc.DataType);
+ }
+ failDt.Columns.Add("导入错误", typeof(string));
+ dt.Columns.Add("导入错误", typeof(string));
+
+ foreach (DataRow dr in dt.Rows)
+ {
+ try
+ {
+ var stuno = dr["学号"].ToString().Trim();
+ var academicYearNo_dr = dr["学年"].ToString().Trim();
+ var semester_dr = dr["学期"].ToString().Trim();
+ var lessoninfo_dr = dr["课程名称"].ToString().Trim();
+ var classRoominfo_dr = dr["教室名称"].ToString().Trim();
+ var lessonSection_dr = dr["节次"].ToString().Trim();
+ //var lessonNo_dr = lessonInfoList.FirstOrDefault(x => x.LessonName == lessoninfo_dr)?.LessonNo;
+ //var classRoomNo_dr = classRoomList.FirstOrDefault(x => x.ClassroomName == classRoominfo_dr)?.ClassroomNo;
+ if (!string.IsNullOrEmpty(stuno))
+ {
+ num++;
+ var item = list.Find(x => x.StuNo == stuno && x.LessonNo == LessonNo && x.ClassRoomNo == ClassRoomNo && x.LessonSection == LessonSection);
+ if (!academicYearNo_dr.Equals(AcademicYearNo) || !semester_dr.Equals(semester_dr))
+ {
+ dr["导入错误"] = "学年学期与查询条件不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+
+ if (!lessoninfo_dr.Equals(lessonInfoEntity.LessonName))
+ {
+ dr["导入错误"] = "课程与查询条件课程(" + lessonInfoEntity.LessonName + ")不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ if (!classRoominfo_dr.Equals(classRoomEntity.ClassroomName))
+ {
+ dr["导入错误"] = "教室与查询条件教室(" + classRoomEntity.ClassroomName + ")不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ if (!lessonSection_dr.Equals(LessonSection))
+ {
+ dr["导入错误"] = "节次与查询条件节次(" + LessonSection + ")不匹配!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ if (item == null)
+ {
+ dr["导入错误"] = "课程:" + lessonInfoEntity.LessonName + "在" + LessonSection + "节次找不到学号为" + stuno + "的学生";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ var OrdinaryScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["平时成绩"].ToString().Trim()) ? "0" : dr["平时成绩"].ToString().Trim());
+ var TermInScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["期中成绩"].ToString().Trim()) ? "0" : dr["期中成绩"].ToString().Trim());
+ var TermEndScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["期末成绩"].ToString().Trim()) ? "0" : dr["期末成绩"].ToString().Trim());
+ var OtherScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["其他成绩"].ToString().Trim()) ? "0" : dr["其他成绩"].ToString().Trim());
+ if (OrdinaryScore < 0 || TermInScore < 0 || TermEndScore < 0 || OtherScore < 0)
+ {
+ dr["导入错误"] = "成绩必须大于0!";
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+
+ var Score = Math.Round(Convert.ToDouble(OrdinaryScore * (stuSelectLessonListOfElectiveEntity.OrdinaryScoreScale / 100) +
+ TermInScore * (stuSelectLessonListOfElectiveEntity.TermInScoreScale / 100) +
+ TermEndScore * (stuSelectLessonListOfElectiveEntity.TermEndScoreScale / 100) +
+ OtherScore * (stuSelectLessonListOfElectiveEntity.OtherScoreScale / 100)), MidpointRounding.AwayFromZero);
+ var remark = dr["备注"].ToString().Trim();
+ db.ExecuteBySql($"update StuScore set OrdinaryScore={OrdinaryScore},TermInScore={TermInScore},TermEndScore={TermEndScore},OtherScore={OtherScore},Score={Score},Remark='{remark}' where ScoreId='{item.ScoreId}' ");
+ }
+ else
+ {
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ dr["导入错误"] = "出现异常:" + e.Message;
+ failDt.Rows.Add(dr.ItemArray);
+ continue;
+ }
+ }
+ db.Commit();
+
+ // 写入缓存如果有未导入的数据
+ if (failDt.Rows.Count > 0)
+ {
+ string errordt = failDt.ToJson();
+
+ cache.Write(cacheKey + fileGuid, errordt, CacheId.excel);
+ }
+
+ snum = (num - failDt.Rows.Count) > 0 ? num - failDt.Rows.Count : 0;
+ }
+ return (failDt, snum, failDt.Rows.Count);
+ }
+ catch (Exception ex)
+ {
+ db.Rollback();
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowServiceException(ex);
+ }
+ }
+ }
}
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassBLL.cs
index 06edde13f..91ed0352c 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassBLL.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassBLL.cs
@@ -442,5 +442,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
#endregion
+
+ public (DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPass(DataTable dt, string fileGuid, string queryJson)
+ {
+ try
+ {
+ return stuScoreNotPassService.ExecuteImportExcelForNotPass(dt, fileGuid, queryJson);
+ }
+ catch (Exception ex)
+ {
+ if (ex is ExceptionEx)
+ {
+ throw;
+ }
+ else
+ {
+ throw ExceptionEx.ThrowBusinessException(ex);
+ }
+ }
+ }
}
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassIBLL.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassIBLL.cs
index ad1e1472d..2dd35e90a 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassIBLL.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassIBLL.cs
@@ -124,5 +124,15 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
void SubmitStuScore(string AcademicYearNo, string Semester, string LessonNo, string TeachClassNo, string EmpNo);
#endregion
+
+
+ ///
+ /// 补考成绩导入
+ ///
+ ///
+ ///
+ ///
+ ///
+ (DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPass(DataTable dt, string fileGuid, string queryJson);
}
}
diff --git a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassService.cs b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassService.cs
index ef30a0135..c0661d558 100644
--- a/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassService.cs
+++ b/Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassService.cs
@@ -1,4 +1,6 @@
using Dapper;
+using Learun.Cache.Base;
+using Learun.Cache.Factory;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
@@ -18,6 +20,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
///