Ver código fonte

补考成绩、二次补考成绩录入导入功能

新疆影视学院高职^2
zhangli 1 ano atrás
pai
commit
9fe90cad7e
13 arquivos alterados com 506 adições e 11 exclusões
  1. +23
    -3
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs
  2. +8
    -2
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js
  3. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.cshtml
  4. +54
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.js
  5. +1
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.cshtml
  6. +53
    -0
      Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.js
  7. +35
    -5
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs
  8. +21
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassBLL.cs
  9. +10
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassIBLL.cs
  10. +135
    -1
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassService.cs
  11. +20
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPassTwo/StuScoreNotPassTwoBLL.cs
  12. +9
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPassTwo/StuScoreNotPassTwoIBLL.cs
  13. +136
    -0
      Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPassTwo/StuScoreNotPassTwoService.cs

+ 23
- 3
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Controllers/StuScoreController.cs Ver arquivo

@@ -23,6 +23,8 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
public class StuScoreController : MvcControllerBase
{
private StuScoreIBLL stuScoreIBLL = new StuScoreBLL();
private StuScoreNotPassIBLL stuScoreNotPassIBLL = new StuScoreNotPassBLL();
private StuScoreNotPassTwoIBLL stuScoreNotPassTwoIBLL = new StuScoreNotPassTwoBLL();
private ClassInfoIBLL classInfoIBLL = new ClassInfoBLL();
private StuInfoBasicIBLL stuInfoBasicIBLL = new StuInfoBasicBLL();
private CdMajorIBLL cdMajorIBLL = new CdMajorBLL();
@@ -544,7 +546,7 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
var loginInfo = LoginUserInfo.Get();
var semesterAndYear = Common.GetSemesterAndYear();
var data = stuScoreIBLL.GetClassNoDataForInput(loginInfo.account, loginInfo.Description, lessonNo, semesterAndYear.AcademicYearShort, semesterAndYear.Semester);
return Success(data);
}
/// <summary>
@@ -1219,6 +1221,10 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
/// <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]
@@ -1228,8 +1234,22 @@ namespace Learun.Application.Web.Areas.EducationalAdministration.Controllers
if (!string.IsNullOrEmpty(path))
{
DataTable dt = ExcelHelper.ExcelImport(path);
var res = stuScoreIBLL.ExecuteImportExcel(type, dt, fileGuid, queryJson);

(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,


+ 8
- 2
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScore/InputScoreIndexInTeacherImport.js Ver arquivo

@@ -83,9 +83,15 @@ var bootstrap = function ($, learun) {
columnJson = JSON.stringify(columnJson.filter(item => item.name !== 'CheckMark'));
var rowJson = JSON.stringify(learun.frameTab.currentIframe().rowJson);
var fileName = "成绩录入数据";
if (type == '2')
if (type == '2') {
fileName = "选修成绩录入数据";
}
else if (type == '3') {
fileName = "补考成绩录入";
}
else if (type == '4') {
fileName = "二次补考成绩录入";
}
learun.download({
method: "POST",
url: '/EducationalAdministration/StuScore/ExportExcel',


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.cshtml Ver arquivo

@@ -89,6 +89,7 @@
<a id="lr_save" class="btn btn-default" style="display:none;"><i class="fa fa-edit">&nbsp;提交成绩</i></a>
<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_importScore" class="btn btn-default"><i class="fa fa-edit">&nbsp;导入</i></a>
</div>
</div>



+ 54
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPass/InputScoreIndexInTeacher.js Ver arquivo

@@ -17,6 +17,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
var rowJson;
var columnJson;
var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -368,6 +371,57 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPass/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
//导入
$('#lr_importScore').on('click', function () {
var query = judgeSelect();
if (query) {
//成绩被占用,且是登录用户时,根据编辑时间判断是否是本人;
$.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPass/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
if (data != null) {
if (data.CheckMark == 1) {
learun.alert.warning("学生成绩已审核!");
return false;
}
if (data.IsEditable == 0) {
if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
if (modifyDate != null && modifyDate != data.ModifyDate) {
learun.alert.warning("当前班级成绩被修改,请重新获取!");
return false;
}
} 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 () {
//校区


+ 1
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.cshtml Ver arquivo

@@ -89,6 +89,7 @@
<a id="lr_save" class="btn btn-default" style="display:none;"><i class="fa fa-edit">&nbsp;提交成绩</i></a>
<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_importScore" class="btn btn-default"><i class="fa fa-edit">&nbsp;导入</i></a>
</div>
</div>



+ 53
- 0
Learun.Framework.Ultimate V7/Learun.Application.Web/Areas/EducationalAdministration/Views/StuScoreNotPassTwo/InputScoreIndexInTeacher.js Ver arquivo

@@ -17,6 +17,9 @@ var headData; //常规列头
var headDataEdit; //可编辑列头
var headDataNoEdit; //不可编辑列头
var headDataFinally; //最终列头
var rowJson;
var columnJson;
var queryJson;
var bootstrap = function ($, learun) {
"use strict";
var page = {
@@ -368,6 +371,56 @@ var bootstrap = function ($, learun) {
learun.postFormSilence(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPassTwo/AddMinutes', { queryJson: JSON.stringify(query), minutes: newMinutes }, function (res) { });
}
});
//导入
$('#lr_importScore').on('click', function () {
var query = judgeSelect();
if (query) {
//成绩被占用,且是登录用户时,根据编辑时间判断是否是本人;
$.lrSetForm(top.$.rootUrl + '/EducationalAdministration/StuScoreNotPassTwo/GetEntityByJson?queryJson=' + JSON.stringify(query), function (data) {
if (data != null) {
if (data.CheckMark == 1) {
learun.alert.warning("学生成绩已审核!");
return false;
}
if (data.IsEditable == 0) {
if (data.EditUserId == learun.clientdata.get(['userinfo']).account) {
if (modifyDate != null && modifyDate != data.ModifyDate) {
learun.alert.warning("当前班级成绩被修改,请重新获取!");
return false;
}
} 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 () {
//校区


+ 35
- 5
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScore/StuScoreService.cs Ver arquivo

@@ -2303,7 +2303,20 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
num++;
if (!academicYearNo_dr.Equals(AcademicYearNo) || !semester_dr.Equals(Semester))
{
dr["导入错误"] = "学年学期与查询条件不符!";
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;
}
@@ -2427,7 +2440,6 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
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))
@@ -2436,12 +2448,30 @@ where StuNo not in(Select StuNo from stuscore s where s.Academicyearno = sl.Acad
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["导入错误"] = "学年学期与查询条件不符!";
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 (!lessoninfo_dr.Equals(lessonInfoEntity.LessonName) || !classRoominfo_dr.Equals(classRoomEntity.ClassroomName) || !lessonSection_dr.Equals(LessonSection))
//if (item == null)
if (item == null)
{
dr["导入错误"] = "课程:" + lessonInfoEntity.LessonName + "在" + LessonSection + "节次找不到学号为" + stuno + "的学生";
failDt.Rows.Add(dr.ItemArray);


+ 21
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassBLL.cs Ver arquivo

@@ -441,6 +441,27 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
}
}

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);
}
}
}

#endregion
}
}

+ 10
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassIBLL.cs Ver arquivo

@@ -123,6 +123,16 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// <param name="EmpNo"></param>
void SubmitStuScore(string AcademicYearNo, string Semester, string LessonNo, string TeachClassNo, string EmpNo);

/// <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);

#endregion
}
}

+ 135
- 1
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPass/StuScoreNotPassService.cs Ver arquivo

@@ -1,4 +1,6 @@
using Dapper;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
@@ -76,6 +78,10 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
}
#endregion

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

/// <summary>
@@ -186,7 +192,7 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
// @" left join StuScoreNotPass ssnp on ssnp.StuNo = a.StuNo and ssnp.lessonno = a.lessonno ");
// strSql.Append(@" where 1=1 and ( ssnp.StuNo not in (select StuNo from StuInfoBasic where ChangeStatus=1) and a.LessonSortNo='1' )
// and a.LessonSortNo='1' and ((a.Score>=0 and a.Score<60) or a.Score=(-5) or a.Score=(-10)) ");
//新
strSql.Append(@"select ISNULL(ssnp.Score,0) as BKScore,ssnp.CheckMark as IsSubmit,c.classname,a.*,CONVERT(varchar,a.OrdinaryScore) as OrdinaryScore2,CONVERT(varchar,a.TermEndScore) as TermEndScore2,CONVERT(varchar,a.Score) as Score2,b.MoveType,b.StudyModality
from StuScore a
@@ -793,6 +799,134 @@ order by bb.ScoreId";
}


/// <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());
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);
}
}
}

#endregion

}


+ 20
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPassTwo/StuScoreNotPassTwoBLL.cs Ver arquivo

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


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);
}
}
}

#endregion
}
}

+ 9
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPassTwo/StuScoreNotPassTwoIBLL.cs Ver arquivo

@@ -126,6 +126,15 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
void SubmitStuScore(string AcademicYearNo, string Semester, string LessonNo, string TeachClassNo, string EmpNo);


/// <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);
#endregion
}
}

+ 136
- 0
Learun.Framework.Ultimate V7/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/EducationalAdministration/StuScoreNotPassTwo/StuScoreNotPassTwoService.cs Ver arquivo

@@ -1,4 +1,6 @@
using Dapper;
using Learun.Cache.Base;
using Learun.Cache.Factory;
using Learun.DataBase.Repository;
using Learun.Util;
using System;
@@ -18,6 +20,12 @@ namespace Learun.Application.TwoDevelopment.EducationalAdministration
/// </summary>
public class StuScoreNotPassTwoService : RepositoryFactory
{

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

#region 获取数据

/// <summary>
@@ -839,6 +847,134 @@ order by bb.ScoreId";
}


/// <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());
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);
}
}
}

#endregion
}
}

Carregando…
Cancelar
Salvar