|
@@ -17,6 +17,8 @@ using TEAMModelOS.SDK.Context.Exception;
|
|
using TEAMModelOS.Service.Models;
|
|
using TEAMModelOS.Service.Models;
|
|
using TEAMModelOS.SDK.Helper.Network.HttpHelper;
|
|
using TEAMModelOS.SDK.Helper.Network.HttpHelper;
|
|
using TEAMModelOS.Service.Analysis.Implements;
|
|
using TEAMModelOS.Service.Analysis.Implements;
|
|
|
|
+using OpenXmlPowerTools;
|
|
|
|
+using System.Text.Json;
|
|
|
|
|
|
namespace TEAMModelOS.Controllers.Analysis
|
|
namespace TEAMModelOS.Controllers.Analysis
|
|
{
|
|
{
|
|
@@ -36,15 +38,21 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
|
|
|
}
|
|
}
|
|
[HttpPost("Achievement")]
|
|
[HttpPost("Achievement")]
|
|
- public async Task<BaseResponse> FindExam(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public async Task<BaseResponse> FindExam(JsonElement request)
|
|
{
|
|
{
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
|
|
Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
|
|
|
|
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamRedis(request.@params, request.method); });
|
|
|
|
|
|
+ info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "Achievement",
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), timeoutSeconds, () => { return FindExamRedis(dict, "Achievement"); });
|
|
|
|
|
|
//数据从redis读取过后进行转换格式
|
|
//数据从redis读取过后进行转换格式
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
@@ -52,7 +60,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info = await FindExamRedis(request.@params, request.method);
|
|
|
|
|
|
+ info = await FindExamRedis(dict, "Achievement");
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
@@ -527,15 +535,21 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
return info;
|
|
return info;
|
|
}*/
|
|
}*/
|
|
[HttpPost("PointAnalysis")]
|
|
[HttpPost("PointAnalysis")]
|
|
- public async Task<BaseResponse> PointAnalysis(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public async Task<BaseResponse> PointAnalysis(JsonElement request)
|
|
{
|
|
{
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
|
|
List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
|
|
|
|
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindPointAnalysisRedis(request.@params, request.method); });
|
|
|
|
|
|
+ info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "PointAnalysis",
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), timeoutSeconds, () => { return FindPointAnalysisRedis(dict, "PointAnalysis"); });
|
|
|
|
|
|
//数据从redis读取过后进行转换格式
|
|
//数据从redis读取过后进行转换格式
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
@@ -543,7 +557,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info = await FindPointAnalysisRedis(request.@params, request.method);
|
|
|
|
|
|
+ info = await FindPointAnalysisRedis(dict, "PointAnalysis");
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
@@ -726,15 +740,21 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
|
|
|
|
[HttpPost("ExerciseScatter")]
|
|
[HttpPost("ExerciseScatter")]
|
|
- public async Task<BaseResponse> ExerciseScatter(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public async Task<BaseResponse> ExerciseScatter(JsonElement request)
|
|
{
|
|
{
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
|
|
List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
|
|
|
|
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExerciseScatterRedis(request.@params, request.method); });
|
|
|
|
|
|
+ info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "ExerciseScatter",
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), timeoutSeconds, () => { return FindExerciseScatterRedis(dict, "ExerciseScatter"); });
|
|
|
|
|
|
//数据从redis读取过后进行转换格式
|
|
//数据从redis读取过后进行转换格式
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
@@ -742,7 +762,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info = await FindExerciseScatterRedis(request.@params, request.method);
|
|
|
|
|
|
+ info = await FindExerciseScatterRedis(dict, "ExerciseScatter");
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
@@ -1462,15 +1482,21 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
|
|
|
|
[HttpPost("knowledgePoint")]
|
|
[HttpPost("knowledgePoint")]
|
|
- public async Task<BaseResponse> KnowledgePoint(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public async Task<BaseResponse> KnowledgePoint(JsonElement request)
|
|
{
|
|
{
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
|
|
Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
|
|
|
|
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindKnowledgePointRedis(request.@params, request.method); });
|
|
|
|
|
|
+ info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "knowledgePoint",
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), timeoutSeconds, () => { return FindKnowledgePointRedis(dict, "knowledgePoint"); });
|
|
|
|
|
|
//数据从redis读取过后进行转换格式
|
|
//数据从redis读取过后进行转换格式
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
@@ -1478,22 +1504,28 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info = await FindKnowledgePointRedis(request.@params, request.method);
|
|
|
|
|
|
+ info = await FindKnowledgePointRedis(dict, "knowledgePoint");
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
}
|
|
}
|
|
[HttpPost("FindExamInfo")]
|
|
[HttpPost("FindExamInfo")]
|
|
- public async Task<BaseResponse> FindExamInfo(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public async Task<BaseResponse> FindExamInfo(JsonElement request)
|
|
{
|
|
{
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
try {
|
|
try {
|
|
///RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
|
|
///RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
|
|
/// RedisHelper.Instance.CurrentDeserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
|
|
/// RedisHelper.Instance.CurrentDeserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
|
|
- List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamInfoRedis(request.@params, request.method); });
|
|
|
|
|
|
+ List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), timeoutSeconds, () => { return FindExamInfoRedis(dict, "FindExamInfo"); });
|
|
|
|
|
|
builder.Data(info);
|
|
builder.Data(info);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
@@ -1502,7 +1534,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- List<ExamInfo> info = await FindExamInfoRedis(request.@params,request.method);
|
|
|
|
|
|
+ List<ExamInfo> info = await FindExamInfoRedis(dict, "FindExamInfo");
|
|
builder.Data(info);
|
|
builder.Data(info);
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
@@ -1533,10 +1565,16 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
|
|
|
|
[HttpPost("FindExamPaper")]
|
|
[HttpPost("FindExamPaper")]
|
|
- public BaseResponse FindExamPaper(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public BaseResponse FindExamPaper(JsonElement request)
|
|
{
|
|
{
|
|
- request.@params.TryGetValue("subjectCode", out object subjectCode);
|
|
|
|
- request.@params.TryGetValue("code", out object code);
|
|
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
|
|
+ dict.TryGetValue("subjectCode", out object subjectCode);
|
|
|
|
+ dict.TryGetValue("code", out object code);
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
/*if (RedisHelper.Instance != null)
|
|
/*if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
@@ -1587,28 +1625,23 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
}
|
|
}
|
|
[HttpPost("FindExamAnswer")]
|
|
[HttpPost("FindExamAnswer")]
|
|
- public async Task<BaseResponse> FindExamAnswer(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public BaseResponse FindExamAnswer(JsonElement request)
|
|
{
|
|
{
|
|
- request.@params.TryGetValue("subjectCode", out object subjectCode);
|
|
|
|
- request.@params.TryGetValue("code", out object code);
|
|
|
|
- ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
- if (RedisHelper.Instance != null)
|
|
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
{
|
|
{
|
|
-
|
|
|
|
- List<ExamAnswer> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamAnswerRedis(request.@params, request.method); });
|
|
|
|
- builder.Data(info);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- List<ExamAnswer> info = await FindExamAnswerRedis(request.@params, request.method);
|
|
|
|
- builder.Data(info);
|
|
|
|
- }
|
|
|
|
- if (RedisHelper.Exists(CacheCosmosPrefix + ""))
|
|
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
|
|
+ dict.TryGetValue("subjectCode", out object subjectCode);
|
|
|
|
+ dict.TryGetValue("code", out object code);
|
|
|
|
+ ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ List<ExamAnswer> exams = new List<ExamAnswer>();
|
|
|
|
+ if (RedisHelper.Exists(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString()))
|
|
{
|
|
{
|
|
- List<ExamAnswer> info = RedisHelper.HGet<List<ExamAnswer>>(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
|
|
|
|
- builder.Data(info);
|
|
|
|
|
|
+ ExamAnswer exam = RedisHelper.HGet<ExamAnswer>(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
|
|
|
|
+ exams.Add(exam);
|
|
|
|
+ builder.Data(exams);
|
|
}
|
|
}
|
|
|
|
|
|
return builder.build();
|
|
return builder.build();
|
|
@@ -1665,15 +1698,21 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
}
|
|
}
|
|
[HttpPost("HomeStatistics")]
|
|
[HttpPost("HomeStatistics")]
|
|
- public async Task<BaseResponse> HomeStatistics(JosnRequest<Dictionary<string, object>> request)
|
|
|
|
|
|
+ public async Task<BaseResponse> HomeStatistics(JsonElement request)
|
|
{
|
|
{
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
ResponseBuilder builder = ResponseBuilder.custom();
|
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object>();
|
|
|
|
+ var emobj = request.EnumerateObject();
|
|
|
|
+ while (emobj.MoveNext())
|
|
|
|
+ {
|
|
|
|
+ dict[emobj.Current.Name] = emobj.Current.Value;
|
|
|
|
+ }
|
|
List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
|
|
List<Dictionary<string, dynamic>> info = new List<Dictionary<string, dynamic>>();
|
|
if (RedisHelper.Instance != null)
|
|
if (RedisHelper.Instance != null)
|
|
{
|
|
{
|
|
|
|
|
|
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
|
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindHomeStatisticsRedis(request.@params, request.method); });
|
|
|
|
|
|
+ info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "HomeStatistics",
|
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), timeoutSeconds, () => { return FindHomeStatisticsRedis(dict, "HomeStatistics"); });
|
|
|
|
|
|
//数据从redis读取过后进行转换格式
|
|
//数据从redis读取过后进行转换格式
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
@@ -1681,7 +1720,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- info = await FindHomeStatisticsRedis(request.@params, request.method);
|
|
|
|
|
|
+ info = await FindHomeStatisticsRedis(dict, "HomeStatistics");
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
}
|
|
}
|
|
return builder.build();
|
|
return builder.build();
|
|
@@ -1720,7 +1759,7 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
ExamInfo examInfo = group.ToList().OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
|
|
ExamInfo examInfo = group.ToList().OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
|
|
newInfo.Add(examInfo);
|
|
newInfo.Add(examInfo);
|
|
};
|
|
};
|
|
- //newInfo.Select(e => e.type.Equals("union"));
|
|
|
|
|
|
+ //newInfo.Select(e => e.type.Equals("union"));
|
|
//List<ExamInfo> unionInfo = newInfo.Where(e => e.type.Equals("union")).ToList();
|
|
//List<ExamInfo> unionInfo = newInfo.Where(e => e.type.Equals("union")).ToList();
|
|
//exams.GroupBy(e => e.conditions.period);
|
|
//exams.GroupBy(e => e.conditions.period);
|
|
//ExamInfo info = exams.OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
|
|
//ExamInfo info = exams.OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
|
|
@@ -2060,91 +2099,5 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
throw new BizException(e.Message);
|
|
throw new BizException(e.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- public async Task SaveRedisInfoAsync(Dictionary<string, object> eMap)
|
|
|
|
- {
|
|
|
|
- //说明 同学校、同类型考试数据
|
|
|
|
- List<ExamInfo> exams = await azureCosmosDBRepository.FindByDict<ExamInfo>(eMap);
|
|
|
|
- for (int i = 0; i < exams.Count; i++)
|
|
|
|
- {
|
|
|
|
- //List<ExamResult> examResults = new List<ExamResult>();
|
|
|
|
- //Blob中获取文件并处理相关文件内容
|
|
|
|
- /*if (dict.TryGetValue("urlBlob", out object urlBlob))
|
|
|
|
- {
|
|
|
|
- string azureBlobSAS = System.Web.HttpUtility.UrlDecode((string)urlBlob, Encoding.UTF8);
|
|
|
|
- }*/
|
|
|
|
- List<ExamResult> simples = new List<ExamResult>();
|
|
|
|
- List<ExamAnswer> answers = new List<ExamAnswer>();
|
|
|
|
- List<Paper> papers = new List<Paper>();
|
|
|
|
- if (exams[i].blobUrl.Count < 0) {
|
|
|
|
- throw new BizException("数据未上传", 400);
|
|
|
|
- }
|
|
|
|
- //(string, string) a = BlobUrlString(azureBlobSAS);
|
|
|
|
- string sas = "?sv=2019-02-02&st=2020-08-04T07%3A45%3A24Z&se=2022-08-05T07%3A45%3A00Z&sr=c&sp=rl&sig=jA2sdItTVtzE3%2FKqXo77vObl18s905aDc8f61rSKAAM%3D";
|
|
|
|
- List<string> url = new List<string> {
|
|
|
|
- "https://teammodelstorage.blob.core.chinacloudapi.cn/hbcn/exam/88924E4C-F00D-4A1D-B2C3-234F930F29D4fa9fa7c5-e956-4bed-b3db-71756ad2ffc9Subject_Math.json"
|
|
|
|
- };
|
|
|
|
- for (int j = 0; j < url.Count; j++)
|
|
|
|
- {
|
|
|
|
- //获取Blob文件内容
|
|
|
|
- string text = await HttpHelper.HttpGetAsync(url[j] + sas);
|
|
|
|
- Dictionary<string, object> json = text.FromApiJson<Dictionary<string, object>>();
|
|
|
|
- json.TryGetValue("examResult", out object examResult);
|
|
|
|
- json.TryGetValue("students", out object students);
|
|
|
|
- json.TryGetValue("paperInfo", out object paperInfo);
|
|
|
|
- json.TryGetValue("examAnswer", out object examAnswer);
|
|
|
|
- json.TryGetValue("classInfo", out object classInfo);
|
|
|
|
- json.TryGetValue("schoolInfo", out object schoolInfo);
|
|
|
|
- //json.TryGetValue("students", out object students);
|
|
|
|
- ExamResult result = JsonApiHelper.FromApiJson<ExamResult>(examResult.ToApiJson());
|
|
|
|
- ExamAnswer answer = JsonApiHelper.FromApiJson<ExamAnswer>(examAnswer.ToApiJson());
|
|
|
|
- Paper paper = JsonApiHelper.FromApiJson<Paper>(paperInfo.ToApiJson());
|
|
|
|
- List<Student> stu = JsonApiHelper.FromApiJson<List<Student>>(students.ToApiJson());
|
|
|
|
- List<Classroom> classroom = JsonApiHelper.FromApiJson<List<Classroom>>(classInfo.ToApiJson());
|
|
|
|
- School school = JsonApiHelper.FromApiJson<School>(schoolInfo.ToApiJson());
|
|
|
|
- simples.Add(result);
|
|
|
|
- answers.Add(answer);
|
|
|
|
- papers.Add(paper);
|
|
|
|
- //Redis处理考试结果数据集合
|
|
|
|
- if (RedisHelper.Instance != null)
|
|
|
|
- {
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "examResult" + exams[i].conditions.subject[j], ShaHashHelper.GetSHA1(exams[i].examCode), result);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "examResult" + exams[i].conditions.subject[j], timeoutSeconds);
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "students" + exams[i].conditions.subject[j], ShaHashHelper.GetSHA1(exams[i].examCode), stu);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "students" + exams[i].conditions.subject[j], timeoutSeconds);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "paperInfo" + exams[i].conditions.subject[j], ShaHashHelper.GetSHA1(exams[i].examCode), paper);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "paperInfo" + exams[i].conditions.subject[j], timeoutSeconds);
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "examAnswer" + exams[i].conditions.subject[j], ShaHashHelper.GetSHA1(exams[i].examCode), answer);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "examAnswer" + exams[i].conditions.subject[j], timeoutSeconds);
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "classInfo" + exams[i].conditions.subject[j], ShaHashHelper.GetSHA1(exams[i].examCode), classroom);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "classInfo" + exams[i].conditions.subject[j], timeoutSeconds);
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "schoolInfo" + exams[i].conditions.subject[j], ShaHashHelper.GetSHA1(exams[i].examCode), school);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "schoolInfo" + exams[i].conditions.subject[j], timeoutSeconds);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (RedisHelper.Instance != null)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "results", ShaHashHelper.GetSHA1(exams[i].examCode), simples);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "results", timeoutSeconds);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "papers", ShaHashHelper.GetSHA1(exams[i].examCode), papers);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "papers", timeoutSeconds);
|
|
|
|
-
|
|
|
|
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "answers", ShaHashHelper.GetSHA1(exams[i].examCode), answers);
|
|
|
|
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "answers", timeoutSeconds);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|