Преглед изворни кода

成绩录入--导入功能

新疆影视学院高职
zhangli пре 2 година
родитељ
комит
e84f2bd4e8
9 измењених фајлова са 605 додато и 11 уклоњено
  1. +101
    -3
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs
  2. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.cshtml
  3. +66
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js
  4. +27
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.cshtml
  5. +185
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js
  6. +2
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj
  7. +40
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs
  8. +3
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs
  9. +180
    -8
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs

+ 101
- 3
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs Прегледај датотеку

@@ -1,4 +1,5 @@
using Hangfire;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.EducationalAdministration;
using Learun.Util;
@@ -27,6 +28,8 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
private UserIBLL userIBLL = new UserBLL();
private EADateArrangeIBLL eADateArrangeIBLL = new EADateArrangeBLL();
private AnnexesFileIBLL annexesFileIBLL = new AnnexesFileBLL();


#region 视图功能

@@ -249,6 +252,18 @@ 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 获取数据
@@ -581,7 +596,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
{
var loginInfo = LoginUserInfo.Get();
var semesterAndYear = Common.GetSemesterAndYear();
var data = stuScoreIBLL.GetLessonNoDataOfAll(loginInfo.account, loginInfo.Description,semesterAndYear.AcademicYearShort,semesterAndYear.Semester);
var data = stuScoreIBLL.GetLessonNoDataOfAll(loginInfo.account, loginInfo.Description, semesterAndYear.AcademicYearShort, semesterAndYear.Semester);
foreach (var item in data)
{
item.text = string.Format("{0}({1})", item.text, item.value);
@@ -795,9 +810,9 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
var data = stuScoreIBLL.GetScoreListByStuInfo(queryJson);
if (data.Any())
{
data = data.OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x=>x.LessonSortNo).ThenBy(x => x.LessonNo);
data = data.OrderByDescending(x => x.AcademicYearNo).ThenByDescending(x => x.Semester).ThenBy(x => x.LessonSortNo).ThenBy(x => x.LessonNo);
}
return Success(data);
}

@@ -1131,6 +1146,89 @@ 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();
////写入Excel表头
//Dictionary<string, string> exportFieldMap = new Dictionary<string, string>();
//if (!string.IsNullOrEmpty(exportField))
//{
// string[] exportFields = exportField.Split(',');
// foreach (var field in exportFields)
// {
// if (!exportFieldMap.ContainsKey(field))
// {
// exportFieldMap.Add(field, "1");
// }
// }
//}

foreach (jfGridModel columnModel in columnList)
{
//if (exportFieldMap.ContainsKey(columnModel.name) || string.IsNullOrEmpty(exportField))
//{
excelconfig.ColumnEntity.Add(new ColumnModel()
{
Column = columnModel.name,
ExcelColumn = columnModel.label,
Alignment = columnModel.align,
});

// }
}
ExcelHelper.ExcelDownload(rowData, excelconfig);
}

/// <summary>
/// 成绩导入
/// </summary>
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ExecuteImportExcel(string fileGuid, int chunks, string queryJson)
{
string path = annexesFileIBLL.SaveAnnexes(fileGuid, fileGuid, chunks, LoginUserInfo.Get());
if (!string.IsNullOrEmpty(path))
{
DataTable dt = ExcelHelper.ExcelImport(path);
var res = stuScoreIBLL.ExecuteImportExcel(dt, fileGuid, queryJson);
var data = new
{
Success = res.snum,
Fail = res.failDt.Rows.Count
};
return Success(data);
}
else
{
return Fail("导入数据失败!");
}
}


#endregion

}
}

+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.cshtml Прегледај датотеку

@@ -89,6 +89,7 @@
<a id="lr_check" class="btn btn-default"><i class="fa fa-lock">&nbsp;提交教务处</i></a>
<a id="lr_uncheck" class="btn btn-default"><i class="fa fa-lock">&nbsp;去审核成绩</i></a>
<a id="lr_setScale" class="btn btn-default"><i class="fa fa-edit">&nbsp;设置成绩比例</i></a>
<a id="lr_importScore" class="btn btn-default"><i class="fa fa-edit">&nbsp;导入</i></a>
</div>
</div>



+ 66
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js Прегледај датотеку

@@ -18,6 +18,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
var rowJson;
var columnJson;
var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -469,6 +472,69 @@ 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;
}
}
var param = {};
param.F_SchoolId = $('#F_SchoolId').lrselectGet();
param.AcademicYearNo = $('#AcademicYearNo').lrselectGet();
param.Semester = $('#Semester').lrselectGet();
param.LessonNo = $('#LessonNo').lrselectGet();
param.ClassNo = $('#ClassNo').lrselectGet();

rowJson = $('#gridtable').jfGridGet('showData');
columnJson = $('#gridtable').jfGridGet('settingInfo').headData;
queryJson = param;

learun.layerForm({
id: 'indexImport',
title: "导入学生成绩",
url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport',
width: 600,
height: 400,
maxmin: true,
btn: null,
end: function () {
refreshGirdData2();
}
});
} else {
learun.alert.warning("学生成绩不存在!");
return false;
}
});
}
}


});
},
bindSelect: function () {
//校区


+ 27
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.cshtml Прегледај датотеку

@@ -0,0 +1,27 @@
@{
ViewBag.Title = "Form";
Layout = "~/Views/Shared/_Form.cshtml";
}
<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")

+ 185
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js Прегледај датотеку

@@ -0,0 +1,185 @@
/*
* 描 述:附件上传管理
*/
var gridId = request('gridtable');
var bootstrap = function ($, learun) {
"use strict";

var fileInfo = {};

// 触发合并文件碎片
var mergeFileChunks = function (file) {
var param = {};
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);

learun.download({
method: "POST",
url: '/EducationalAdministration/StuScore/ExportExcel',
param: {
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();
}

+ 2
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Learun.Application.Web.csproj Прегледај датотеку

@@ -1138,6 +1138,7 @@
<Content Include="Areas\EducationalAdministration\Views\StuScoreNotPass\InputScoreIndex.js" />
<Content Include="Areas\EducationalAdministration\Views\StuScoreNotPass\Monitor.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\InputScoreIndexOfElectiveInTeacher.js" />
<Content Include="Areas\EducationalAdministration\Views\StuScore\InputScoreIndexOfElective.js" />
@@ -7995,6 +7996,7 @@
<Content Include="Areas\EducationalAdministration\Views\MealCardRunTab\Index.cshtml" />
<Content Include="Areas\EducationalAdministration\Views\StuSubsidize\FormView.cshtml" />
<Content Include="Areas\LR_NewWorkFlow\Views\NWFProcess\MonitorIndexStatistics.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" />


+ 40
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs Прегледај датотеку

@@ -41,6 +41,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}

public DataTable GetListForExport(string queryJson)
{
try
{
return stuScoreService.GetListForExport(queryJson);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}
}
}

public IEnumerable<StuScoreEntity> GetMonitorList(string queryJson)
{
try
@@ -1070,6 +1090,26 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson)
{
try
{
return stuScoreService.ExecuteImportExcel(dt, fileGuid, queryJson);

}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowBusinessException(ex);
}

}
}

#endregion



+ 3
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs Прегледај датотеку

@@ -21,6 +21,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// <summary>
/// <returns></returns>
IEnumerable<StuScoreEntity> GetList(string queryJson);
DataTable GetListForExport(string queryJson);

IEnumerable<StuScoreEntity> GetMonitorList(string queryJson);
/// <summary>
@@ -250,6 +251,8 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// <param name="checkMark">已审核:1;未审核:0;</param>
void DoCheckScore(string queryJson, int checkMark);

(DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson);

#endregion

IEnumerable<WebHelper.YearGrade> GetLessonNoDataFromStuNo(string academicYearNo, string semester, string stuNo);


+ 180
- 8
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs Прегледај датотеку

@@ -9,6 +9,8 @@ using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Learun.Cache.Base;
using Learun.Cache.Factory;

namespace Learun.Application.TwoDevelopment.EducationalAdministration
{
@@ -79,7 +81,10 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
";
}
#endregion

#region 缓存定义
private ICache cache = CacheFactory.CaChe();
private string cacheKey = "Learun_adms_excelError_";
#endregion
#region 获取数据

public IEnumerable<StuScoreEntity> GetMonitorList(string queryJson)
@@ -188,6 +193,72 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}

public DataTable GetListForExport(string queryJson)
{
try
{
var strSql = new StringBuilder();
strSql.Append("SELECT t.*,sb.StudyModality,sb.MoveType FROM StuScore t ");
strSql.Append(" left join StuInfoBasic sb on t.StuNo=sb.StuNo ");
strSql.Append(" where 1=1 ");

//学籍异动的学生不显示
//strSql.Append(" and t.StuNo not in (select StuNo from StuInfoBasic where ChangeStatus=1) ");
//20220616改 休学的要录入成绩,退学和转校的不用
strSql.Append(" and t.StuNo not in (select StuNo from StuInfoBasicChange where StuChangeType in('04','06')) ");
var queryParam = queryJson.ToJObject();
var dp = new DynamicParameters(new { });
if (!queryParam["F_SchoolId"].IsEmpty())
{
strSql.Append(" and t.F_SchoolId=@F_SchoolId ");
dp.Add("F_SchoolId", queryParam["F_SchoolId"].ToString(), DbType.String);
}
if (!queryParam["AcademicYearNo"].IsEmpty())
{
strSql.Append(" and t.AcademicYearNo=@AcademicYearNo ");
dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
}
if (!queryParam["Semester"].IsEmpty())
{
strSql.Append(" and t.Semester=@Semester ");
dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
}
if (!queryParam["LessonNo"].IsEmpty())
{
strSql.Append(" and t.LessonNo=@LessonNo ");
dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
}
if (!queryParam["ClassNo"].IsEmpty())
{
strSql.Append(" and t.ClassNo=@ClassNo ");
dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
}
if (!queryParam["ClassRoomNo"].IsEmpty())
{
strSql.Append(" and t.ClassRoomNo=@ClassRoomNo ");
dp.Add("ClassRoomNo", queryParam["ClassRoomNo"].ToString(), DbType.String);
}
if (!queryParam["LessonSection"].IsEmpty())
{
strSql.Append(" and t.LessonSection=@LessonSection ");
dp.Add("LessonSection", queryParam["LessonSection"].ToString(), DbType.String);
}

return new DataTable(); //this.BaseRepository("CollegeMIS").FindList<StuScoreEntity>(strSql.ToString(), dp);
}
catch (Exception ex)
{
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}

/// <summary>
/// 获取列表分页数据
/// <param name="pagination">分页参数</param>
@@ -1115,7 +1186,7 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
/// 课程下拉框信息【学生成绩录入可去审核】
/// </summary>
/// <returns></returns>
public IEnumerable<WebHelper.YearGrade> GetLessonNoDataOfAll(string userAccount, string userType,string AcademicYearNo="",string Semester="")
public IEnumerable<WebHelper.YearGrade> GetLessonNoDataOfAll(string userAccount, string userType, string AcademicYearNo = "", string Semester = "")
{
try
{
@@ -1131,7 +1202,7 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
}
if (!string.IsNullOrEmpty(AcademicYearNo))
{
strSql.Append(" and s.AcademicYearNo='" + AcademicYearNo + "' and s.Semester='"+Semester+"' ");
strSql.Append(" and s.AcademicYearNo='" + AcademicYearNo + "' and s.Semester='" + Semester + "' ");
}
var data = this.BaseRepository("CollegeMIS").FindList<WebHelper.YearGrade>(strSql.ToString());
data = data.Where(x => !string.IsNullOrEmpty(x.value)).OrderBy(x => x.value);
@@ -1655,7 +1726,7 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
var classInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<ClassInfoEntity>(x => x.ClassNo == classno);
if (classInfoEntity != null)
{
this.BaseRepository("CollegeMIS").ExecuteBySql("update StuScore set IsEditable='0',EditUserId='" + loginUserInfo.account + "',BeginModifyDate='" + now + "' where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and OpenLessonDeptNo='" + classInfoEntity.DeptNo + "' and OpenLessonMajorNo='" + classInfoEntity.MajorNo + "' and LessonNo='" + LessonNo + "' and LessonSortNo='1' and ClassNo='" + classno+ "' ");
this.BaseRepository("CollegeMIS").ExecuteBySql("update StuScore set IsEditable='0',EditUserId='" + loginUserInfo.account + "',BeginModifyDate='" + now + "' where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and OpenLessonDeptNo='" + classInfoEntity.DeptNo + "' and OpenLessonMajorNo='" + classInfoEntity.MajorNo + "' and LessonNo='" + LessonNo + "' and LessonSortNo='1' and ClassNo='" + classno + "' ");
}
}
else
@@ -1765,7 +1836,7 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
}
}

}
catch (Exception ex)
{
@@ -1870,17 +1941,17 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
//教师电子成绩单
if (checkMark == 0)//撤销
{
db.ExecuteBySql("update EmpReportCard set ElectronicStatus=0,ElectronicTime=null where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and LessonNo='" + LessonNo + "' and ClassRoomNo='" + classroomno + "' and LessonSortNo='2' and LessonSection='"+ lessonsection + "'");
db.ExecuteBySql("update EmpReportCard set ElectronicStatus=0,ElectronicTime=null where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and LessonNo='" + LessonNo + "' and ClassRoomNo='" + classroomno + "' and LessonSortNo='2' and LessonSection='" + lessonsection + "'");
}
else
{
db.ExecuteBySql("update EmpReportCard set ElectronicStatus=1,ElectronicTime='" + DateTime.Now + "' where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and LessonNo='" + LessonNo + "' and classroomno='" + classroomno + "' and LessonSortNo='2' and LessonSection='"+ lessonsection + "'");
db.ExecuteBySql("update EmpReportCard set ElectronicStatus=1,ElectronicTime='" + DateTime.Now + "' where F_SchoolId='" + F_SchoolId + "' and AcademicYearNo='" + AcademicYearNo + "' and Semester='" + Semester + "' and LessonNo='" + LessonNo + "' and classroomno='" + classroomno + "' and LessonSortNo='2' and LessonSection='" + lessonsection + "'");
}
}
db.Commit();
}

}
catch (Exception ex)
{
@@ -2100,6 +2171,107 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
}
}

/// <summary>
/// 导入学生成绩
/// </summary>
/// <param name="dt"></param>
/// <returns></returns>
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson)
{
int snum = 0;
int fnum = 0;
var db = this.BaseRepository("CollegeMIS");
var msg = "";
try
{
db.BeginTrans();
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 classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == ClassNo);

//获取成绩比例数据
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);
//当前班级学生成绩
var list = GetList(queryJson).ToList();

// 创建一个datatable容器用于保存导入失败的数据
DataTable failDt = new DataTable();
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();
if (!string.IsNullOrEmpty(stuno))
{
var item = list.Find(x => x.StuNo == stuno);
if (item == null)
{
fnum++;
dr["导入错误"] = classInfoEntity.ClassName + "找不到学号为" + 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());
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 = list.Count - failDt.Rows.Count;
return (failDt, snum, failDt.Rows.Count);
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
throw;
}
else
{
throw ExceptionEx.ThrowServiceException(ex);
}
}
}


}


Loading…
Откажи
Сачувај