Selaa lähdekoodia

处理落点分析和试卷接口返回数据问题

zhouj1203@hotmail.com 4 vuotta sitten
vanhempi
commit
750d09c87d
1 muutettua tiedostoa jossa 32 lisäystä ja 14 poistoa
  1. 32 14
      TEAMModelOS/Controllers/Analysis/AchievementController.cs

+ 32 - 14
TEAMModelOS/Controllers/Analysis/AchievementController.cs

@@ -557,21 +557,25 @@ namespace TEAMModelOS.Controllers.Analysis
 
             dict.TryGetValue("subjectCode", out object subjectCode);
             dict.TryGetValue("code", out object code);
-           /* List<string> subjectCouns = JsonApiHelper.FromApiJson<List<string>>(subjectCode.ToApiJson());
-            for (int i = 0; i < subjectCouns.Count; i++)
-            {*/
-                if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCode.ToString()))
+            dict.TryGetValue("schoolCode", out object schoolCode);
+            /* List<string> subjectCouns = JsonApiHelper.FromApiJson<List<string>>(subjectCode.ToApiJson());
+             for (int i = 0; i < subjectCouns.Count; i++)
+             {*/
+            if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCode.ToString()))
                 {
                     ExamResult result = RedisHelper.HGet<ExamResult>(CacheCosmosPrefix + "examResult" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
                     //builder.Data(info);
                     exams.Add(result);
                 }
             //}
-            Dictionary<string, object> stuMap = new Dictionary<string, object>
+            //List<Student> students = await azureCosmosDBRepository.FindByDict<Student>(stuMap);
+            List<Student> students = null;
+            if (RedisHelper.Exists(CacheCosmosPrefix + "students"))
             {
-                { "schoolCode", "Habook" }
-            };
-            List<Student> students = await azureCosmosDBRepository.FindByDict<Student>(stuMap);
+                students = RedisHelper.HGet<List<Student>>(CacheCosmosPrefix + "students", ShaHashHelper.GetSHA1(schoolCode.ToString()));
+                //builder.Data(info);
+                //students.Add(student);
+            }
             List<string> key = new List<string>
             {
                 "name",
@@ -657,6 +661,7 @@ namespace TEAMModelOS.Controllers.Analysis
                                 info.Add(wrong + "");
                                 int[] str = strive[i];
                                 string striveAll = "";
+
                                 foreach (int n in str)
                                 {
                                     striveAll += n.ToString() + ",";
@@ -667,8 +672,21 @@ namespace TEAMModelOS.Controllers.Analysis
                                 {
                                     careAll += n.ToString() + ",";
                                 }
-                                info.Add(striveAll.Substring(0, striveAll.Length - 1));
-                                info.Add(careAll.Substring(0, careAll.Length - 1));
+                                if (string.IsNullOrEmpty(striveAll))
+                                {
+                                    info.Add("无");
+                                }
+                                else {
+                                    info.Add(striveAll.Substring(0, striveAll.Length - 1));
+                                }
+                                if (string.IsNullOrEmpty(careAll))
+                                {
+                                    info.Add("无");
+                                }
+                                else
+                                {
+                                    info.Add(careAll.Substring(0, careAll.Length - 1)); ;
+                                }                               
                                 info.Add(stu[i].ToString());
                                 datas.Add(info);
 
@@ -1515,12 +1533,12 @@ namespace TEAMModelOS.Controllers.Analysis
         }
 
         [HttpPost("FindExamPaper")]
-        public async Task<BaseResponse> FindExamPaper(JosnRequest<Dictionary<string, object>> request)
+        public BaseResponse FindExamPaper(JosnRequest<Dictionary<string, object>> request)
         {
             request.@params.TryGetValue("subjectCode", out object subjectCode);
             request.@params.TryGetValue("code", out object code);
             ResponseBuilder builder = ResponseBuilder.custom();
-            if (RedisHelper.Instance != null)
+            /*if (RedisHelper.Instance != null)
             {
 
                  List<Paper> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
@@ -1532,8 +1550,8 @@ namespace TEAMModelOS.Controllers.Analysis
              {
                  List<Paper> info = await FindExamPaperRedis(request.@params, request.method);
                  builder.Data(info);
-             }
-            if (RedisHelper.Exists(CacheCosmosPrefix + ""))
+             }*/
+            if (RedisHelper.Exists(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString()))
             {
                 List<Paper> info = RedisHelper.HGet<List<Paper>>(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
                 builder.Data(info);