|
@@ -16,6 +16,7 @@ using System.ComponentModel;
|
|
|
using System.Linq;
|
|
|
using System.Runtime.Intrinsics.Arm;
|
|
|
using System.Text.Json;
|
|
|
+using System.Text.RegularExpressions;
|
|
|
using System.Threading.Tasks;
|
|
|
using TEAMModelOS.Filter;
|
|
|
using TEAMModelOS.Models;
|
|
@@ -68,66 +69,140 @@ namespace TEAMModelOS.Controllers
|
|
|
//[Authorize(Roles = "IES")]
|
|
|
[AuthToken(Roles = "teacher,admin,business")]
|
|
|
[RequestSizeLimit(102_400_000_00)] //最大10000m左右
|
|
|
- public async Task<IActionResult> ReadExcelVirtue([FromForm] IFormFile file, [FromForm] string periodId) {
|
|
|
+ public async Task<IActionResult> ReadExcelVirtue([FromForm] IFormFile[] file, [FromForm] string periodId) {
|
|
|
+ var (userid, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
List<KeyValuePair<string, List<string>>> error = new List<KeyValuePair<string, List<string>>>();
|
|
|
List<KeyValuePair<string, List<string>>> warn = new List<KeyValuePair<string, List<string>>>();
|
|
|
- var (id, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ List<VirtueImport> virtueImports = new List<VirtueImport> { };
|
|
|
+ //德育数据导入
|
|
|
+ School schoolBase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new Azure.Cosmos.PartitionKey("Base"));
|
|
|
+ Period period = schoolBase.period.Find(x => x.id.Equals(periodId));
|
|
|
+ HashSet<Student> rightStudents = new HashSet<Student>();
|
|
|
+ List<Class> classes = new List<Class>();
|
|
|
+ List<Dictionary<string, object>> students = new List<Dictionary<string, object>>();
|
|
|
ExcelPackage.LicenseContext = OfficeOpenXml.LicenseContext.NonCommercial;
|
|
|
- List<VirtueImport> virtueImports = new List<VirtueImport> { };
|
|
|
- using (ExcelPackage package = new ExcelPackage(file.OpenReadStream())) {
|
|
|
- ExcelWorksheets sheet = package.Workbook.Worksheets;
|
|
|
- //德育数据导入
|
|
|
- School schoolBase = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School).ReadItemAsync<School>(school, new Azure.Cosmos.PartitionKey("Base"));
|
|
|
- Period period = schoolBase.period.Find(x => x.id.Equals(periodId));
|
|
|
- var daily_sheets = sheet.Where(z => !z.Name.Equals("栏位说明"));
|
|
|
- HashSet<IdNameCode> rightStudents = new HashSet<IdNameCode>();
|
|
|
- List<Class> classes = new List<Class>();
|
|
|
- foreach (var daily_sheet in daily_sheets)
|
|
|
+ foreach (var f in file) {
|
|
|
+ using (ExcelPackage package = new ExcelPackage(f.OpenReadStream()))
|
|
|
{
|
|
|
- if (DateTimeOffset.TryParse(daily_sheet.Name, out DateTimeOffset sheetNameTime))
|
|
|
+ ExcelWorksheets sheet = package.Workbook.Worksheets;
|
|
|
+ var daily_sheets = sheet.Where(z => !z.Name.Equals("栏位说明"));
|
|
|
+ foreach (var daily_sheet in daily_sheets)
|
|
|
{
|
|
|
-
|
|
|
var data = GetSubSheetData(daily_sheet, error);
|
|
|
- Dictionary<string, object> dailyData = new Dictionary<string, object> { { "subject", "德育" }, { "students", data.students } };
|
|
|
- ImportExamSubject importExamDaily = dailyData.ToJsonString().ToObject<ImportExamSubject>();
|
|
|
- var subject = period.subjects.Find(z => z.name.Equals(importExamDaily.subject));
|
|
|
- if (subject != null)
|
|
|
- {
|
|
|
- List<ResultImportStudent> examImportStudents = new List<ResultImportStudent>();
|
|
|
- //学生
|
|
|
- await ExamImportStudent(importExamDaily.students, rightStudents, school, period, examImportStudents, error, warn, classes, daily_sheet.Name);
|
|
|
- var semesterData= SchoolService.GetSemester(period, sheetNameTime.ToUnixTimeMilliseconds());
|
|
|
- var group = examImportStudents.GroupBy(x => x.classId).Select(y => new { key = y.Key,list= y.ToList()} );
|
|
|
- foreach (var groupData in group) {
|
|
|
- VirtueImport virtueImport = new VirtueImport
|
|
|
+ students.AddRange(data.students);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Dictionary<string, object> dailyData = new Dictionary<string, object> { { "subject", "德育" }, { "students", students } };
|
|
|
+ ImportExamSubject importExamDaily = dailyData.ToJsonString().ToObject<ImportExamSubject>();
|
|
|
+ var subject = period.subjects.Find(z => z.name.Equals(importExamDaily.subject));
|
|
|
+ if (subject != null)
|
|
|
+ {
|
|
|
+ List<ResultImportStudent> examImportStudents = new List<ResultImportStudent>();
|
|
|
+ //学生
|
|
|
+ await ExamImportStudent(importExamDaily.students, rightStudents, school, period, examImportStudents, error, warn, classes,"");
|
|
|
+ List<KeyValuePair<string , (Semester currSemester, int studyYear, DateTimeOffset date, DateTimeOffset nextSemester)>> semesterDatas = new List<KeyValuePair<string, (Semester currSemester, int studyYear, DateTimeOffset date, DateTimeOffset nextSemester)>>();
|
|
|
+ importExamDaily.students.GroupBy(x => x.time).Select(y => y.Key).ToList().ForEach(time => {
|
|
|
+ var semesterData = SchoolService.GetSemester(period, time: time);
|
|
|
+ semesterDatas.Add(new KeyValuePair<string, (Semester currSemester, int studyYear, DateTimeOffset date, DateTimeOffset nextSemester)>(time, semesterData));
|
|
|
+ });
|
|
|
+ var group = examImportStudents.GroupBy(x => new { classId = x.classId, date = x.date }).Select(y => new { key = y.Key, list = y.ToList() });
|
|
|
+ List<string> ids = new List<string>();
|
|
|
+ foreach (var groupData in group)
|
|
|
+ {
|
|
|
+ var semesterData = semesterDatas.Find(x => x.Key.Equals(groupData.key.date)).Value;
|
|
|
+ string id = $"{groupData.key.date}-{semesterData.currSemester.id}-{groupData.key.classId}";
|
|
|
+ ids.Add(id);
|
|
|
+ }
|
|
|
+ if (ids.Any()) {
|
|
|
+ string idsql = $"select value c from c where c.id in ({string.Join(",",ids.Select(z=>$"'{z}'"))}) ";
|
|
|
+ var reuslt= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<VirtueImport>(idsql, $"VirtueImport-{school}");
|
|
|
+ if (reuslt.list.IsNotEmpty()) { virtueImports.AddRange(reuslt.list); }
|
|
|
+ }
|
|
|
+ HashSet<VirtueImport> changeDataVirtueImports = new HashSet<VirtueImport>();
|
|
|
+ foreach (var groupData in group) {
|
|
|
+ var semesterData = semesterDatas.Find(x => x.Key.Equals(groupData.key.date)).Value;
|
|
|
+ string id = $"{groupData.key.date}-{semesterData.currSemester.id}-{groupData.key.classId}";
|
|
|
+ string code = $"VirtueImport-{school}";
|
|
|
+ var virtueImport = virtueImports.Find(x => x.id.Equals(id));
|
|
|
+ if (virtueImport != null)
|
|
|
+ {
|
|
|
+ groupData.list.ForEach(z => {
|
|
|
+ var student = virtueImport.students.Find(x => x.id.Equals(z.id) && x.date.Equals(z.date) && x.classId.Equals(z.classId) );
|
|
|
+ if (student != null)
|
|
|
+ {
|
|
|
+ bool hasChange=false;
|
|
|
+ //此处分数直接覆盖
|
|
|
+ if (student.items.Count == z.items.Count)
|
|
|
{
|
|
|
- time = sheetNameTime.ToUnixTimeMilliseconds(),
|
|
|
- id = $"{semesterData.studyYear}-{semesterData.currSemester.id}-{groupData.key}",
|
|
|
- code = $"VirtueImport-{school}",
|
|
|
- pk = "VirtueImport",
|
|
|
- ttl = -1,
|
|
|
- semesterId = semesterData.currSemester.id,
|
|
|
- periodId = period.id,
|
|
|
- type = "日常",
|
|
|
- school = school,
|
|
|
- year = semesterData.studyYear,
|
|
|
- classId=groupData.key,
|
|
|
- students = groupData.list,
|
|
|
- name=$"{semesterData.studyYear}-{semesterData.currSemester.name}"
|
|
|
- };
|
|
|
- virtueImports.Add(virtueImport);
|
|
|
+
|
|
|
+ //为节约导入的RU成本开销检查导入分数是否有差异.
|
|
|
+ foreach (var item in z.items)
|
|
|
+ {
|
|
|
+ var noChangeData = student.items.Find(x => x.code.Equals(item.code) && x.value==item.value );
|
|
|
+ //
|
|
|
+ if (noChangeData == null)
|
|
|
+ {
|
|
|
+ hasChange = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //两个的数量不同则是属于要修改的。
|
|
|
+ hasChange = true;
|
|
|
+ }
|
|
|
+ if (hasChange) {
|
|
|
+ student.items = z.items;
|
|
|
+ student.classId = z.classId;
|
|
|
+ student.date = z.date;
|
|
|
+ student.id = z.id;
|
|
|
+ student.stuYear = z.stuYear;
|
|
|
+ changeDataVirtueImports.Add(virtueImport);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
+ else {
|
|
|
+ changeDataVirtueImports.Add(virtueImport);
|
|
|
+ virtueImport.students.Add(z);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ virtueImport = new VirtueImport
|
|
|
{
|
|
|
- error.Add(new KeyValuePair<string, List<string>>("subject_invalid", new List<string> { importExamDaily.subject }));// 科目不存在
|
|
|
- }
|
|
|
+ id = id,
|
|
|
+ time = semesterData.date.ToUnixTimeMilliseconds(),
|
|
|
+ code = code,
|
|
|
+ pk = "VirtueImport",
|
|
|
+ ttl = -1,
|
|
|
+ semesterId = semesterData.currSemester.id,
|
|
|
+ periodId = period.id,
|
|
|
+ type = "日常",
|
|
|
+ school = school,
|
|
|
+ year = semesterData.studyYear,
|
|
|
+ classId = groupData.key.classId,
|
|
|
+ students = groupData.list,
|
|
|
+ name = $"{semesterData.studyYear}-{semesterData.currSemester.name}-{groupData.key.date}"
|
|
|
+ };
|
|
|
+ changeDataVirtueImports.Add(virtueImport);
|
|
|
+ virtueImports.Add(virtueImport);
|
|
|
}
|
|
|
- else {
|
|
|
-
|
|
|
+ }
|
|
|
+ if (changeDataVirtueImports.Any())
|
|
|
+ {
|
|
|
+ double ru = 0;
|
|
|
+ //196条数据产生RU:2341.739999999998
|
|
|
+ foreach (var virtueImport in changeDataVirtueImports) {
|
|
|
+ Azure.Cosmos.ItemResponse<VirtueImport> a = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync<VirtueImport>(virtueImport, new Azure.Cosmos.PartitionKey(virtueImport.code));
|
|
|
+ a.GetRawResponse().Headers.TryGetValue("x-ms-request-charge", out var value);
|
|
|
+ ru=ru+ Convert.ToDouble(value);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ error.Add(new KeyValuePair<string, List<string>>("subject_invalid", new List<string> { importExamDaily.subject }));// 科目不存在
|
|
|
+ }
|
|
|
return Ok(new { virtueImports, error,warn});
|
|
|
}
|
|
|
// [AuthToken(Roles = "teacher,admin")]
|
|
@@ -288,7 +363,8 @@ namespace TEAMModelOS.Controllers
|
|
|
Period period = schoolBase.period.Find(x => x.id.Equals(importExam.periodId));
|
|
|
if (validData.isVaild)
|
|
|
{
|
|
|
- string sql = $"select value c from c where c.name ='{importExam.name}'";
|
|
|
+ var semesterData = SchoolService.GetSemester(period, time: importExam.time);
|
|
|
+ string sql = $"select value c from c where c.name ='{importExam.name}' and c.periodId='{period.id}' and c.semesterId ='{semesterData.currSemester.id}' ";
|
|
|
var result = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).GetList<ExamImport>(sql, $"ExamImport-{importExam.school}", pageSize: 1);
|
|
|
|
|
|
if (string.IsNullOrEmpty(result.continuationToken))
|
|
@@ -299,31 +375,27 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
examImport = result.list[0];
|
|
|
warn.Add(new KeyValuePair<string, List<string>>("name_update", new List<string> { importExam.name }));//同名评测数据更新
|
|
|
-
|
|
|
}
|
|
|
if (examImport == null)
|
|
|
{
|
|
|
- examImport = new ExamImport { name = importExam.name, type = importExam.type, school = importExam.school,periodId=period.id,code= $"ExamImport-{importExam.school}",pk= "ExamImport", };
|
|
|
+ examImport = new ExamImport { year= semesterData.studyYear,name = importExam.name, type = importExam.type, school = importExam.school,periodId=period.id,code= $"ExamImport-{importExam.school}",pk= "ExamImport", };
|
|
|
if (DateTimeOffset.TryParse(importExam.time, out DateTimeOffset dateTime))
|
|
|
{
|
|
|
examImport.time = dateTime.ToUnixTimeMilliseconds();
|
|
|
- var semesterData= SchoolService.GetSemester(period, examImport.time);
|
|
|
+
|
|
|
examImport.semesterId = semesterData.currSemester.id;
|
|
|
- examImport.id = $"{semesterData.studyYear}-{ShaHashHelper.GetSHA1(examImport.name)}";
|
|
|
+ examImport.id = $"{semesterData.studyYear}-{ShaHashHelper.GetSHA1($"{period.id}-{semesterData.currSemester.id}-{examImport.name}")}";
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
error.Add(new KeyValuePair<string, List<string>>("time_format", new List<string> { importExam.time }));// 时间格式错误
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
if (period != null)
|
|
|
{
|
|
|
//用于处理多学科,不需要重复查询学习基础信息
|
|
|
//id 学生id code 行政班id name 学生姓名
|
|
|
- HashSet<IdNameCode> rightStudents = new HashSet<IdNameCode>();
|
|
|
+ HashSet<Student> rightStudents = new HashSet<Student>();
|
|
|
List<Class> classes = new List<Class>();
|
|
|
foreach (var item in importExam.subjects)
|
|
|
{
|
|
@@ -332,9 +404,40 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
List<ResultImportStudent> examImportStudents = new List<ResultImportStudent>();
|
|
|
//学生
|
|
|
- await ExamImportStudent(item.students, rightStudents, school, period, examImportStudents, error, warn, classes, item.subject);
|
|
|
-
|
|
|
- examImport.subjects.Add(new ExamImportSubject { id = subject.id, name = subject.name, students = examImportStudents, }) ;
|
|
|
+ await ExamImportStudent(item.students, rightStudents, school, period, examImportStudents, error, warn, classes, item.subject);
|
|
|
+ //配分
|
|
|
+ List<ExamImportItem> examImportItems = new List<ExamImportItem>();
|
|
|
+ foreach (var itemItem in item.items)
|
|
|
+ {
|
|
|
+ string[] ps = Regex.Split(itemItem.point, "\\.|\\.|\\、|\\:|\\:|\\,|\\,|\\;|\\;");
|
|
|
+ var points = ps.Distinct().ToHashSet();
|
|
|
+ ExamImportItem examImportItem = new ExamImportItem() {
|
|
|
+ point=points,
|
|
|
+ index=itemItem.index,
|
|
|
+ filed=itemItem.filed,
|
|
|
+ type=itemItem.type,
|
|
|
+ score=itemItem.score,
|
|
|
+ };
|
|
|
+ examImportItems.Add(examImportItem);
|
|
|
+ }
|
|
|
+ var examImportSubject= examImport.subjects.Find(x => x.id.Equals(subject.id));
|
|
|
+ if (examImportSubject != null)
|
|
|
+ {
|
|
|
+ examImportSubject.name = subject.name;
|
|
|
+ foreach (var stu in examImportStudents) {
|
|
|
+ var student = examImportSubject.students.Find(x => x.id.Equals(stu.id));
|
|
|
+ if (student != null)
|
|
|
+ {
|
|
|
+ student = stu;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ examImportSubject.students.Add(stu);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ examImport.subjects.Add(new ExamImportSubject { id = subject.id, name = subject.name, students = examImportStudents, items = examImportItems });
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -363,11 +466,12 @@ namespace TEAMModelOS.Controllers
|
|
|
errorData.Add(new KeyValuePair<string, HashSet<string>>(x.Key,x.Value.ToHashSet()));
|
|
|
}
|
|
|
});
|
|
|
+ await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Common).UpsertItemAsync(examImport, new Azure.Cosmos.PartitionKey(examImport.code));
|
|
|
return Ok(new { code = 400, error = errorData, examImport });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private async Task ExamImportStudent(List<ImportResultStudent> importExamStudents, HashSet<IdNameCode> rightStudents,string school,
|
|
|
+ private async Task ExamImportStudent(List<ImportResultStudent> importExamStudents, HashSet<Student> rightStudents,string school,
|
|
|
Period period, List<ResultImportStudent> examImportStudents, List<KeyValuePair<string, List<string>>> error,
|
|
|
List<KeyValuePair<string, List<string>>> warn, List<Class> classes, string sheetName)
|
|
|
{
|
|
@@ -380,8 +484,8 @@ namespace TEAMModelOS.Controllers
|
|
|
if (needSearch.Any())
|
|
|
{
|
|
|
///在rightStudents找不到的学生需要查询数据库。
|
|
|
- string stuidsql = $"select c.id,c.classId as code , c.name from c where c.id in ({string.Join(",", needSearch.Select(x => $"'{x.id}'"))}) and c.periodId='{period.id}' ";
|
|
|
- var sturesult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<IdNameCode>(stuidsql, $"Base-{school}");
|
|
|
+ string stuidsql = $"select value c from c where c.id in ({string.Join(",", needSearch.Select(x => $"'{x.id}'"))}) and c.periodId='{period.id}' ";
|
|
|
+ var sturesult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>(stuidsql, $"Base-{school}");
|
|
|
if (sturesult.list.IsNotEmpty())
|
|
|
{
|
|
|
sturesult.list.ForEach(x => {
|
|
@@ -409,19 +513,25 @@ namespace TEAMModelOS.Controllers
|
|
|
if (existStudent .Any())
|
|
|
{
|
|
|
long time = 0;
|
|
|
- if (DateTimeOffset.TryParse(item.time, out DateTimeOffset dateTime))
|
|
|
+ string date = string.Empty;
|
|
|
+ DateTimeOffset dateTime = DateTimeOffset.Now;
|
|
|
+
|
|
|
+ if (!string.IsNullOrWhiteSpace(item.time) && DateTimeOffset.TryParse(item.time, out dateTime))
|
|
|
{
|
|
|
time = dateTime.ToUnixTimeMilliseconds();
|
|
|
+ date = dateTime.ToString("yyyy-MM-dd");
|
|
|
}
|
|
|
examImportStudents.Add(new ResultImportStudent
|
|
|
{
|
|
|
id = item.id,
|
|
|
name = existStudent.First().name,
|
|
|
- classId = existStudent.First().code,
|
|
|
+ classId = existStudent.First().classId,
|
|
|
score = item.score,
|
|
|
scores = item.scores,
|
|
|
time = time,
|
|
|
+ date = date,
|
|
|
items = item.items,
|
|
|
+ stuYear = existStudent.First().year,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -519,8 +629,8 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
if (clzz != null)
|
|
|
{
|
|
|
- string stuClassIdsql = $"select c.id,c.classId as code , c.name from c where c.name in ({string.Join(",", classStudents.Select(x => $"'{x.name}'"))}) and c.classId ='{clzz.id}' and c.periodId='{period.id}' ";
|
|
|
- var sturesult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<IdNameCode>(stuClassIdsql, $"Base-{school}");
|
|
|
+ string stuClassIdsql = $"select value c from c where c.name in ({string.Join(",", classStudents.Select(x => $"'{x.name}'"))}) and c.classId ='{clzz.id}' and c.periodId='{period.id}' ";
|
|
|
+ var sturesult = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).GetList<Student>(stuClassIdsql, $"Base-{school}");
|
|
|
//检查重名
|
|
|
if (sturesult.list.IsNotEmpty())
|
|
|
{
|
|
@@ -536,19 +646,24 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
|
|
|
long time = 0;
|
|
|
- if (DateTimeOffset.TryParse(stu.time, out DateTimeOffset dateTime))
|
|
|
+ string date = string.Empty;
|
|
|
+ DateTimeOffset dateTime = DateTimeOffset.Now;
|
|
|
+ if (!string.IsNullOrWhiteSpace(stu.time) && DateTimeOffset.TryParse(stu.time, out dateTime))
|
|
|
{
|
|
|
time = dateTime.ToUnixTimeMilliseconds();
|
|
|
+ date = dateTime.ToString("yyyy-MM-dd");
|
|
|
}
|
|
|
examImportStudents.Add(new ResultImportStudent
|
|
|
{
|
|
|
id = student[0].id,
|
|
|
name = student[0].name,
|
|
|
- classId = student[0].code,
|
|
|
+ classId = student[0].classId,
|
|
|
score = stu.score,
|
|
|
scores = stu.scores,
|
|
|
time = time,
|
|
|
- items = stu.items
|
|
|
+ date = date,
|
|
|
+ items = stu.items,
|
|
|
+ stuYear = student[0].year,
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -625,20 +740,38 @@ namespace TEAMModelOS.Controllers
|
|
|
double score = 0;
|
|
|
if (double.TryParse(datas[i][j], out score))
|
|
|
{
|
|
|
- items.Add(new ItemVlaue() { code = titles[j].Replace("item_", ""), value = score });
|
|
|
+ //德育细项分数为0 不纳入计算
|
|
|
+ if (score != 0)
|
|
|
+ {
|
|
|
+ items.Add(new ItemVlaue() { code = titles[j].Replace("item_", ""), value = score });
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else if (string.IsNullOrWhiteSpace(datas[i][j]))
|
|
|
{
|
|
|
- items.Add(new ItemVlaue() { code = titles[j].Replace("item_", ""), value = score });
|
|
|
+ //德育细项为空 不纳入计算
|
|
|
+ //items.Add(new ItemVlaue() { code = titles[j].Replace("item_", ""), value = score });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ error.Add(new KeyValuePair<string, List<string>>("score_invalid", new List<string> { datas[i][j] }));// 得分只能是数字
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (titles[j].Equals("time")) {
|
|
|
+
|
|
|
+ if (!string.IsNullOrWhiteSpace(datas[i][j]) && DateTimeOffset.TryParse(datas[i][j], out DateTimeOffset dateTime))
|
|
|
+ {
|
|
|
+
|
|
|
+ item.Add(titles[j], dateTime.ToString("yyyy-MM-dd"));
|
|
|
}
|
|
|
else {
|
|
|
- error.Add(new KeyValuePair<string, List<string>>("score_invalid",new List<string> { datas[i][j] }));// 得分只能是数字
|
|
|
+ error.Add(new KeyValuePair<string, List<string>>("time_format", new List<string> { datas[i][j] }));// 时间格式错误
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (titles[j].Equals("score") )
|
|
|
+ if (titles[j].Equals("score"))
|
|
|
{
|
|
|
if (double.TryParse(datas[i][j], out double score))
|
|
|
{
|
|
@@ -648,14 +781,16 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
item.Add(titles[j], 0);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
error.Add(new KeyValuePair<string, List<string>>("score_invalid", new List<string> { datas[i][j] }));// 得分只能是数字
|
|
|
}
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
item.Add(titles[j], datas[i][j]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
var orders = _index_order.OrderBy(x => x.Key).ToList();
|