@@ -1,4 +1,5 @@ | |||||
using Hangfire; | using Hangfire; | ||||
using Learun.Application.Base.SystemModule; | |||||
using Learun.Application.Organization; | using Learun.Application.Organization; | ||||
using Learun.Application.TwoDevelopment.EducationalAdministration; | using Learun.Application.TwoDevelopment.EducationalAdministration; | ||||
using Learun.Util; | using Learun.Util; | ||||
@@ -25,6 +26,9 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); | private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL(); | ||||
private CdMajorIBLL cdMajorIBLL = new CdMajorBLL(); | private CdMajorIBLL cdMajorIBLL = new CdMajorBLL(); | ||||
private UserIBLL userIBLL = new UserBLL(); | private UserIBLL userIBLL = new UserBLL(); | ||||
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL(); | |||||
private StuScoreNotPassIBLL stuScoreNotPassIBLL = new StuScoreNotPassBLL(); | |||||
private StuScoreNotPassTwoIBLL stuScoreNotPassTwoIBLL = new StuScoreNotPassTwoBLL(); | |||||
#region 视图功能 | #region 视图功能 | ||||
@@ -192,6 +196,16 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
{ | { | ||||
return View(); | return View(); | ||||
} | } | ||||
/// <summary> | |||||
/// 成绩录入导入 | |||||
/// <summary> | |||||
/// <returns></returns> | |||||
[HttpGet] | |||||
public ActionResult InputScoreIndexInTeacherImport() | |||||
{ | |||||
return View(); | |||||
} | |||||
#endregion | #endregion | ||||
#region 获取数据 | #region 获取数据 | ||||
@@ -205,8 +219,16 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
public ActionResult GetList(string queryJson) | public ActionResult GetList(string queryJson) | ||||
{ | { | ||||
var data = stuScoreIBLL.GetList(queryJson).OrderBy(a => a.StuNo); | var data = stuScoreIBLL.GetList(queryJson).OrderBy(a => a.StuNo); | ||||
return Success(data); | |||||
var jsonData = new | |||||
{ | |||||
rows = data, | |||||
total = 1, | |||||
page = 1, | |||||
records = data.Count() | |||||
}; | |||||
return Success(jsonData); | |||||
} | } | ||||
[HttpGet] | [HttpGet] | ||||
[AjaxOnly] | [AjaxOnly] | ||||
public ActionResult GetMonitorList(string queryJson) | public ActionResult GetMonitorList(string queryJson) | ||||
@@ -738,7 +760,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
{ | { | ||||
data = data.OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo); | data = data.OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonNo); | ||||
} | } | ||||
return Success(data); | return Success(data); | ||||
} | } | ||||
@@ -1072,6 +1094,89 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers | |||||
return Success("操作成功"); | 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 | #endregion | ||||
} | } | ||||
} | } |
@@ -89,6 +89,7 @@ | |||||
<a id="lr_check" class="btn btn-default"><i class="fa fa-lock"> 提交教务处</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_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_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> | ||||
</div> | </div> | ||||
@@ -15,6 +15,9 @@ var headData; //常规列头 | |||||
var headDataEdit; //可编辑列头 | var headDataEdit; //可编辑列头 | ||||
var headDataNoEdit; //不可编辑列头 | var headDataNoEdit; //不可编辑列头 | ||||
var headDataFinally; //最终列头 | var headDataFinally; //最终列头 | ||||
var rowJson; | |||||
var columnJson; | |||||
var queryJson; | |||||
var bootstrap = function ($, learun) { | var bootstrap = function ($, learun) { | ||||
"use strict"; | "use strict"; | ||||
var page = { | 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) { }); | 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 () { | bindSelect: function () { | ||||
//校区 | //校区 | ||||
@@ -503,7 +563,7 @@ var bootstrap = function ($, learun) { | |||||
url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetList', | url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetList', | ||||
headData: headDataFinally, | headData: headDataFinally, | ||||
mainId: 'ScoreId', | mainId: 'ScoreId', | ||||
isPage: false, | |||||
isPage: true, | |||||
sidx: 'StuNo', | sidx: 'StuNo', | ||||
sord: 'asc' | sord: 'asc' | ||||
}); | }); | ||||
@@ -89,6 +89,7 @@ | |||||
<a id="lr_check" class="btn btn-default"><i class="fa fa-lock"> 提交教务处</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_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_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> | ||||
</div> | </div> | ||||
@@ -15,6 +15,9 @@ var headData; //常规列头 | |||||
var headDataEdit; //可编辑列头 | var headDataEdit; //可编辑列头 | ||||
var headDataNoEdit; //不可编辑列头 | var headDataNoEdit; //不可编辑列头 | ||||
var headDataFinally; //最终列头 | var headDataFinally; //最终列头 | ||||
var rowJson; | |||||
var columnJson; | |||||
var queryJson; | |||||
var bootstrap = function ($, learun) { | var bootstrap = function ($, learun) { | ||||
"use strict"; | "use strict"; | ||||
var page = { | 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) { }); | 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 () { | bindSelect: function () { | ||||
//校区 | //校区 | ||||
@@ -504,7 +564,7 @@ var bootstrap = function ($, learun) { | |||||
url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetList', | url: top.$.rootUrl + '/EducationalAdministration/StuScore/GetList', | ||||
headData: headDataFinally, | headData: headDataFinally, | ||||
mainId: 'ScoreId', | mainId: 'ScoreId', | ||||
isPage: false, | |||||
isPage: true, | |||||
sidx: 'StuNo', | sidx: 'StuNo', | ||||
sord: 'asc' | sord: 'asc' | ||||
}); | }); | ||||
@@ -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(); | |||||
} |
@@ -89,6 +89,7 @@ | |||||
<a id="lr_save" class="btn btn-default" style="display:none;"><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_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_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> | ||||
</div> | </div> | ||||
@@ -15,6 +15,9 @@ var headData; //常规列头 | |||||
var headDataEdit; //可编辑列头 | var headDataEdit; //可编辑列头 | ||||
var headDataNoEdit; //不可编辑列头 | var headDataNoEdit; //不可编辑列头 | ||||
var headDataFinally; //最终列头 | var headDataFinally; //最终列头 | ||||
var rowJson; | |||||
var columnJson; | |||||
var queryJson; | |||||
var bootstrap = function ($, learun) { | var bootstrap = function ($, learun) { | ||||
"use strict"; | "use strict"; | ||||
var page = { | 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) { }); | 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 () { | bindSelect: function () { | ||||
//校区 | //校区 | ||||
@@ -89,6 +89,7 @@ | |||||
<a id="lr_save" class="btn btn-default" style="display:none;"><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_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_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> | ||||
</div> | </div> | ||||
@@ -15,6 +15,9 @@ var headData; //常规列头 | |||||
var headDataEdit; //可编辑列头 | var headDataEdit; //可编辑列头 | ||||
var headDataNoEdit; //不可编辑列头 | var headDataNoEdit; //不可编辑列头 | ||||
var headDataFinally; //最终列头 | var headDataFinally; //最终列头 | ||||
var rowJson; | |||||
var columnJson; | |||||
var queryJson; | |||||
var bootstrap = function ($, learun) { | var bootstrap = function ($, learun) { | ||||
"use strict"; | "use strict"; | ||||
var page = { | 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) { }); | 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 () { | bindSelect: function () { | ||||
//校区 | //校区 | ||||
@@ -91,6 +91,7 @@ | |||||
<a id="lr_save" class="btn btn-default" style="display:none;"><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_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_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> | ||||
</div> | </div> | ||||
@@ -15,6 +15,10 @@ var headData; //常规列头 | |||||
var headDataEdit; //可编辑列头 | var headDataEdit; //可编辑列头 | ||||
var headDataNoEdit; //不可编辑列头 | var headDataNoEdit; //不可编辑列头 | ||||
var headDataFinally; //最终列头 | var headDataFinally; //最终列头 | ||||
var rowJson; | |||||
var columnJson; | |||||
var queryJson; | |||||
var bootstrap = function ($, learun) { | var bootstrap = function ($, learun) { | ||||
"use strict"; | "use strict"; | ||||
var page = { | 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) { }); | 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 () { | bindSelect: function () { | ||||
//校区 | //校区 | ||||
@@ -89,6 +89,7 @@ | |||||
<a id="lr_save" class="btn btn-default" style="display:none;"><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_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_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> | ||||
</div> | </div> | ||||
@@ -15,6 +15,10 @@ var headData; //常规列头 | |||||
var headDataEdit; //可编辑列头 | var headDataEdit; //可编辑列头 | ||||
var headDataNoEdit; //不可编辑列头 | var headDataNoEdit; //不可编辑列头 | ||||
var headDataFinally; //最终列头 | var headDataFinally; //最终列头 | ||||
var rowJson; | |||||
var columnJson; | |||||
var queryJson; | |||||
var bootstrap = function ($, learun) { | var bootstrap = function ($, learun) { | ||||
"use strict"; | "use strict"; | ||||
var page = { | 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) { }); | 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 () { | bindSelect: function () { | ||||
//校区 | //校区 | ||||
@@ -1369,6 +1369,7 @@ | |||||
<Content Include="Areas\EducationalAdministration\Views\StuScoreNotPass\InputScoreIndex.js" /> | <Content Include="Areas\EducationalAdministration\Views\StuScoreNotPass\InputScoreIndex.js" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuScoreNotPass\Monitor.js" /> | <Content Include="Areas\EducationalAdministration\Views\StuScoreNotPass\Monitor.js" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuScore\AllStuScoreQueryIndex.js" /> | <Content Include="Areas\EducationalAdministration\Views\StuScore\AllStuScoreQueryIndex.js" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexInTeacherImport.js" /> | |||||
<Content Include="Areas\EducationalAdministration\Views\StuScore\StuScoreQueryIndex.js" /> | <Content Include="Areas\EducationalAdministration\Views\StuScore\StuScoreQueryIndex.js" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexOfElectiveInTeacher.js" /> | <Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexOfElectiveInTeacher.js" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexOfElective.js" /> | <Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexOfElective.js" /> | ||||
@@ -8101,6 +8102,7 @@ | |||||
<Content Include="Areas\EducationalAdministration\Views\StuTransferInfo\QueryAPStuHealthIndex.cshtml" /> | <Content Include="Areas\EducationalAdministration\Views\StuTransferInfo\QueryAPStuHealthIndex.cshtml" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuTransferInfo\QueryStuEncourgementIndex.cshtml" /> | <Content Include="Areas\EducationalAdministration\Views\StuTransferInfo\QueryStuEncourgementIndex.cshtml" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuLeaveManagement\FormView.cshtml" /> | <Content Include="Areas\EducationalAdministration\Views\StuLeaveManagement\FormView.cshtml" /> | ||||
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexInTeacherImport.cshtml" /> | |||||
<None Include="Properties\PublishProfiles\CustomProfile.pubxml" /> | <None Include="Properties\PublishProfiles\CustomProfile.pubxml" /> | ||||
<None Include="Properties\PublishProfiles\FolderProfile.pubxml" /> | <None Include="Properties\PublishProfiles\FolderProfile.pubxml" /> | ||||
<Content Include="Views\Login\Default-beifen.cshtml" /> | <Content Include="Views\Login\Default-beifen.cshtml" /> | ||||
@@ -3,6 +3,8 @@ using System; | |||||
using System.Data; | using System.Data; | ||||
using System.Collections.Generic; | using System.Collections.Generic; | ||||
using static Learun.Application.TwoDevelopment.EducationalAdministration.StuScoreService; | using static Learun.Application.TwoDevelopment.EducationalAdministration.StuScoreService; | ||||
using Learun.Cache.Base; | |||||
using Learun.Cache.Factory; | |||||
namespace Learun.Application.TwoDevelopment.EducationalAdministration | namespace Learun.Application.TwoDevelopment.EducationalAdministration | ||||
{ | { | ||||
@@ -17,6 +19,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
{ | { | ||||
private StuScoreService stuScoreService = new StuScoreService(); | private StuScoreService stuScoreService = new StuScoreService(); | ||||
#region 缓存定义 | |||||
private ICache cache = CacheFactory.CaChe(); | |||||
private string cacheKey = "Learun_adms_excelError_"; | |||||
#endregion | |||||
#region 获取数据 | #region 获取数据 | ||||
/// <summary> | /// <summary> | ||||
@@ -1074,5 +1081,33 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
} | } | ||||
#endregion | #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); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |
@@ -250,6 +250,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
void DoCheckScore(string queryJson, int checkMark); | void DoCheckScore(string queryJson, int checkMark); | ||||
#endregion | #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); | IEnumerable<WebHelper.YearGrade> GetLessonNoDataFromStuNo(string academicYearNo, string semester, string stuNo); | ||||
void UpEmpNos(string xn, string xq, string classNo, string LessonNo, string EmpNo, string HisEmpNo, string Grade); | void UpEmpNos(string xn, string xq, string classNo, string LessonNo, string EmpNo, string HisEmpNo, string Grade); | ||||
@@ -9,6 +9,8 @@ using System.Net.Http; | |||||
using System.Text; | using System.Text; | ||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using Newtonsoft.Json; | using Newtonsoft.Json; | ||||
using Learun.Cache.Base; | |||||
using Learun.Cache.Factory; | |||||
namespace Learun.Application.TwoDevelopment.EducationalAdministration | namespace Learun.Application.TwoDevelopment.EducationalAdministration | ||||
{ | { | ||||
@@ -21,6 +23,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
/// </summary> | /// </summary> | ||||
public class StuScoreService : RepositoryFactory | public class StuScoreService : RepositoryFactory | ||||
{ | { | ||||
#region 缓存定义 | |||||
private ICache cache = CacheFactory.CaChe(); | |||||
private string cacheKey = "Learun_adms_excelError_"; | |||||
#endregion | |||||
#region 构造函数和属性 | #region 构造函数和属性 | ||||
private string fieldSql; | private string fieldSql; | ||||
@@ -1991,5 +1998,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,24 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
} | } | ||||
} | } | ||||
#endregion | #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,15 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
void SubmitStuScore(string AcademicYearNo, string Semester, string LessonNo, string TeachClassNo, string EmpNo); | void SubmitStuScore(string AcademicYearNo, string Semester, string LessonNo, string TeachClassNo, string EmpNo); | ||||
#endregion | #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 Dapper; | ||||
using Learun.Cache.Base; | |||||
using Learun.Cache.Factory; | |||||
using Learun.DataBase.Repository; | using Learun.DataBase.Repository; | ||||
using Learun.Util; | using Learun.Util; | ||||
using System; | using System; | ||||
@@ -18,6 +20,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
/// </summary> | /// </summary> | ||||
public class StuScoreNotPassService : RepositoryFactory | public class StuScoreNotPassService : RepositoryFactory | ||||
{ | { | ||||
#region 缓存定义 | |||||
private ICache cache = CacheFactory.CaChe(); | |||||
private string cacheKey = "Learun_adms_excelError_"; | |||||
#endregion | |||||
#region 构造函数和属性 | #region 构造函数和属性 | ||||
private string fieldSql; | private string fieldSql; | ||||
@@ -427,7 +434,7 @@ else CONVERT(varchar,a.Score) end as Score2 "); | |||||
select a.* from | select a.* from | ||||
StuScore a | StuScore a | ||||
left join StuInfoBasic b on b.StuNo=a.StuNo | left join StuInfoBasic b on b.StuNo=a.StuNo | ||||
where a.LessonSortNo='1' and b.AbmormityMoveMark <> '1' | |||||
where a.LessonSortNo='1' and (b.AbmormityMoveMark<>'1' or len(b.AbmormityMoveMark)=0 or b.AbmormityMoveMark is null) | |||||
and ( (a.Score >= 0 and a.Score<60) or a.Score=(-5) or a.Score=(-10) ) | and ( (a.Score >= 0 and a.Score<60) or a.Score=(-5) or a.Score=(-10) ) | ||||
and a.StuNo not in ( | and a.StuNo not in ( | ||||
select StuNo from StuScoreNotPass p where p.AcademicYearNo=a.AcademicYearNo and p.Semester=a.Semester and p.LessonNo=a.LessonNo and p.TeachClassNo=a.TeachClassNo and p.LessonSortNo=a.LessonSortNo and p.OpenLessonDeptNo=a.OpenLessonDeptNo and p.OpenLessonMajorNo=a.OpenLessonMajorNo | select StuNo from StuScoreNotPass p where p.AcademicYearNo=a.AcademicYearNo and p.Semester=a.Semester and p.LessonNo=a.LessonNo and p.TeachClassNo=a.TeachClassNo and p.LessonSortNo=a.LessonSortNo and p.OpenLessonDeptNo=a.OpenLessonDeptNo and p.OpenLessonMajorNo=a.OpenLessonMajorNo | ||||
@@ -489,7 +496,7 @@ order by bb.ScoreId"; | |||||
var strSql = new StringBuilder(); | var strSql = new StringBuilder(); | ||||
strSql.Append("select distinct s.LessonNo as value,s.LessonName as text from StuScoreNotPass s "); | strSql.Append("select distinct s.LessonNo as value,s.LessonName as text from StuScoreNotPass s "); | ||||
strSql.Append(" left join LessonInfo l on s.LessonNo=l.LessonNo left join CdLessonType t on l.LessonTypeId=t.LTId "); | strSql.Append(" left join LessonInfo l on s.LessonNo=l.LessonNo left join CdLessonType t on l.LessonTypeId=t.LTId "); | ||||
strSql.Append(" where s.LessonSortNo='1' and t.LessonTypeCode='OpenLesson' "); | |||||
strSql.Append(" where s.LessonSortNo='1' "); | |||||
if (userType == "教师") | if (userType == "教师") | ||||
{ | { | ||||
strSql.Append(" and s.EmpNo='" + userAccount + "' "); | strSql.Append(" and s.EmpNo='" + userAccount + "' "); | ||||
@@ -767,5 +774,138 @@ order by bb.ScoreId"; | |||||
#endregion | #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,25 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
#endregion | #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,14 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
#endregion | #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 Dapper; | ||||
using Learun.Cache.Base; | |||||
using Learun.Cache.Factory; | |||||
using Learun.DataBase.Repository; | using Learun.DataBase.Repository; | ||||
using Learun.Util; | using Learun.Util; | ||||
using System; | using System; | ||||
@@ -18,6 +20,11 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration | |||||
/// </summary> | /// </summary> | ||||
public class StuScoreNotPassTwoService : RepositoryFactory | public class StuScoreNotPassTwoService : RepositoryFactory | ||||
{ | { | ||||
#region 缓存定义 | |||||
private ICache cache = CacheFactory.CaChe(); | |||||
private string cacheKey = "Learun_adms_excelError_"; | |||||
#endregion | |||||
#region 获取数据 | #region 获取数据 | ||||
/// <summary> | /// <summary> | ||||
@@ -406,7 +413,7 @@ else CONVERT(varchar,a.Score) end as Score2 "); | |||||
select a.* from | select a.* from | ||||
StuScoreNotPass a | StuScoreNotPass a | ||||
left join StuInfoBasic b on b.StuNo=a.StuNo | left join StuInfoBasic b on b.StuNo=a.StuNo | ||||
where a.LessonSortNo='1' and b.AbmormityMoveMark <> '1' | |||||
where a.LessonSortNo='1' and (b.AbmormityMoveMark<>'1' or len(b.AbmormityMoveMark)=0 or b.AbmormityMoveMark is null) | |||||
and ( (a.Score >= 0 and a.Score<60) or a.Score=(-5) or a.Score=(-10) ) | and ( (a.Score >= 0 and a.Score<60) or a.Score=(-5) or a.Score=(-10) ) | ||||
and a.StuNo not in ( | and a.StuNo not in ( | ||||
select StuNo from StuScoreNotPassTwo p where p.AcademicYearNo=a.AcademicYearNo and p.Semester=a.Semester and p.LessonNo=a.LessonNo and p.TeachClassNo=a.TeachClassNo and p.LessonSortNo=a.LessonSortNo and p.OpenLessonDeptNo=a.OpenLessonDeptNo and p.OpenLessonMajorNo=a.OpenLessonMajorNo | select StuNo from StuScoreNotPassTwo p where p.AcademicYearNo=a.AcademicYearNo and p.Semester=a.Semester and p.LessonNo=a.LessonNo and p.TeachClassNo=a.TeachClassNo and p.LessonSortNo=a.LessonSortNo and p.OpenLessonDeptNo=a.OpenLessonDeptNo and p.OpenLessonMajorNo=a.OpenLessonMajorNo | ||||
@@ -465,7 +472,7 @@ order by bb.ScoreId"; | |||||
var strSql = new StringBuilder(); | var strSql = new StringBuilder(); | ||||
strSql.Append("select distinct s.LessonNo as value,s.LessonName as text from StuScoreNotPassTwo s "); | strSql.Append("select distinct s.LessonNo as value,s.LessonName as text from StuScoreNotPassTwo s "); | ||||
strSql.Append(" left join LessonInfo l on s.LessonNo=l.LessonNo left join CdLessonType t on l.LessonTypeId=t.LTId "); | strSql.Append(" left join LessonInfo l on s.LessonNo=l.LessonNo left join CdLessonType t on l.LessonTypeId=t.LTId "); | ||||
strSql.Append(" where s.LessonSortNo='1' and t.LessonTypeCode='OpenLesson' "); | |||||
strSql.Append(" where s.LessonSortNo='1' "); | |||||
if (userType == "教师") | if (userType == "教师") | ||||
{ | { | ||||
strSql.Append(" and s.EmpNo='" + userAccount + "' "); | strSql.Append(" and s.EmpNo='" + userAccount + "' "); | ||||
@@ -742,5 +749,141 @@ order by bb.ScoreId"; | |||||
#endregion | #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); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |