|
@@ -724,17 +724,17 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
Dictionary<string, object> scatterAnalysis = new Dictionary<string, object>();
|
|
|
dict.TryGetValue("subjectCode", out object subjectCode);
|
|
|
dict.TryGetValue("schoolCode", out object schoolCode);
|
|
|
- //dict.TryGetValue("examCode", out object examCode);
|
|
|
- dict.TryGetValue("scopeCode", out object scopeCode);
|
|
|
+ dict.TryGetValue("code", out object code);
|
|
|
+ //dict.TryGetValue("scopeCode", out object scopeCode);
|
|
|
Dictionary<string, object> sub = new Dictionary<string, object>
|
|
|
{
|
|
|
{ "subjectCode", subjectCode.ToString()},
|
|
|
- { "scopeCode",scopeCode.ToString()}
|
|
|
+ { "code",code.ToString()}
|
|
|
};
|
|
|
Dictionary<string, object> examMap = new Dictionary<string, object>
|
|
|
{
|
|
|
{ "subjectCode", subjectCode.ToString()},
|
|
|
- //{ "examCode", examCode.ToString()},
|
|
|
+ { "code", code.ToString()},
|
|
|
{ "schoolCode", schoolCode.ToString()}
|
|
|
};
|
|
|
//List<ExamResult> exams = await azureCosmosDBRepository.FindByDict<ExamResult>(examMap);
|
|
@@ -977,18 +977,18 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
//JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
dict.TryGetValue("subjectCode", out object subjectCode);
|
|
|
dict.TryGetValue("schoolCode", out object schoolCode);
|
|
|
- dict.TryGetValue("examCode", out object examCode);
|
|
|
- dict.TryGetValue("scopeCode", out object scopeCode);
|
|
|
+ dict.TryGetValue("code", out object code);
|
|
|
+ //dict.TryGetValue("scopeCode", out object scopeCode);
|
|
|
Dictionary<string, object> sub = new Dictionary<string, object>
|
|
|
{
|
|
|
{ "subjectCode", subjectCode.ToString()},
|
|
|
- { "scopeCode",scopeCode.ToString()}
|
|
|
+ { "scopeCode",code.ToString()}
|
|
|
|
|
|
};
|
|
|
Dictionary<string, object> examMap = new Dictionary<string, object>
|
|
|
{
|
|
|
{ "schoolCode", schoolCode.ToString()},
|
|
|
- { "examCode", examCode.ToString()},
|
|
|
+ { "examCode", code.ToString()},
|
|
|
{ "subjectCode", subjectCode.ToString()}
|
|
|
|
|
|
|
|
@@ -1627,20 +1627,49 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
public async Task<BaseJosnRPCResponse> HomeStatistics(JosnRPCRequest<Dictionary<string, object>> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
+ Dictionary<string, dynamic> info = new Dictionary<string, dynamic>();
|
|
|
+ if (RedisHelper.Instance != null)
|
|
|
+ {
|
|
|
+
|
|
|
+ info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindHomeStatisticsRedis(request.@params, request.method); });
|
|
|
+
|
|
|
+ //数据从redis读取过后进行转换格式
|
|
|
+ builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ info = await FindHomeStatisticsRedis(request.@params, request.method);
|
|
|
+ builder.Data(JsonApiHelper.FromApiJson<System.Text.Json.JsonElement>(info.ToJson()));
|
|
|
+ }
|
|
|
+ return builder.build();
|
|
|
+ }
|
|
|
+ public async Task<Dictionary<string, dynamic>> FindHomeStatisticsRedis(Dictionary<string, object> dict, string method) {
|
|
|
|
|
|
//request.@params.TryGetValue("subjectCode", out object subjectCode);
|
|
|
- request.@params.TryGetValue("schoolCode", out object schoolCode);
|
|
|
- request.@params.TryGetValue("scopeCode", out object scopeCode);
|
|
|
+ dict.TryGetValue("schoolCode", out object schoolCode);
|
|
|
+ dict.TryGetValue("code", out object code);
|
|
|
Dictionary<string, object> eMap = new Dictionary<string, object>
|
|
|
{
|
|
|
- { "scopeCode", scopeCode.ToString()}
|
|
|
+ { "code", code.ToString()}
|
|
|
};
|
|
|
Dictionary<string, object> SCMap = new Dictionary<string, object>
|
|
|
{
|
|
|
{ "schoolCode", schoolCode.ToString()},
|
|
|
};
|
|
|
//说明 同学校、同类型考试数据
|
|
|
- List<ExamInfo> exams = await azureCosmosDBRepository.FindByDict<ExamInfo>(eMap);
|
|
|
+ //List<ExamInfo> exams = await azureCosmosDBRepository.FindByDict<ExamInfo>(eMap);
|
|
|
+ List<ExamInfo> exams = new List<ExamInfo>();
|
|
|
+ if (RedisHelper.Instance != null)
|
|
|
+ {
|
|
|
+ exams = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
|
|
|
+ ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(eMap)), timeoutSeconds, () => { return FindExamInfoRedis(eMap, "FindExamInfo"); });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ exams = await FindExamInfoRedis(eMap, "FindExamInfo");
|
|
|
+ }
|
|
|
//查询学校对应的年级信息
|
|
|
List<School> schools = await azureCosmosDBRepository.FindByDict<School>(SCMap);
|
|
|
HashSet<string> classList = new HashSet<string>();
|
|
@@ -1652,19 +1681,26 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
string Grade = "";
|
|
|
List<double> CoreAverage = new List<double>();
|
|
|
double weightSum = 0;
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
List<Period> periods = new List<Period>();
|
|
|
List<Grade> grades = new List<Grade>();
|
|
|
- foreach (School s in schools) {
|
|
|
+ foreach (School s in schools)
|
|
|
+ {
|
|
|
periods = s.period;
|
|
|
}
|
|
|
periods.ForEach(p =>
|
|
|
{
|
|
|
- if (p.periodName.Equals("初中")) {
|
|
|
+ if (p.periodName.Equals("初中"))
|
|
|
+ {
|
|
|
grades = p.grades;
|
|
|
- } else if (p.periodName.Equals("高中")) {
|
|
|
+ }
|
|
|
+ else if (p.periodName.Equals("高中"))
|
|
|
+ {
|
|
|
grades = p.grades;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
grades = p.grades;
|
|
|
}
|
|
|
});
|
|
@@ -1837,7 +1873,8 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
|
|
|
}
|
|
|
//年级成就指标
|
|
|
- if (weightSum == 0) {
|
|
|
+ if (weightSum == 0)
|
|
|
+ {
|
|
|
weightSum = 1;
|
|
|
}
|
|
|
double index = CoreAverage.Sum() / weightSum;
|
|
@@ -1927,13 +1964,25 @@ namespace TEAMModelOS.Controllers.Analysis
|
|
|
{ "ClassCore", ClassCore },
|
|
|
{ "KeyLines",KeyLines}
|
|
|
};
|
|
|
- builder.Data(AveragePointMap);
|
|
|
- return builder.build();
|
|
|
- } catch (Exception e) {
|
|
|
- Console.WriteLine("---------------------" + e.Message + "--------------------------");
|
|
|
+ //Redis处理结果集
|
|
|
+ if (RedisHelper.Instance != null)
|
|
|
+ {
|
|
|
+ if (!RedisHelper.Exists(CacheCosmosPrefix + method))
|
|
|
+ {
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), AveragePointMap);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(dict)), AveragePointMap);
|
|
|
+ await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AveragePointMap;
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ throw new BizException(e.Message);
|
|
|
}
|
|
|
- builder.Data("");
|
|
|
- return builder.build();
|
|
|
}
|
|
|
}
|
|
|
}
|