2.成绩录入界面和导入模板备注字段改为考试类型娄底高职分支
@@ -1,4 +1,5 @@ | |||
using Hangfire; | |||
using Learun.Application.Base.SystemModule; | |||
using Learun.Application.Organization; | |||
using Learun.Application.TwoDevelopment.EducationalAdministration; | |||
using Learun.Util; | |||
@@ -26,6 +27,9 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); | |||
private CdMajorIBLL cdMajorIBLL = new CdMajorBLL(); | |||
private UserIBLL userIBLL = new UserBLL(); | |||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | |||
private StuScoreNotPassIBLL stuScoreNotPassIBLL = new StuScoreNotPassBLL(); | |||
private StuScoreNotPassTwoIBLL stuScoreNotPassTwoIBLL = new StuScoreNotPassTwoBLL(); | |||
private EADateArrangeIBLL eADateArrangeIBLL = new EADateArrangeBLL(); | |||
#region 视图功能 | |||
@@ -249,6 +253,15 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||
ViewBag.WebApi = ConfigurationManager.AppSettings["WebApi"]; | |||
return View(); | |||
} | |||
/// <summary> | |||
/// 成绩录入导入 | |||
/// <summary> | |||
/// <returns></returns> | |||
[HttpGet] | |||
public ActionResult InputScoreIndexInTeacherImport() | |||
{ | |||
return View(); | |||
} | |||
#endregion | |||
#region 获取数据 | |||
@@ -1134,6 +1147,90 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||
return Success("操作成功"); | |||
} | |||
#endregion | |||
#region 成绩录入--导入 | |||
/// <summary> | |||
/// 成绩导入---下载导入模板 | |||
/// </summary> | |||
/// <param name="fileName"></param> | |||
/// <param name="columnJson">表头</param> | |||
/// <param name="dataJson">列表数据</param> | |||
[HttpPost, ValidateInput(false)] | |||
public void ExportExcel(string fileName, string columnJson, string dataJson) | |||
{ | |||
//设置导出格式 | |||
ExcelConfig excelconfig = new ExcelConfig(); | |||
//excelconfig.Title = Server.UrlDecode(fileName); | |||
excelconfig.TitleFont = "微软雅黑"; | |||
excelconfig.TitlePoint = 15; | |||
excelconfig.FileName = Server.UrlDecode(fileName) + ".xls"; | |||
excelconfig.IsAllSizeColumn = true; | |||
excelconfig.ColumnEntity = new List<ColumnModel>(); | |||
//表头 | |||
List<jfGridModel> columnList = columnJson.ToList<jfGridModel>(); | |||
//行数据 | |||
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); | |||
} | |||
/// <summary> | |||
/// 成绩导入 | |||
/// </summary> | |||
/// <param name="type">1必修;2选修;3补考成绩;4二次补考成绩</param> | |||
/// <param name="fileGuid"></param> | |||
/// <param name="chunks"></param> | |||
/// <param name="queryJson"></param> | |||
/// <returns></returns> | |||
[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 | |||
} | |||
} |
@@ -83,12 +83,13 @@ | |||
<div class="btn-group btn-group-sm"> | |||
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a> | |||
</div> | |||
<div class=" btn-group btn-group-sm" learun-authorize="yes"> | |||
<div class=" btn-group btn-group-sm"> | |||
<a id="lr_input" class="btn btn-default"><i class="fa fa-edit"> 开始录入</i></a> | |||
<a id="lr_save" class="btn btn-default" style="display:none;"><i class="fa fa-edit"> 提交成绩</i></a> | |||
<a id="lr_check" class="btn btn-default"><i class="fa fa-lock"> 提交教务处</i></a> | |||
<a id="lr_uncheck" class="btn btn-default"><i class="fa fa-lock"> 去审核成绩</i></a> | |||
<a id="lr_setScale" class="btn btn-default"><i class="fa fa-edit"> 设置成绩比例</i></a> | |||
<a id="lr_importScore" class="btn btn-default"><i class="fa fa-edit"> 导入</i></a> | |||
</div> | |||
</div> | |||
@@ -175,7 +175,7 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: '总成绩', name: 'Score', width: 80, align: "left" }, | |||
{ | |||
label: '备注', name: 'Remark', width: 100, align: "left", | |||
label: '考试类型', name: 'Remark', width: 100, align: "left", | |||
edit: { | |||
type: 'input', | |||
} | |||
@@ -196,7 +196,7 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: '总成绩', name: 'Score', width: 80, align: "left" }, | |||
{ | |||
label: '备注', name: 'Remark', width: 100, align: "left" | |||
label: '考试类型', name: 'Remark', width: 100, align: "left" | |||
}, | |||
]; | |||
headDataFinally = headData.concat(headDataNoEdit); | |||
@@ -467,6 +467,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 () { | |||
//校区 | |||
@@ -625,10 +682,10 @@ var bootstrap = function ($, learun) { | |||
} | |||
}; | |||
judgeSelect = function () { | |||
if (CanInputFlag != "True") { | |||
top.learun.layerConfirm('当前时间不是成绩录入时间!', function (res) { }); | |||
return false; | |||
} | |||
//if (CanInputFlag != "True") { | |||
// top.learun.layerConfirm('当前时间不是成绩录入时间!', function (res) { }); | |||
// return false; | |||
//} | |||
var $content = $('body').find('.lr-layout-tool-left'); | |||
var query = $content.lrGetFormData(); | |||
@@ -0,0 +1,27 @@ | |||
@{ | |||
ViewBag.Title = "Form"; | |||
Layout = "~/Views/Shared/_Form.cshtml"; | |||
} | |||
<link href="~/Content/webuploader/webuploader.css" rel="stylesheet" /> | |||
<script src="~/Content/webuploader/webuploader.nolog.min.js"></script> | |||
@Html.AppendCssFile("/Areas/LR_SystemModule/Views/ExcelImport/ImportForm.css") | |||
@*必修成绩录入导入*@ | |||
<div class="lr-form-layout lr-form-layout-top-bottom"> | |||
<div class="lr-form-layout-header"> | |||
<div id="lr_add_file_btn"><i class="fa fa-cloud-upload"></i><span class="lrlt">上传文件</span></div> | |||
<div class="webuploader-pick" id="lr_down_file_btn"><i class="fa fa-download"></i><span class="lrlt">下载模板</span></div> | |||
</div> | |||
<div class="lr-form-layout-body"> | |||
<div class="lr-form-file-queue-wrap" id="lr_form_file_queue"> | |||
<div class="lr-form-file-queue" id="lr_form_file_queue_list"> | |||
</div> | |||
<div class="lr-form-file-queue-bg"> | |||
<h1><span class="lrlt">试试将电脑里的文件拖拽到此上传</span></h1> | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
@Html.AppendJsFile("/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('<div class="lr-msg2"><span>' + res.data.Success + '</span><span>/</span><span style="color:#b94a48;" >' + res.data.Fail + '</span></div>'); | |||
// 如果有失败 | |||
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('<div class="lr-msg"><i class="fa fa-exclamation-circle"></i></div>'); | |||
} | |||
}); | |||
} | |||
// 触发清楚文件碎片 | |||
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('<div class="lr-msg"><i class="fa fa-exclamation-circle"></i></div>'); | |||
} | |||
// 删除文件 | |||
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 = $('<div class="lr-form-file-queue-item" id="lr_filequeue_' + file.id + '" ></div>'); | |||
$item.append('<div class="lr-file-image"><img src="' + top.$.rootUrl + '/Content/images/filetype/' + file.ext + '.png"></div>'); | |||
$item.append('<span class="lr-file-name">' + file.name + '(' + learun.countFileSize(file.size) + ')</span>'); | |||
$('#lr_form_file_queue_list').append($item); | |||
}, | |||
uploadStart: function (file) { | |||
var $fileItem = $('#lr_form_file_queue_list').find('#lr_filequeue_' + file.id); | |||
$fileItem.append('<div class="lr-uploader-progress"><div class="lr-uploader-progress-bar" style="width:0%;"></div></div>'); | |||
}, | |||
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(); | |||
} |
@@ -84,11 +84,13 @@ | |||
<div class="btn-group btn-group-sm"> | |||
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a> | |||
</div> | |||
<div class=" btn-group btn-group-sm" learun-authorize="yes"> | |||
<div class=" btn-group btn-group-sm"> | |||
@*learun-authorize="yes"*@ | |||
<a id="lr_input" class="btn btn-default"><i class="fa fa-edit"> 开始录入</i></a> | |||
<a id="lr_save" class="btn btn-default" style="display:none;"><i class="fa fa-edit"> 提交成绩</i></a> | |||
<a id="lr_check" class="btn btn-default"><i class="fa fa-lock"> 提交教务处</i></a> | |||
<a id="lr_uncheck" class="btn btn-default"><i class="fa fa-lock"> 去审核成绩</i></a> | |||
<a id="lr_importScore" class="btn btn-default"><i class="fa fa-edit"> 导入</i></a> | |||
</div> | |||
</div> | |||
@@ -141,7 +141,7 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: '总成绩', name: 'Score', width: 80, align: "left" }, | |||
{ | |||
label: '备注', name: 'Remark', width: 100, align: "left", | |||
label: '考试类型', name: 'Remark', width: 100, align: "left", | |||
edit: { | |||
type: 'input', | |||
} | |||
@@ -153,7 +153,7 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: '总成绩', name: 'Score', width: 80, align: "left" }, | |||
{ | |||
label: '备注', name: 'Remark', width: 100, align: "left" | |||
label: '考试类型', name: 'Remark', width: 100, align: "left" | |||
}, | |||
]; | |||
headDataFinally = headData.concat(headDataNoEdit); | |||
@@ -366,6 +366,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 () { | |||
//校区 | |||
@@ -84,11 +84,12 @@ | |||
<div class="btn-group btn-group-sm"> | |||
<a id="lr_refresh" class="btn btn-default"><i class="fa fa-refresh"></i></a> | |||
</div> | |||
<div class=" btn-group btn-group-sm" learun-authorize="yes"> | |||
<div class=" btn-group btn-group-sm"> | |||
<a id="lr_input" class="btn btn-default"><i class="fa fa-edit"> 开始录入</i></a> | |||
<a id="lr_save" class="btn btn-default" style="display:none;"><i class="fa fa-edit"> 提交成绩</i></a> | |||
<a id="lr_check" class="btn btn-default"><i class="fa fa-lock"> 提交教务处</i></a> | |||
<a id="lr_uncheck" class="btn btn-default"><i class="fa fa-lock"> 去审核成绩</i></a> | |||
<a id="lr_importScore" class="btn btn-default"><i class="fa fa-edit"> 导入</i></a> | |||
</div> | |||
</div> | |||
@@ -141,7 +141,7 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: '总成绩', name: 'Score', width: 80, align: "left" }, | |||
{ | |||
label: '备注', name: 'Remark', width: 100, align: "left", | |||
label: '考试类型', name: 'Remark', width: 100, align: "left", | |||
edit: { | |||
type: 'input', | |||
} | |||
@@ -153,7 +153,7 @@ var bootstrap = function ($, learun) { | |||
}, | |||
{ label: '总成绩', name: 'Score', width: 80, align: "left" }, | |||
{ | |||
label: '备注', name: 'Remark', width: 100, align: "left" | |||
label: '考试类型', name: 'Remark', width: 100, align: "left" | |||
}, | |||
]; | |||
headDataFinally = headData.concat(headDataNoEdit); | |||
@@ -366,6 +366,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 () { | |||
//校区 | |||
@@ -1022,6 +1022,7 @@ | |||
<Content Include="Areas\EducationalAdministration\Views\StuInfoBasic\GraduateFeeSettle.js" /> | |||
<Content Include="Areas\EducationalAdministration\Views\StuInfoBasic\GraduateFileTransfer.js" /> | |||
<Content Include="Areas\EducationalAdministration\Views\StuInfoBasic\GraduateReturnBooks.js" /> | |||
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexInTeacherImport.js" /> | |||
<Content Include="Areas\EducationalAdministration\Views\YKTStateMent\AnalysisByMonthForStudent.js" /> | |||
<Content Include="Areas\EducationalAdministration\Views\YKTStateMent\ManageIndexTeacher.js" /> | |||
<Content Include="Areas\EducationalAdministration\Views\YKTStateMent\IndexForTeacher.js" /> | |||
@@ -7989,6 +7990,7 @@ | |||
<Content Include="Content\excel\ArrangeLessonTermImport.xls" /> | |||
<Content Include="Areas\PersonnelManagement\Views\TimeTable\ImportForm.cshtml" /> | |||
<Content Include="Areas\LR_Desktop\Views\EnrollTemplate\IndexMail.cshtml" /> | |||
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexInTeacherImport.cshtml" /> | |||
<None Include="Properties\PublishProfiles\CustomProfile.pubxml" /> | |||
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" /> | |||
<Content Include="Views\Login\Default-beifen.cshtml" /> | |||
@@ -1073,5 +1073,33 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
#endregion | |||
/// <summary> | |||
/// 成绩导入 | |||
/// </summary> | |||
/// <param name="type"></param> | |||
/// <param name="dt"></param> | |||
/// <param name="fileGuid"></param> | |||
/// <param name="queryJson"></param> | |||
/// <returns></returns> | |||
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); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -251,6 +251,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<WebHelper.YearGrade> GetLessonNoDataFromStuNo(string academicYearNo, string semester, string stuNo); | |||
} | |||
@@ -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,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
/// </summary> | |||
public class StuScoreService : RepositoryFactory | |||
{ | |||
private ICache cache = CacheFactory.CaChe(); | |||
private string cacheKey = "Learun_adms_excelError_"; | |||
#region 构造函数和属性 | |||
private string fieldSql; | |||
@@ -2125,5 +2129,329 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad | |||
/// <summary> | |||
/// 成绩导入--必修课 选修课 | |||
/// </summary> | |||
/// <param name="type">1:必修,2:选修</param> | |||
/// <param name="dt"></param> | |||
/// <param name="fileGuid"></param> | |||
/// <param name="queryJson"></param> | |||
/// <returns></returns> | |||
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); | |||
} | |||
} | |||
/// <summary> | |||
/// 导入学生成绩--必修课 | |||
/// </summary> | |||
/// <param name="dt"></param> | |||
/// <returns></returns> | |||
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<ClassInfoEntity>(); | |||
var lessonInfoList = db.FindList<LessonInfoEntity>(); | |||
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<StuSelectLessonListEntity>(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<string>(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); | |||
} | |||
} | |||
} | |||
/// <summary> | |||
/// 导入学生成绩--选修课 | |||
/// </summary> | |||
/// <param name="dt"></param> | |||
/// <returns></returns> | |||
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<ClassroomInfoEntity>(); | |||
var lessonInfoList = db.FindList<LessonInfoEntity>(); | |||
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<StuSelectLessonListOfElectiveEntity>(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<string>(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); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -442,5 +442,25 @@ 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); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -124,5 +124,13 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
void SubmitStuScore(string AcademicYearNo, string Semester, string LessonNo, string TeachClassNo, string EmpNo); | |||
#endregion | |||
/// <summary> | |||
/// 补考成绩导入 | |||
/// </summary> | |||
/// <param name="dt"></param> | |||
/// <param name="fileGuid"></param> | |||
/// <param name="queryJson"></param> | |||
/// <returns></returns> | |||
(DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPass(DataTable dt, string fileGuid, string queryJson); | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
public class StuScoreNotPassService : RepositoryFactory | |||
{ | |||
#region 缓存定义 | |||
private ICache cache = CacheFactory.CaChe(); | |||
private string cacheKey = "Learun_adms_excelError_"; | |||
#endregion | |||
#region 构造函数和属性 | |||
private string fieldSql; | |||
@@ -795,5 +802,138 @@ order by bb.ScoreId"; | |||
#endregion | |||
/// <summary> | |||
/// 导入学生成绩--补考成绩 | |||
/// </summary> | |||
/// <param name="dt"></param> | |||
/// <returns></returns> | |||
public (DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPass(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<ClassInfoEntity>(); | |||
var lessonInfoList = db.FindList<LessonInfoEntity>(); | |||
var classInfoEntity = classInfoList.FirstOrDefault(x => x.ClassNo == ClassNo); | |||
var lessonInfoEntity = lessonInfoList.FirstOrDefault(x => x.LessonNo == LessonNo && x.CheckMark == true); | |||
if (classInfoEntity != null && lessonInfoEntity != 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(); | |||
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; | |||
} | |||
var item = list.Find(x => x.StuNo == stuno && x.LessonNo == LessonNo && x.ClassNo == ClassNo); | |||
if (item == null) | |||
{ | |||
dr["导入错误"] = "课程:" + lessonInfoEntity.LessonName + ",班级:" + classInfoEntity.ClassName + "找不到学号为" + stuno + "的学生"; | |||
failDt.Rows.Add(dr.ItemArray); | |||
continue; | |||
} | |||
var TermEndScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["期末成绩"].ToString().Trim()) ? "0" : dr["期末成绩"].ToString().Trim()); | |||
if (TermEndScore < 0) | |||
{ | |||
dr["导入错误"] = "成绩必须大于0!"; | |||
failDt.Rows.Add(dr.ItemArray); | |||
continue; | |||
} | |||
var Score = Math.Round(TermEndScore, MidpointRounding.AwayFromZero); | |||
var remark = dr["备注"].ToString().Trim(); | |||
db.ExecuteBySql($"update StuScoreNotPass set TermEndScore={TermEndScore},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<string>(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); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -450,5 +450,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
#endregion | |||
public (DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPassTwo(DataTable dt, string fileGuid, string queryJson) | |||
{ | |||
try | |||
{ | |||
return stuScoreNotPassTwoService.ExecuteImportExcelForNotPassTwo(dt, fileGuid, queryJson); | |||
} | |||
catch (Exception ex) | |||
{ | |||
if (ex is ExceptionEx) | |||
{ | |||
throw; | |||
} | |||
else | |||
{ | |||
throw ExceptionEx.ThrowBusinessException(ex); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -127,5 +127,13 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||
#endregion | |||
/// <summary> | |||
/// 补考成绩导入 | |||
/// </summary> | |||
/// <param name="dt"></param> | |||
/// <param name="fileGuid"></param> | |||
/// <param name="queryJson"></param> | |||
/// <returns></returns> | |||
(DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPassTwo(DataTable dt, string fileGuid, string queryJson); | |||
} | |||
} |
@@ -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 | |||
/// </summary> | |||
public class StuScoreNotPassTwoService : RepositoryFactory | |||
{ | |||
#region 缓存定义 | |||
private ICache cache = CacheFactory.CaChe(); | |||
private string cacheKey = "Learun_adms_excelError_"; | |||
#endregion | |||
#region 获取数据 | |||
/// <summary> | |||
@@ -840,5 +847,141 @@ order by bb.ScoreId"; | |||
#endregion | |||
/// <summary> | |||
/// 导入学生成绩--补考成绩 | |||
/// </summary> | |||
/// <param name="dt"></param> | |||
/// <returns></returns> | |||
public (DataTable failDt, int snum, int fnum) ExecuteImportExcelForNotPassTwo(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<ClassInfoEntity>(); | |||
var lessonInfoList = db.FindList<LessonInfoEntity>(); | |||
var classInfoEntity = classInfoList.FirstOrDefault(x => x.ClassNo == ClassNo); | |||
var lessonInfoEntity = lessonInfoList.FirstOrDefault(x => x.LessonNo == LessonNo && x.CheckMark == true); | |||
if (classInfoEntity != null && lessonInfoEntity != 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(); | |||
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; | |||
} | |||
var item = list.Find(x => x.StuNo == stuno && x.LessonNo == LessonNo && x.ClassNo == ClassNo); | |||
if (item == null) | |||
{ | |||
dr["导入错误"] = "课程:" + lessonInfoEntity.LessonName + ",班级:" + classInfoEntity.ClassName + "找不到学号为" + stuno + "的学生"; | |||
failDt.Rows.Add(dr.ItemArray); | |||
continue; | |||
} | |||
var TermEndScore = Convert.ToDecimal(string.IsNullOrEmpty(dr["期末成绩"].ToString().Trim()) ? "0" : dr["期末成绩"].ToString().Trim()); | |||
if (TermEndScore < 0) | |||
{ | |||
dr["导入错误"] = "成绩必须大于0!"; | |||
failDt.Rows.Add(dr.ItemArray); | |||
continue; | |||
} | |||
var Score = Math.Round(TermEndScore, MidpointRounding.AwayFromZero); | |||
var remark = dr["备注"].ToString().Trim(); | |||
db.ExecuteBySql($"update StuScoreNotPassTwo set TermEndScore={TermEndScore},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<string>(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); | |||
} | |||
} | |||
} | |||
} | |||
} |