Browse Source

选修成绩录入--导入功能

新疆影视学院高职
zhangli 2 years ago
parent
commit
3f57030a69
8 changed files with 282 additions and 68 deletions
  1. +3
    -2
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs
  2. +5
    -9
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js
  3. +8
    -3
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js
  4. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexOfElectiveInTeacher.cshtml
  5. +65
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexOfElectiveInTeacher.js
  6. +11
    -2
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs
  7. +1
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs
  8. +188
    -51
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs

+ 3
- 2
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs View File

@@ -1207,13 +1207,14 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
/// <returns></returns>
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ExecuteImportExcel(string fileGuid, int chunks, string queryJson)
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);
var res = stuScoreIBLL.ExecuteImportExcel(dt, fileGuid, queryJson);
var res = stuScoreIBLL.ExecuteImportExcel(type, dt, fileGuid, queryJson);

var data = new
{
Success = res.snum,


+ 5
- 9
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacher.js View File

@@ -501,21 +501,17 @@ var bootstrap = function ($, learun) {
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;

//条件
var $content = $('body').find('.lr-layout-tool-left');
queryJson = $content.lrGetFormData();

learun.layerForm({
id: 'indexImport',
title: "导入学生成绩",
url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport',
url: top.$.rootUrl + '/EducationalAdministration/StuScore/InputScoreIndexInTeacherImport?type=1',
width: 600,
height: 400,
maxmin: true,


+ 8
- 3
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js View File

@@ -2,6 +2,7 @@
* 描 述:附件上传管理
*/
var gridId = request('gridtable');
var type = request('type');//1:成绩录入;2:选修成绩录入
var bootstrap = function ($, learun) {
"use strict";

@@ -10,6 +11,7 @@ var bootstrap = function ($, learun) {
// 触发合并文件碎片
var mergeFileChunks = function (file) {
var param = {};
param['type'] = type;
param['__RequestVerificationToken'] = $.lrToken;
param['fileGuid'] = fileInfo[file.id].fileGuid;
param['fileName'] = fileInfo[file.id].name;
@@ -31,7 +33,7 @@ var bootstrap = function ($, learun) {
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);
@@ -80,12 +82,15 @@ var bootstrap = function ($, learun) {
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 = "选修成绩录入数据";
learun.download({
method: "POST",
url: '/EducationalAdministration/StuScore/ExportExcel',
param: {
fileName: '成绩录入数据',
fileName: fileName,
columnJson: columnJson,
dataJson: rowJson,
//exportField: String(exportField)


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexOfElectiveInTeacher.cshtml View File

@@ -92,6 +92,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>



+ 65
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexOfElectiveInTeacher.js View File

@@ -15,6 +15,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
var rowJson;
var columnJson;
var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -467,6 +470,68 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScore/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});

//导入
$("#lr_importScore").on("click", function () {
var query = judgeSelect();
if (query) {
//判断成绩比例是否合理
var OrdinaryScoreScale = $('#OrdinaryScoreScale').html();
var TermInScoreScale = $('#TermInScoreScale').html();
var TermEndScoreScale = $('#TermEndScoreScale').html();
var OtherScoreScale = $('#OtherScoreScale').html();
var totalScale = Number(OrdinaryScoreScale) + Number(TermInScoreScale) + Number(TermEndScoreScale) + Number(OtherScoreScale);
if (totalScale !== 100) {
learun.alert.warning("成绩比例设置不合理!");
return false;
} else {
//判断是否已审核;判断是否被其他教师占用
$.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScore/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
if (data != null) {
if (data.CheckMark == 1) {
learun.alert.warning("学生成绩已审核!");
return false;
}
if (data.IsEditable == 0) {
if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
modifyDate = data.ModifyDate;
} else {
learun.alert.warning("当前班级成绩由账号为" + data.EditUserId + "的教师在使用!");
return false;
}
}

//列表数据
rowJson = $('#gridtable').jfGridGet('showData');
//列头
columnJson = $('#gridtable').jfGridGet('settingInfo').headData;

//条件
var $content = $('body').find('.lr-layout-tool-left');
queryJson = $content.lrGetFormData();

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

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


+ 11
- 2
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreBLL.cs View File

@@ -1090,11 +1090,20 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson)

/// <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(dt, fileGuid, queryJson);
return stuScoreService.ExecuteImportExcel(type,dt, fileGuid, queryJson);

}
catch (Exception ex)


+ 1
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreIBLL.cs View File

@@ -251,7 +251,7 @@ 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);
(DataTable failDt, int snum, int fnum) ExecuteImportExcel(int type, DataTable dt, string fileGuid, string queryJson);

#endregion



+ 188
- 51
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs View File

@@ -2172,11 +2172,35 @@ 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>
public (DataTable failDt, int snum, int fnum) ExecuteImportExcel(DataTable dt, string fileGuid, string queryJson)
private (DataTable failDt, int snum, int fnum) ExecuteImportExcelForRequired(DataTable dt, string fileGuid, string queryJson)
{
int snum = 0;
int fnum = 0;
@@ -2185,6 +2209,9 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
try
{
db.BeginTrans();
// 创建一个datatable容器用于保存导入失败的数据
DataTable failDt = new DataTable();

var queryParam = queryJson.ToJObject();
var F_SchoolId = queryParam["F_SchoolId"].ToString();
var AcademicYearNo = queryParam["AcademicYearNo"].ToString();
@@ -2193,70 +2220,181 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
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)
if (classInfoEntity != null)
{
try
//获取成绩比例数据
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 stuno = dr["学号"].ToString().Trim();
if (!string.IsNullOrEmpty(stuno))
//当前班级学生成绩
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)
{
var item = list.Find(x => x.StuNo == stuno);
if (item == null)
try
{
fnum++;
dr["导入错误"] = classInfoEntity.ClassName + "找不到学号为" + stuno + "的学生";
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;
}
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
db.Commit();

// 写入缓存如果有未导入的数据
if (failDt.Rows.Count > 0)
{
break;
string errordt = failDt.ToJson();

cache.Write<string>(cacheKey + fileGuid, errordt, CacheId.excel);
}
}
catch (Exception e)
{
dr["导入错误"] = "出现异常:" + e.Message;
failDt.Rows.Add(dr.ItemArray);
continue;
snum = list.Count - failDt.Rows.Count;
}
}
db.Commit();

// 写入缓存如果有未导入的数据
if (failDt.Rows.Count > 0)
return (failDt, snum, failDt.Rows.Count);
}
catch (Exception ex)
{
db.Rollback();
if (ex is ExceptionEx)
{
string errordt = failDt.ToJson();

cache.Write<string>(cacheKey + fileGuid, errordt, CacheId.excel);
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 fnum = 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();

snum = list.Count - failDt.Rows.Count;
//成绩比例数据
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();
if (!string.IsNullOrEmpty(stuno))
{
var item = list.Find(x => x.StuNo == stuno);
if (item == null)
{
fnum++;
dr["导入错误"] = "当前课程在" + 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());
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 = list.Count - failDt.Rows.Count;
}
return (failDt, snum, failDt.Rows.Count);
}
catch (Exception ex)
@@ -2273,6 +2411,5 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
}
}


}
}

Loading…
Cancel
Save