hhb 8 달 전
부모
커밋
d5736f183b
2개의 변경된 파일46개의 추가작업 그리고 18개의 파일을 삭제
  1. 1 1
      TEAMModelOS.SDK/Models/Service/ExamService.cs
  2. 45 17
      TEAMModelOS/Controllers/Analysis/ArtAnalysisController.cs

+ 1 - 1
TEAMModelOS.SDK/Models/Service/ExamService.cs

@@ -97,7 +97,7 @@ namespace TEAMModelOS.SDK.Models.Service
                         using var json = await JsonDocument.ParseAsync(response.Content);
                         sc = json.ToObject<School>();
                     }*/
-                    StringBuilder stringBuilder = new($"select value(c) from c where c.startTime >= {stime} and c.startTime < {etime} and c.progress = 'finish' and c.period.id = '{periodId}'");
+                    StringBuilder stringBuilder = new($"select value(c) from c where c.startTime >= {stime} and c.startTime < {etime} and c.qamode <> 2 and c.progress = 'finish' and c.period.id = '{periodId}'");
                     if (examType.Any()) {
                         stringBuilder.Append($" and c.examType.name in ({string.Join(",", examType.Select(o => $"'{o}'"))}) ");
                     }

+ 45 - 17
TEAMModelOS/Controllers/Analysis/ArtAnalysisController.cs

@@ -101,10 +101,10 @@ namespace TEAMModelOS.Controllers.Analysis
                         var value_count = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:count:{code}", $"count:{subjectId}:{id}");
                         var value_max = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:max:{code}", $"max:{subjectId}:{id}");
                         var value_min = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:min:{code}", $"min:{subjectId}:{id}");
-                        var value_average = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:average:{code}", $"average:{subjectId}:{id}");
-                        var value_excellent = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:excellent:{code}", $"excellent:{subjectId}:{id}");
-                        var value_pass = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:pass:{code}", $"pass:{subjectId}:{id}");
-                        var value_pow = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:pow:{code}", $"pow:{subjectId}:{id}");
+                        var value_average = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:average:{code}:{classIds[0]}", $"average:{subjectId}:{id}");
+                        var value_excellent = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:excellent:{code}:{classIds[0]}", $"excellent:{subjectId}:{id}");
+                        var value_pass = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:pass:{code}:{classIds[0]}", $"pass:{subjectId}:{id}");
+                        var value_pow = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:pow:{code}:{classIds[0]}", $"pow:{subjectId}:{id}");
                         var value_blks = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:blk:{code}", $"blk:{subjectId}:{id}");
                         var value_kno = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:kno:{code}", $"kno:{subjectId}:{id}");
                         var value_dim = await _azureRedis.GetRedisClient(8).HashGetAsync($"ArtSchool:dim:{code}", $"dim:{subjectId}:{id}");
@@ -292,15 +292,7 @@ namespace TEAMModelOS.Controllers.Analysis
                 double max = subjectScore.name.Max(s => Math.Abs(s));
                 double min = subjectScore.name.Min(s => Math.Abs(s));
                 double total = subjectScore.name.Sum();
-                double average = Math.Round(total / stus.Count, 2);
-                double excellent = Math.Round(subjectScore.name.Where(s => s >= 80).Count() * 1.0 / stus.Count, 4);
-                double pass = Math.Round(subjectScore.name.Where(s => s >= 60).Count() * 1.0 / stus.Count, 4);
-                double powSum = 0;
-                foreach (var sc in subjectScore.name)
-                {
-                    powSum += Math.Pow(sc - average, 2);
-                }
-                var pow = Math.Round(stus.Count > 0 ? Math.Pow(powSum / stus.Count, 0.5) : 0, 2);
+                
 
                 //获取本次评测所有科目结算结果
                 List<ExamResult> examResults = new();
@@ -609,10 +601,6 @@ namespace TEAMModelOS.Controllers.Analysis
                 await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:count:{code}", $"count:{subjectId}:{id}", tchList.Count.ToJsonString());                
                 await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:max:{code}", $"max:{subjectId}:{id}", max.ToJsonString());
                 await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:min:{code}", $"min:{subjectId}:{id}", min.ToJsonString());
-                await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:average:{code}", $"average:{subjectId}:{id}", average.ToJsonString());
-                await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:excellent:{code}", $"excellent:{subjectId}:{id}", excellent.ToJsonString());
-                await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pass:{code}", $"pass:{subjectId}:{id}", pass.ToJsonString());
-                await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pow:{code}", $"pow:{subjectId}:{id}", pow.ToJsonString());
                 await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:blk:{code}", $"blk:{subjectId}:{id}", blk.ToJsonString());
                 await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:kno:{code}", $"kno:{subjectId}:{id}", kno.ToJsonString());
                 await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:dim:{code}", $"dim:{subjectId}:{id}", dim.ToJsonString());
@@ -620,20 +608,60 @@ namespace TEAMModelOS.Controllers.Analysis
                 if (classIds.Count == 1)
                 {
                     var realClassCount = classResults.Where(c => c.info.id.Equals(classIds[0])).SelectMany(z => z.status).Count(k => k == 0);
+                    double average = Math.Round(total / realClassCount, 2);
+                    double excellent = Math.Round(subjectScore.name.Where(s => s >= 80).Count() * 1.0 / realClassCount, 2);
+                    double pass = Math.Round(subjectScore.name.Where(s => s >= 60).Count() * 1.0 / realClassCount, 2);
+                    double powSum = 0;
+                    foreach (var sc in subjectScore.name)
+                    {
+                        powSum += Math.Pow(sc - average, 2);
+                    }
+                    var pow = Math.Round(realClassCount > 0 ? Math.Pow(powSum / realClassCount, 0.5) : 0, 2);
+                    
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:realClassCount:{code}", $"realClassCount:{subjectId}:{id}", realClassCount);
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:students:{code}:{classIds[0]}", $"students:{subjectId}:{id}", students.ToJsonString());
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:gscore:{code}", $"gscore:{subjectId}:{id}", gscore.ToJsonString());
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:cInfo:{code}:{classIds[0]}", $"cInfo:{subjectId}:{id}", cInfo.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:average:{code}:{classIds[0]}", $"average:{subjectId}:{id}", average.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:excellent:{code}:{classIds[0]}", $"excellent:{subjectId}:{id}", excellent.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pass:{code}:{classIds[0]}", $"pass:{subjectId}:{id}", pass.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pow:{code}:{classIds[0]}", $"pow:{subjectId}:{id}", pow.ToJsonString());
                     return Ok(new { count = tchList.Count, scount = realClassCount, max, min, average, excellent, pass, pow, blk, kno, dim, optCount, students, cInfo, gscore });
                 }
                 else if (classIds.Count == 0)
                 {
+                    double average = Math.Round(total / realCount, 2);
+                    double excellent = Math.Round(subjectScore.name.Where(s => s >= 80).Count() * 1.0 / realCount, 2);
+                    double pass = Math.Round(subjectScore.name.Where(s => s >= 60).Count() * 1.0 / realCount, 2);
+                    double powSum = 0;
+                    foreach (var sc in subjectScore.name)
+                    {
+                        powSum += Math.Pow(sc - average, 2);
+                    }
+                    var pow = Math.Round(realCount > 0 ? Math.Pow(powSum / realCount, 0.5) : 0, 2);
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:average:{code}", $"average:{subjectId}:{id}", average.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:excellent:{code}", $"excellent:{subjectId}:{id}", excellent.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pass:{code}", $"pass:{subjectId}:{id}", pass.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pow:{code}", $"pow:{subjectId}:{id}", pow.ToJsonString());
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:scount:{code}", $"scount:{subjectId}:{id}", realCount);
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:grade:{code}", $"grade:{subjectId}:{id}", "true");
                     return Ok(new { count = tchList.Count, scount = realCount, max, min, average, excellent, pass, pow, blk, kno, dim, optCount });
                 }
                 else
                 {
+                    double average = Math.Round(total / realCount, 2);
+                    double excellent = Math.Round(subjectScore.name.Where(s => s >= 80).Count() * 1.0 / realCount, 2);
+                    double pass = Math.Round(subjectScore.name.Where(s => s >= 60).Count() * 1.0 / realCount, 2);
+                    double powSum = 0;
+                    foreach (var sc in subjectScore.name)
+                    {
+                        powSum += Math.Pow(sc - average, 2);
+                    }
+                    var pow = Math.Round(realCount > 0 ? Math.Pow(powSum / realCount, 0.5) : 0, 2);
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:average:{code}", $"average:{subjectId}:{id}", average.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:excellent:{code}", $"excellent:{subjectId}:{id}", excellent.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pass:{code}", $"pass:{subjectId}:{id}", pass.ToJsonString());
+                    await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:pow:{code}", $"pow:{subjectId}:{id}", pow.ToJsonString());
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:scount:{code}", $"scount:{subjectId}:{id}", realCount);
                     await _azureRedis.GetRedisClient(8).HashSetAsync($"ArtSchool:cInfo:{code}", $"cInfo:{subjectId}:{id}", cInfo.ToJsonString());
                     return Ok(new { count = tchList.Count, scount = realCount, max, min, average, excellent, pass, pow, blk, kno, dim, optCount, cInfo});