|
@@ -22,6 +22,8 @@ using DocumentFormat.OpenXml.Office2016.Excel;
|
|
using static TEAMModelOS.SDK.Models.Cosmos.Student.StudentAnalysis;
|
|
using static TEAMModelOS.SDK.Models.Cosmos.Student.StudentAnalysis;
|
|
using HTEXLib.Helpers.ShapeHelpers;
|
|
using HTEXLib.Helpers.ShapeHelpers;
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
|
+using NUnit.Framework;
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
{
|
|
{
|
|
@@ -243,103 +245,96 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
break;
|
|
break;
|
|
case "finish":
|
|
case "finish":
|
|
//判定是否是区级创建的活动内容
|
|
//判定是否是区级创建的活动内容
|
|
- /* if (art.lost.Count == 0 && art.pass == 0)
|
|
|
|
- {
|
|
|
|
- if (art.owner.Equals("area") && string.IsNullOrEmpty(art.pId))
|
|
|
|
- {
|
|
|
|
- *//* List<(string id, string code, List<Tasks> settings)> artSchools = new();
|
|
|
|
- string ql = $"select c.id,c.school,c.settings,c.classes from c where c.pk = 'Art' and c.pId = '{art.id}'";
|
|
|
|
- await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: ql))
|
|
|
|
- {
|
|
|
|
- using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
- if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
- {
|
|
|
|
- var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
|
- while (accounts.MoveNext())
|
|
|
|
- {
|
|
|
|
- JsonElement account = accounts.Current;
|
|
|
|
- List<Tasks> settings = account.GetProperty("settings").ToObject<List<Tasks>>();
|
|
|
|
- artSchools.Add((account.GetProperty("id").GetString(), account.GetProperty("school").GetString(), settings));
|
|
|
|
|
|
+ /* if (art.lost.Count == 0 && art.pass == 0)
|
|
|
|
+ {
|
|
|
|
+ if (art.owner.Equals("area") && string.IsNullOrEmpty(art.pId))
|
|
|
|
+ {
|
|
|
|
+ *//* List<(string id, string code, List<Tasks> settings)> artSchools = new();
|
|
|
|
+ string ql = $"select c.id,c.school,c.settings,c.classes from c where c.pk = 'Art' and c.pId = '{art.id}'";
|
|
|
|
+ await foreach (var item in client.GetContainer("TEAMModelOS", "Common").GetItemQueryStreamIterator(queryText: ql))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
|
|
|
|
+ while (accounts.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ JsonElement account = accounts.Current;
|
|
|
|
+ List<Tasks> settings = account.GetProperty("settings").ToObject<List<Tasks>>();
|
|
|
|
+ artSchools.Add((account.GetProperty("id").GetString(), account.GetProperty("school").GetString(), settings));
|
|
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- foreach (var (id, code, settings) in artSchools)
|
|
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ foreach (var (id, code, settings) in artSchools)
|
|
|
|
+ {
|
|
|
|
+ List<(string eId, string sId)> ids = new();
|
|
|
|
+ var examIds = settings.SelectMany(s => s.task).Where(a => a.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
|
|
+ examIds.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ ids.Add((x.acId, x.subject));
|
|
|
|
+ });
|
|
|
|
+ List<(string code, string sub, List<string> stu)> stuInfo = await getLostAsync(ids, client, code);
|
|
|
|
+ List<string> stus = new();
|
|
|
|
+ foreach (var lost in stuInfo)
|
|
|
|
+ {
|
|
|
|
+ if (stus.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ stus = stus.Union(lost.stu).ToList();
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ stus = stus.Intersect(lost.stu).ToList();
|
|
|
|
+ }
|
|
|
|
+ LostStudent lostStudent = new()
|
|
|
|
+ {
|
|
|
|
+ code = lost.code,
|
|
|
|
+ subject = lost.sub,
|
|
|
|
+ stu = lost.stu.Count
|
|
|
|
+ };
|
|
|
|
+ art.lost.Add(lostStudent);
|
|
|
|
+ }
|
|
|
|
+ art.miss.Add(stus.Count);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ art.pass = 1;
|
|
|
|
+ await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ArtEvaluation>(art, art.id, new PartitionKey(art.code));*//*
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //获取当前艺术评价相关评测ID目前暂时排除区级发布的评测信息
|
|
|
|
+
|
|
|
|
+ *//*List<(string eId, string sId)> ids = new();
|
|
|
|
+ var examId = art.settings.SelectMany(x => x.task).Where(c => c.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
|
|
+ examId.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ ids.Add((x.acId, x.subject));
|
|
|
|
+ });
|
|
|
|
+ List<(string code, string sub, List<string> stu)> stuInfo = await getLostAsync(ids, client, art.school);
|
|
|
|
+ List<string> stus = new();
|
|
|
|
+ foreach (var (code, sub, stu) in stuInfo)
|
|
{
|
|
{
|
|
- List<(string eId, string sId)> ids = new();
|
|
|
|
- var examIds = settings.SelectMany(s => s.task).Where(a => a.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
|
|
- examIds.ForEach(x =>
|
|
|
|
|
|
+ if (stus.Count == 0)
|
|
{
|
|
{
|
|
- ids.Add((x.acId, x.subject));
|
|
|
|
- });
|
|
|
|
- List<(string code, string sub, List<string> stu)> stuInfo = await getLostAsync(ids, client, code);
|
|
|
|
- List<string> stus = new();
|
|
|
|
- foreach (var lost in stuInfo)
|
|
|
|
|
|
+ stus = stus.Union(stu).ToList();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
{
|
|
{
|
|
- if (stus.Count == 0)
|
|
|
|
- {
|
|
|
|
- stus = stus.Union(lost.stu).ToList();
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- stus = stus.Intersect(lost.stu).ToList();
|
|
|
|
- }
|
|
|
|
- LostStudent lostStudent = new()
|
|
|
|
- {
|
|
|
|
- code = lost.code,
|
|
|
|
- subject = lost.sub,
|
|
|
|
- stu = lost.stu.Count
|
|
|
|
- };
|
|
|
|
- art.lost.Add(lostStudent);
|
|
|
|
|
|
+ stus = stus.Intersect(stu).ToList();
|
|
}
|
|
}
|
|
- art.miss.Add(stus.Count);
|
|
|
|
-
|
|
|
|
|
|
+ LostStudent lostStudent = new()
|
|
|
|
+ {
|
|
|
|
+ code = code,
|
|
|
|
+ subject = sub,
|
|
|
|
+ stu = stu.Count
|
|
|
|
+ };
|
|
|
|
+ art.lost.Add(lostStudent);
|
|
}
|
|
}
|
|
|
|
+ art.miss.Add(stus.Count);
|
|
|
|
+ //art.miss = stus.Count;
|
|
art.pass = 1;
|
|
art.pass = 1;
|
|
await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ArtEvaluation>(art, art.id, new PartitionKey(art.code));*//*
|
|
await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ArtEvaluation>(art, art.id, new PartitionKey(art.code));*//*
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- //获取当前艺术评价相关评测ID目前暂时排除区级发布的评测信息
|
|
|
|
-
|
|
|
|
- *//*List<(string eId, string sId)> ids = new();
|
|
|
|
- var examId = art.settings.SelectMany(x => x.task).Where(c => c.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
|
|
- examId.ForEach(x =>
|
|
|
|
- {
|
|
|
|
- ids.Add((x.acId, x.subject));
|
|
|
|
- });
|
|
|
|
- List<(string code, string sub, List<string> stu)> stuInfo = await getLostAsync(ids, client, art.school);
|
|
|
|
- List<string> stus = new();
|
|
|
|
- foreach (var (code, sub, stu) in stuInfo)
|
|
|
|
- {
|
|
|
|
- if (stus.Count == 0)
|
|
|
|
- {
|
|
|
|
- stus = stus.Union(stu).ToList();
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- stus = stus.Intersect(stu).ToList();
|
|
|
|
- }
|
|
|
|
- LostStudent lostStudent = new()
|
|
|
|
- {
|
|
|
|
- code = code,
|
|
|
|
- subject = sub,
|
|
|
|
- stu = stu.Count
|
|
|
|
- };
|
|
|
|
- art.lost.Add(lostStudent);
|
|
|
|
- }
|
|
|
|
- art.miss.Add(stus.Count);
|
|
|
|
- //art.miss = stus.Count;
|
|
|
|
- art.pass = 1;
|
|
|
|
- await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ArtEvaluation>(art, art.id, new PartitionKey(art.code));*//*
|
|
|
|
- }
|
|
|
|
- }*/
|
|
|
|
- List<StudentArtResult> studentArtResults = new();
|
|
|
|
- string sql = $"SELECT value c FROM c where c.pk='ArtResult' ";
|
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student)
|
|
|
|
- .GetItemQueryIterator<StudentArtResult>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{art.id}") }))
|
|
|
|
- {
|
|
|
|
- studentArtResults.Add(item);
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ }*/
|
|
//根据学校编码去获取区级ID
|
|
//根据学校编码去获取区级ID
|
|
School scInfo = new();
|
|
School scInfo = new();
|
|
//School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
|
|
//School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
|
|
@@ -363,7 +358,41 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
{
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
- if (art.publish == 0) {
|
|
|
|
|
|
+ if (art.publish == 0)
|
|
|
|
+ {
|
|
|
|
+ //获取该艺术评测的评测Id
|
|
|
|
+ List<(string id, string subjectId)> ids = new();
|
|
|
|
+ List<ExamClassResult> examClassResults = new();
|
|
|
|
+ var examId = art.settings.SelectMany(x => x.task).Where(c => c.type == 1).Select(z => new { z.acId, z.subject }).ToList();
|
|
|
|
+ examId.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ ids.Add((x.acId, x.subject));
|
|
|
|
+ });
|
|
|
|
+ List<string> results = new();
|
|
|
|
+ results = ids.Select(x => x.id).ToList();
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId in ({string.Join(",", results.Select(x => $"'{x}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{art.school}") }))
|
|
|
|
+ {
|
|
|
|
+ using var json = await JsonDocument.ParseAsync(item.ContentStream);
|
|
|
|
+ if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
|
|
|
|
+ {
|
|
|
|
+ foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
|
|
|
|
+ {
|
|
|
|
+ examClassResults.Add(obj.ToObject<ExamClassResult>());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ var sta = examClassResults.SelectMany(x => x.status).ToList();
|
|
|
|
+ var ansCount = sta.Where(x => x == 0).ToList();
|
|
|
|
+ var persent = ansCount.Count * 1.0 / sta.Count * 100;
|
|
|
|
+ var period = scInfo.period.Where(x => x.id.Equals(art.period.id)).FirstOrDefault();
|
|
|
|
+
|
|
|
|
+ List<StudentArtResult> studentArtResults = new();
|
|
|
|
+ string sql = $"SELECT value c FROM c where c.pk='ArtResult' ";
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, Constant.Student)
|
|
|
|
+ .GetItemQueryIterator<StudentArtResult>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"ArtResult-{art.id}") }))
|
|
|
|
+ {
|
|
|
|
+ studentArtResults.Add(item);
|
|
|
|
+ }
|
|
List<Task<ItemResponse<StudentArtResult>>> tasks = new List<Task<ItemResponse<StudentArtResult>>>();
|
|
List<Task<ItemResponse<StudentArtResult>>> tasks = new List<Task<ItemResponse<StudentArtResult>>>();
|
|
//新增数据推送 obj => Portrait
|
|
//新增数据推送 obj => Portrait
|
|
Portrait portrait = new()
|
|
Portrait portrait = new()
|
|
@@ -372,8 +401,9 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
periodId = art.period.id,
|
|
periodId = art.period.id,
|
|
subjectId = "subject_art"
|
|
subjectId = "subject_art"
|
|
};
|
|
};
|
|
- var period = scInfo.period.Where(x => x.id.Equals(art.period.id)).FirstOrDefault();
|
|
|
|
|
|
+ //var period = scInfo.period.Where(x => x.id.Equals(art.period.id)).FirstOrDefault();
|
|
//获取学期信息
|
|
//获取学期信息
|
|
|
|
+
|
|
var (currSemester, studyYear, currSemesterDate, date, nextSemester) = SchoolService.GetSemester(period, art.startTime);
|
|
var (currSemester, studyYear, currSemesterDate, date, nextSemester) = SchoolService.GetSemester(period, art.startTime);
|
|
//总分的占比情况
|
|
//总分的占比情况
|
|
|
|
|
|
@@ -424,6 +454,7 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
}
|
|
}
|
|
rs.totalScore = Math.Round(rs.subjectScores.Where(m => m.score >= 0).Sum(z => z.score), 2);
|
|
rs.totalScore = Math.Round(rs.subjectScores.Where(m => m.score >= 0).Sum(z => z.score), 2);
|
|
tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(rs, rs.id, new PartitionKey(rs.code)));
|
|
tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(rs, rs.id, new PartitionKey(rs.code)));
|
|
|
|
+
|
|
PortraitStudent student = new()
|
|
PortraitStudent student = new()
|
|
{
|
|
{
|
|
studentId = rs.studentId,
|
|
studentId = rs.studentId,
|
|
@@ -466,17 +497,19 @@ namespace TEAMModelOS.FunctionV4.CosmosDB
|
|
{
|
|
{
|
|
await Task.WhenAll(tasks);
|
|
await Task.WhenAll(tasks);
|
|
}
|
|
}
|
|
-
|
|
|
|
//获取学生信息
|
|
//获取学生信息
|
|
//(List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, art.classes, art.school);
|
|
//(List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, art.classes, art.school);
|
|
/* foreach (var member in studentArtResults)
|
|
/* foreach (var member in studentArtResults)
|
|
{
|
|
{
|
|
|
|
|
|
}*/
|
|
}*/
|
|
- string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
|
|
|
|
- var responseData = await _httpTrigger.RequestHttpTrigger(portrait, location, "upsert-student-portrait");
|
|
|
|
|
|
+ if (null != period && persent >= 60)
|
|
|
|
+ {
|
|
|
|
+ string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
|
|
|
|
+ var responseData = await _httpTrigger.RequestHttpTrigger(portrait, location, "upsert-student-portrait");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|