|
@@ -88,8 +88,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
sc = json.ToObject<School>();
|
|
sc = json.ToObject<School>();
|
|
}
|
|
}
|
|
|
|
|
|
- List<(string name, double count)> rc = await getRecordCount(client, records, st, et, code.GetString(), tId);
|
|
|
|
- List<(int week, List<double> count)> tpc = await getTPCount(client, st, et, code.GetString(), tId);
|
|
|
|
|
|
+ List<(string name, double count)> rc = await getRecordCount(client, records, st, et, code.GetString(), tId,pId.GetString());
|
|
|
|
+ List<(int week, List<double> count)> tpc = await getTPCount(client, records, st, et, code.GetString(), tId, pId.GetString());
|
|
List<(string name, int count)> groups = getGroupCount(records);
|
|
List<(string name, int count)> groups = getGroupCount(records);
|
|
List<(string name, int count)> grades = getGradeCount(records);
|
|
List<(string name, int count)> grades = getGradeCount(records);
|
|
List<(string name, int count)> types = getTypeCount(records);
|
|
List<(string name, int count)> types = getTypeCount(records);
|
|
@@ -100,11 +100,12 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
List<(string name, int count)> groc = new List<(string name, int count)>();
|
|
List<(string name, int count)> groc = new List<(string name, int count)>();
|
|
foreach (var item in groups)
|
|
foreach (var item in groups)
|
|
{
|
|
{
|
|
- List<GroupListGrp> grps = await GroupListService.GetMemberInGroupList(_coreAPIHttpService, client, _dingDing, item.name,1, code.GetString(), new List<string> { "research" });
|
|
|
|
|
|
+ List<GroupListGrp> grps = await GroupListService.GetMemberInGroupList(_coreAPIHttpService, client, _dingDing, item.name, 1, code.GetString(), new List<string> { "research" });
|
|
//groupIds.Add(item.name);
|
|
//groupIds.Add(item.name);
|
|
//List<(string name, int count)> groc = new List<(string name, int count)>();
|
|
//List<(string name, int count)> groc = new List<(string name, int count)>();
|
|
- foreach (var grp in grps) {
|
|
|
|
- groc.Add((grp.name,item.count));
|
|
|
|
|
|
+ foreach (var grp in grps)
|
|
|
|
+ {
|
|
|
|
+ groc.Add((grp.name, item.count));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//var gyc = groc.GroupBy(x => x.name).Select(y => new {name = y.Key, count = y.Sum(c => c.count) });
|
|
//var gyc = groc.GroupBy(x => x.name).Select(y => new {name = y.Key, count = y.Sum(c => c.count) });
|
|
@@ -196,7 +197,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
catch (Exception e)
|
|
{
|
|
{
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/analysis-recod()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},analysis/analysis-recod()\n{e.Message}\n{e.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
return BadRequest();
|
|
return BadRequest();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -251,8 +252,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
if (records.Count > 0)
|
|
if (records.Count > 0)
|
|
{
|
|
{
|
|
- List<(string name, double count)> rc = await getRecordCount(client, records, st, et, code.GetString(), tId);
|
|
|
|
- List<(int week, List<double> count)> tpc = await getTPCount(client, st, et, code.GetString(), tId);
|
|
|
|
|
|
+ List<(string name, double count)> rc = await getRecordCount(client, records, st, et, code.GetString(), tId,"");
|
|
|
|
+ List<(int week, List<double> count)> tpc = await getTPCount(client, records, st, et, code.GetString(), tId,"");
|
|
|
|
|
|
var total = rc.Select(x => new { x.name, value = x.count });
|
|
var total = rc.Select(x => new { x.name, value = x.count });
|
|
var trend = tpc.Select(x => new { name = x.week, value = x.count });
|
|
var trend = tpc.Select(x => new { name = x.week, value = x.count });
|
|
@@ -282,7 +283,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
var c = records.Where(r => r.groupIds.Contains(groupId)).Count();
|
|
var c = records.Where(r => r.groupIds.Contains(groupId)).Count();
|
|
grCount.Add((groupId, c));
|
|
grCount.Add((groupId, c));
|
|
}*/
|
|
}*/
|
|
- foreach (var gr in subs) {
|
|
|
|
|
|
+ foreach (var gr in subs)
|
|
|
|
+ {
|
|
grCount.Add((gr.key, gr.count));
|
|
grCount.Add((gr.key, gr.count));
|
|
}
|
|
}
|
|
return grCount;
|
|
return grCount;
|
|
@@ -332,7 +334,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
return tyCount;
|
|
return tyCount;
|
|
}
|
|
}
|
|
//课列趋势图
|
|
//课列趋势图
|
|
- private async Task<List<(int week, List<double> count)>> getTPCount(CosmosClient client, long stime, long etime, string code, string tId)
|
|
|
|
|
|
+ private async Task<List<(int week, List<double> count)>> getTPCount(CosmosClient client, List<LessonRecord> records, long stime, long etime, string code, string tId,string periodId)
|
|
{
|
|
{
|
|
try
|
|
try
|
|
{
|
|
{
|
|
@@ -351,6 +353,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
List<LessonCount> scount = new List<LessonCount>();
|
|
List<LessonCount> scount = new List<LessonCount>();
|
|
List<LessonCount> tcount = new List<LessonCount>();
|
|
List<LessonCount> tcount = new List<LessonCount>();
|
|
var queryClass = $"select value(c) from c ";
|
|
var queryClass = $"select value(c) from c ";
|
|
|
|
+ List<string> perId = records.Select(r => r.periodId).Distinct().ToList();
|
|
if (!string.IsNullOrEmpty(tId))
|
|
if (!string.IsNullOrEmpty(tId))
|
|
{
|
|
{
|
|
|
|
|
|
@@ -361,14 +364,26 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
{
|
|
{
|
|
scount.Add(item);
|
|
scount.Add(item);
|
|
}
|
|
}
|
|
|
|
+ foreach (string pId in perId)
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{syear}-{pId}") }))
|
|
|
|
+ {
|
|
|
|
+ scount.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
- queryText: queryClass,
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{syear}") }))
|
|
|
|
- {
|
|
|
|
- scount.Add(item);
|
|
|
|
|
|
+ else {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{syear}-{periodId}") }))
|
|
|
|
+ {
|
|
|
|
+ scount.Add(item);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
List<List<double>> begin = new();
|
|
List<List<double>> begin = new();
|
|
List<List<double>> t = new();
|
|
List<List<double>> t = new();
|
|
List<List<double>> p = new();
|
|
List<List<double>> p = new();
|
|
@@ -442,13 +457,25 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
{
|
|
{
|
|
tcount.Add(item);
|
|
tcount.Add(item);
|
|
}
|
|
}
|
|
|
|
+ foreach (string pId in perId)
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{tyear}-{pId}") }))
|
|
|
|
+ {
|
|
|
|
+ scount.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
- queryText: queryClass,
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{tyear}") }))
|
|
|
|
- {
|
|
|
|
- tcount.Add(item);
|
|
|
|
|
|
+ else {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{tyear}-{periodId}") }))
|
|
|
|
+ {
|
|
|
|
+ tcount.Add(item);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
var eday = DateTimeOffset.UtcNow.DayOfYear;
|
|
var eday = DateTimeOffset.UtcNow.DayOfYear;
|
|
int pydays = DateTimeHelper.getDays(tyear);
|
|
int pydays = DateTimeHelper.getDays(tyear);
|
|
List<List<double>> e_begin = new();
|
|
List<List<double>> e_begin = new();
|
|
@@ -518,7 +545,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private async Task<List<(string time, double count)>> getRecordCount(CosmosClient client, List<LessonRecord> records, long stime, long etime, string code, string tId)
|
|
|
|
|
|
+ private async Task<List<(string time, double count)>> getRecordCount(CosmosClient client, List<LessonRecord> records, long stime, long etime, string code, string tId,string periodId)
|
|
{
|
|
{
|
|
List<(string time, double count)> counts = new();
|
|
List<(string time, double count)> counts = new();
|
|
counts.Add(("total", records.Count()));
|
|
counts.Add(("total", records.Count()));
|
|
@@ -533,6 +560,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
List<LessonCount> scount = new();
|
|
List<LessonCount> scount = new();
|
|
List<LessonCount> tcount = new();
|
|
List<LessonCount> tcount = new();
|
|
DenseMatrix dense = null;
|
|
DenseMatrix dense = null;
|
|
|
|
+ List<string> perId = records.Select(r => r.periodId).Distinct().ToList();
|
|
var queryClass = $"select value(c) from c ";
|
|
var queryClass = $"select value(c) from c ";
|
|
if (!string.IsNullOrEmpty(tId))
|
|
if (!string.IsNullOrEmpty(tId))
|
|
{
|
|
{
|
|
@@ -543,13 +571,26 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
{
|
|
{
|
|
scount.Add(item);
|
|
scount.Add(item);
|
|
}
|
|
}
|
|
|
|
+ foreach (string pId in perId)
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{syear}-{pId}") }))
|
|
|
|
+ {
|
|
|
|
+ scount.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
- queryText: queryClass,
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{syear}") }))
|
|
|
|
- {
|
|
|
|
- scount.Add(item);
|
|
|
|
|
|
+ else {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{syear}-{periodId}") }))
|
|
|
|
+ {
|
|
|
|
+ scount.Add(item);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
//var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(syear.ToString(), new PartitionKey($"ClassCount-" + code));
|
|
//var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(syear.ToString(), new PartitionKey($"ClassCount-" + code));
|
|
if (tyear > syear)
|
|
if (tyear > syear)
|
|
{
|
|
{
|
|
@@ -562,13 +603,26 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
{
|
|
{
|
|
tcount.Add(item);
|
|
tcount.Add(item);
|
|
}
|
|
}
|
|
|
|
+ foreach (string pId in perId)
|
|
|
|
+ {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{tyear}-{pId}") }))
|
|
|
|
+ {
|
|
|
|
+ tcount.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
- queryText: queryClass,
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{tyear}") }))
|
|
|
|
- {
|
|
|
|
- tcount.Add(item);
|
|
|
|
|
|
+ else {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<LessonCount>(
|
|
|
|
+ queryText: queryClass,
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"LessonCount-{code}-{tyear}-{periodId}") }))
|
|
|
|
+ {
|
|
|
|
+ tcount.Add(item);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
if (tcount.Count > 0)
|
|
if (tcount.Count > 0)
|
|
{
|
|
{
|
|
List<List<double>> be = new();
|
|
List<List<double>> be = new();
|