123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121 |
- using ClouDASLibx;
- using Microsoft.AspNetCore.Mvc;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using TEAMModelOS.SDK;
- using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
- using TEAMModelOS.SDK.Helper.Common.StringHelper;
- using TEAMModelOS.SDK.DI;
- using System.Diagnostics;
- using TEAMModelOS.SDK.Helper.Common.JsonHelper;
- using TEAMModelOS.SDK.Helper.Security.ShaHash;
- using TEAMModelOS.SDK.Context.Exception;
- using TEAMModelOS.Service.Models;
- using TEAMModelOS.Service.Analysis.Implements;
- using OpenXmlPowerTools;
- using System.Text.Json;
- using TEAMModelOS.SDK.Extension;
- namespace TEAMModelOS.Controllers.Analysis
- {
- [Route("api/[controller]")]
- [ApiController]
- public class AchievementController : Controller
- {
- private readonly AzureCosmosFactory _azureCosmos;
- private const string CacheCosmosPrefix = "Analysis:";
- private const int timeoutSeconds = 3600;
- public AchievementController(AzureCosmosFactory azureCosmos)
- {
- _azureCosmos = azureCosmos;
- }
- [HttpPost("Achievement")]
- public async Task<BaseResponse> FindExam(JsonElement request)
- {
- 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>();
- if (RedisHelper.Instance != null)
- {
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "Achievement",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamRedis(dict, "Achievement"); });
- //数据从redis读取过后进行转换格式
- builder.Data(info);
- }
- else
- {
- info = await FindExamRedis(dict, "Achievement");
- builder.Data(info);
- }
- return builder.build();
- }
- public async Task<List<ExamResult>> FindExamResultRedis(Dictionary<string, object> dict, string method)
- {
- try
- {
- List<ExamResult> info = await _azureCosmos.FindByDict<ExamResult>(dict);
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return info;
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- public async Task<Dictionary<string, dynamic>> FindExamRedis(Dictionary<string, object> dict, string method)
- {
- ResponseBuilder builder = ResponseBuilder.custom();
- //Console.WriteLine(DateTimeOffset.Now.Second);
- //
- dict.TryGetValue("subjectCode", out object subjectCode);
- dict.TryGetValue("code", out object code);
- List<ExamResult> exams = new List<ExamResult>();
- /*if (RedisHelper.Instance != null)
- {
- exams = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamResultRedis",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamResultRedis(dict, "FindExamResultRedis"); });
- }
- else
- {
- exams = await FindExamResultRedis(dict, "FindExamResultRedis");
- }*/
- List<string> subjectCouns = JsonExtensions.ToObject<List<string>>(subjectCode.ToJsonString());
- for (int i =0;i < subjectCouns.Count;i++ ) {
- if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCouns[i]))
- {
- ExamResult result = RedisHelper.HGet<ExamResult>(CacheCosmosPrefix + "examResult" + subjectCouns[i], ShaHashHelper.GetSHA1(code.ToString()));
- //builder.Data(info);
- exams.Add(result);
- }
- }
- Dictionary<string, object> stuMap = new Dictionary<string, object>
- {
- { "schoolCode", "Habook" }
- };
- //声明进行标准用来设置进线标准,权重等参数
- dict.TryGetValue("Standard", out object Standard);
- List<Student> students = await _azureCosmos.FindByDict<Student>(stuMap);
- //Console.WriteLine(DateTimeOffset.Now.Second);
- List<Dictionary<string, object>> examList = new List<Dictionary<string, object>>();
- HashSet<string> classList = new HashSet<string>();
- HashSet<string> classId = new HashSet<string>();
- List<string> subjectAverage = new List<string>();
- List<List<string>> subjectPoints = new List<List<string>>();
- Dictionary<string, object> Average = new Dictionary<string, object>();
- Dictionary<string, object> entryTable = new Dictionary<string, object>();
- Dictionary<string, dynamic> achievementAnalysis = new Dictionary<string, dynamic>();
- List<string> arrSubject = new List<string>();
- List<string> keys = new List<string>();
- List<string> person = new List<string>();
- List<List<double>> subSum = new List<List<double>>();
- List<string> gAverage = new List<string>();
- List<string> cAverage = new List<string>();
- Dictionary<string, object> AclassAverage = new Dictionary<string, object>();
- Dictionary<string, object> passRateMap = new Dictionary<string, object>();
- List<List<string>> passALL = new List<List<string>>();
- List<string> gradeList = new List<string>();
- List<string> areaList = new List<string>();
- List<string> sbujectsList = new List<string>();
- if (exams.IsNotEmpty())
- {
- //存放进线情况统计key值
- keys.Add("name");
- keys.Add("className");
- keys.Add("gradeRank");
- keys.Add("score");
- //初始化进行人数
- double iPersons = 0;
- if (exams.IsNotEmpty())
- {
- int classLen = exams[0].classes.Count;
- for (int cls = 0; cls < classLen; cls++)
- {
- if (exams[0].classes[cls].TryGetValue(exams[0].classes[cls].Keys.ToArray<string>()[0], out int[] index))
- {
- List<double> stuScore = new List<double>();
- int stdLen = index[1] - index[0] + 1;
- for (int i = 0; i < stdLen; i++)
- {
- stuScore.Add(0);
- }
- subSum.Add(stuScore);
- }
- }
- }
- int xx = 0;
- //初始化总分
- double sumPoint = 0;
- int sumperson = exams[0].ids.Count;
- for (int i = 0; i < exams[0].ids.Count; i++)
- {
- if (exams[0].ids[i].Equals("0"))
- {
- sumperson--;
- }
- }
- exams.ForEach(e =>
- {
- //获取总分数
- e.result.ForEach(r =>
- {
- sumPoint += r.Sum();
- });
- });
- var gradeAverage = sumPoint / sumperson;
- //存放年级平均
- gAverage.Add(gradeAverage.ToString());
- //任意一次考试数据提取班级信息
- List<Dictionary<string, int[]>> classToName = exams[0].classes;
- //任意一次考试数据提取学生ID信息
- List<string> idToName = exams[0].ids;
- //var gradeAverage = Math.Floor(Math.Round(decimal.Parse((10 / 3).ToString("0.000")), 2));
- List<string> subjects = new List<string>();
- exams.ForEach(e =>
- {
- int peopleCount = 0;
- Dictionary<string, object> detail = new Dictionary<string, object>
- {
- { "name", e.subjectCode }
- };
- subjects.Add(e.subjectCode);
- List<string> ClassAverage = new List<string>();
- //计算试卷总分
- double sum = e.point.Sum();
- //及格分数
- double passRate = sum * 0.6;
- int gradeCount = 0;
- //初始化科目总分
- double subjectPoint = 0;
- //科目平均分
- double subAverage = 0;
- //计算班级平均分
- int classIndex = 0;
- List<string> passList = new List<string>();
- e.classes.ForEach(c =>
- {
- List<List<string>> classPRL = new List<List<string>>();
- //初始化班级总分
- double classPoint = 0;
- //初始化班级缺考人数
- int classCount = 0;
- //初始化班级平均分
- double points = 0;
- double passPoint = 0;
- //初始化及格人数
- int passCount = 0;
- //初始化各班参考人数
- int counts = 0;
- //c.Keys遍历key值
- foreach (string key in c.Keys)
- {
- classList.Add(key);
- }
- //每个班级平均分
- foreach (int[] value in c.Values)
- {
- for (int i = value[0]; i <= value[1]; i++)
- {
- //初始化学生单科个人得分
- double stuPoints = e.result[i].Sum();
- //Console.WriteLine("xx: "+xx+" classIndex:" + classIndex + ",i:" + i + " value[0]:" + value[0]+ " value[0]:" + value[1]);
- subSum[classIndex][i - value[0]] = stuPoints + subSum[classIndex][i - value[0]];
- if (stuPoints > passRate)
- {
- passCount++;
- gradeCount++;
- }
- classPoint += e.result[i].Sum();
- if (e.result[i].Sum() == 0)
- {
- classCount++;
- }
- }
- //每个班级实际参考人数
- counts = value[1] - value[0] - classCount + 1;
- points = Convert.ToDouble(classPoint) / counts;
- ClassAverage.Add(points.ToString("0.00"));
- person.Add(counts + "");
- }
- passPoint = Convert.ToDouble(passCount) / counts;
- passList.Add(passPoint.ToString("0.00"));
- //classPRM.Add(classPRL);
- classIndex += 1;
- });
- //科目平均分
- ClassAverage.ForEach(a =>
- {
- subjectPoint += Convert.ToDouble(a);
- });
- subAverage = subjectPoint / ClassAverage.Count();
- subjectAverage.Add(subAverage.ToString("0.00"));
- detail.Add("schoolAverage", subAverage.ToString("0.00"));
- detail.Add("areaAverage", subAverage.ToString("0.00"));
- detail.Add("score", ClassAverage);
- examList.Add(detail);
- //获取实际参考总人数
- e.ids.ForEach(i =>
- {
- if (!i.Equals("0"))
- {
- peopleCount++;
- }
- });
- //班级及格率
- passALL.Add(passList);
- //年级及格率
- double gradePass = Convert.ToDouble(gradeCount) / peopleCount;
- gradeList.Add(gradePass.ToString("0.00"));
- //passALL.Add(gradeList);
- //区级及格率
- //passALL.Add(areaList);
- //获取进线人数
- iPersons = peopleCount * 0.4;
- //计算每个学生单科成绩
- for (int i = 0; i < e.ids.Count(); i++)
- {
- List<string> info = new List<string>();
- //info = new List<string>();
- info.Add(e.ids[i]);
- info.Add(e.subjectCode);
- info.Add(e.result[i].Sum() + "");
- //classId.Add(e.Ids[i]);
- subjectPoints.Add(info);
- }
- keys.Add(e.subjectCode);
- xx += 1;
- //subjectPoints = GetMark(e.Result,e.Ids);
- });
- //subjectPoints.ForEach(f => f.GroupBy(f[0]));
- //进线情况统计
- Dictionary<string, List<List<string>>> dicts = new Dictionary<string, List<List<string>>>();
- foreach (IGrouping<string, List<string>> group in subjectPoints.GroupBy(c => c[0]))
- {
- dicts.Add(group.Key, group.ToList());
- };
- Average.Add("classList", classList);
- List<List<string>> sp = new List<List<string>>();
- //Dictionary<string, int> rankScore = new Dictionary<string, int>();
- List<int> rankScore = new List<int>();
- foreach (string key in dicts.Keys)
- {
- int score = 0;
- List<string> values = new List<string>();
- keys.ForEach(x =>
- {
- values.Add("-");
- });
- foreach (List<string> val in dicts[key])
- {
- int index = keys.IndexOf(val[1]);
- values[index] = val[2];
- values[keys.IndexOf("name")] = val[0];
- score += int.Parse(val[2]);
- values[keys.IndexOf("score")] = score + "";
- }
- rankScore.Add(score);
- sp.Add(values);
- }
- AchievementService.ReName(sp, idToName, classToName, students);
- //处理人数为整
- string ip = iPersons.ToString("0");
- //初始化进线分数
- int ipoint = 0;
- //计算成绩年级排名
- rankScore.Sort(delegate (int s1, int s2) { return s2.CompareTo(s1); });
- ipoint = rankScore[int.Parse(ip)];
- foreach (List<string> rank in sp)
- {
- int index = rankScore.IndexOf(int.Parse(rank[3]));
- rank[2] = (index + 1) + "";
- }
- //排除成绩为零的选手
- for (int i = sp.Count - 1; i >= 0; i--)
- {
- if (sp[i][0].Equals("0"))
- {
- sp.Remove(sp[i]);
- }
- }
- entryTable.Add("keys", keys);
- entryTable.Add("datas", sp);
- //封装进线人数统计
- List<string> keyLine = new List<string>
- {
- "gradeRank",
- "name",
- "entryNum",
- "totalNum",
- "overAverageRate"
- };
- Dictionary<string, object> entryLineBar = new Dictionary<string, object>();
- //存放班级信息
- List<string> className = new List<string>();
- foreach (string cla in classList)
- {
- className.Add(cla);
- }
- List<List<string>> datas = new List<List<string>>();
- //记录各个班级进线率占比
- List<string> persent = new List<string>();
- int m = 0;
- foreach (List<double> points in subSum)
- {
- List<string> detail = new List<string>();
- keyLine.ForEach(x =>
- {
- detail.Add("-");
- });
- double sum = points.Count;
- int j = 0;
- for (int i = 0; i < points.Count; i++)
- {
- if (points[i] > ipoint)
- {
- j++;
- }
- }
- double Lines = j;
- detail[1] = className[m].ToString();
- detail[2] = j.ToString();
- detail[3] = points.Count.ToString();
- var t3 = Math.Floor(Math.Round(decimal.Parse((Lines / sum).ToString("0.000")), 2) * 100);
- persent.Add(t3.ToString());
- detail[4] = t3.ToString();
- datas.Add(detail);
- m++;
- }
- persent.Sort(delegate (string s1, string s2) { return int.Parse(s2).CompareTo(int.Parse(s1)); });
- //存放班级的年级排名
- List<string> ranks = new List<string>();
- foreach (List<string> des in datas)
- {
- int index = persent.IndexOf(des[4]);
- des[0] = (index + 1).ToString();
- ranks.Add((index + 1).ToString());
- }
- //预警统计
- Dictionary<string, object> early = new Dictionary<string, object>();
- List<List<string>> earlyWarning = new List<List<string>>();
- List<string> keyWarning = new List<string>
- {
- "classId",
- "totalNum",
- "average",
- "standardDeviation",
- "overAverageRate",
- "gradeRank"
- };
- int n = 0;
- foreach (List<double> points in subSum)
- {
- double sum = 0;
- List<string> classInfo = new List<string>();
- classInfo.Add(className[n]);
- classInfo.Add(points.Count.ToString());
- foreach (int point in points)
- {
- sum += point;
- }
- double Aver = sum / points.Count;
- classInfo.Add(Aver.ToString());
- //存放班级平均
- cAverage.Add(Aver.ToString());
- //标准差
- double powSum = 0;
- foreach (int point in points)
- {
- powSum += Math.Pow(point - Aver, 2);
- }
- var pow = Math.Pow(powSum / points.Count, 0.5);
- classInfo.Add(pow.ToString("0.00"));
- //超均率
- var super = (sum - (sum - 100)) / (sum - 100);
- classInfo.Add(super.ToString("0.00"));
- //年级排名
- classInfo.Add(ranks[n]);
- earlyWarning.Add(classInfo);
- n++;
- }
- //sbujectsList.Add(subjects);
- passRateMap.Add("subjects", subjects);
- passRateMap.Add("class", passALL);
- passRateMap.Add("grade", gradeList);
- passRateMap.Add("area", areaList);
- //passRate.Add("passRate", passALL);
- early.Add("keys", keyWarning);
- early.Add("datas", earlyWarning);
- AclassAverage = AchievementService.GetAverage(exams, gAverage, cAverage, subSum, students);
- List<Dictionary<string, object>> rankPR = AchievementService.GetPR(exams, subSum, students);
- entryLineBar.Add("keys", keyLine);
- entryLineBar.Add("datas", datas);
- //sp.Sort(delegate (string s1, string s2) { return int.Parse(s1).CompareTo(int.Parse(s2)); });
- Average.Add("subjectAverage", subjectAverage);
- Average.Add("datas", examList);
- achievementAnalysis.Add("passRate", passRateMap);
- achievementAnalysis.Add("average", Average);
- achievementAnalysis.Add("entryLineBar", entryLineBar);
- achievementAnalysis.Add("entryTable", entryTable);
- achievementAnalysis.Add("earlyWarning", early);
- achievementAnalysis.Add("rankPR", rankPR);
- achievementAnalysis.Add("stuAverage", AclassAverage);
- //Redis处理结果集
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), achievementAnalysis);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), achievementAnalysis);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return achievementAnalysis;
- }
- else return achievementAnalysis;
- }
- /* public List<string> GetMark(List<List<int>> point,List<string> ids) {
- List<string> info = null;
- for (int i = 0;i <= ids.Count();i++) {
- info = new List<string>();
- info.Add(ids[i]);
- info.Add(point[i].Sum()+"");
- }
- return info;
- }*/
- [HttpPost("PointAnalysis")]
- public async Task<BaseResponse> PointAnalysis(JsonElement request)
- {
- 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>>();
- if (RedisHelper.Instance != null)
- {
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "PointAnalysis",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindPointAnalysisRedis(dict, "PointAnalysis"); });
- //数据从redis读取过后进行转换格式
- builder.Data(info);
- }
- else
- {
- info = await FindPointAnalysisRedis(dict, "PointAnalysis");
- builder.Data(info);
- }
- return builder.build();
- }
- public async Task<List<Dictionary<string, dynamic>>> FindPointAnalysisRedis(Dictionary<string, object> dict, string method)
- {
- //ResponseBuilder builder = ResponseBuilder.custom();
- List<Dictionary<string, dynamic>> scatterAnalysis = new List<Dictionary<string, dynamic>>();
- //Dictionary<string, object> scatterAnalysis = new Dictionary<string, object>();
- List<ExamResult> exams = new List<ExamResult>();
- dict.TryGetValue("subjectCode", out object subjectCode);
- dict.TryGetValue("code", out object code);
- 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);
- }
- //}
- //List<Student> students = await azureCosmosDBRepository.FindByDict<Student>(stuMap);
- List<Student> students = null;
- if (RedisHelper.Exists(CacheCosmosPrefix + "students"))
- {
- students = RedisHelper.HGet<List<Student>>(CacheCosmosPrefix + "students", ShaHashHelper.GetSHA1(schoolCode.ToString()));
- //builder.Data(info);
- //students.Add(student);
- }
- List<string> key = new List<string>
- {
- "name",
- "className",
- "x",
- "y",
- "memberId",
- "score",
- "trueNum",
- "falseNum",
- "hardList",
- "carefulList",
- "scatter"
- };
- //key.Add("areaName");
- if (exams.IsNotEmpty())
- {
- //提取班级信息
- List<Dictionary<string, int[]>> classToName = exams[0].classes;
- //提取学生ID信息
- List<string> idToName = exams[0].ids;
- exams.ForEach(e =>
- {
- Dictionary<string, object> detail = new Dictionary<string, object>
- {
- { "keys", key }
- };
- List<List<string>> datas = new List<List<string>>();
- Dictionary<string, object> subject = new Dictionary<string, object>
- {
- { "name", e.subjectCode }
- };
- double[] point = StringHelper.ListTodouble(e.point);
- double[,] result = StringHelper.ListToDouble(e.result);
- try
- {
- var cdm = new ClouDASMatrix(result, point);
- //学生通过率
- List<double> pass = cdm.PassingRate;
- //学生稳定度
- List<double> sta = cdm.StabilityRate;
- //落点区域
- List<string> stu = cdm.StuFallArea;
- //需努力的题型
- List<int[]> strive = cdm.StriveTopic;
- //需小心的题型
- List<int[]> careful = cdm.CarefulTopic;
- int i = 0;
- for (int k = e.ids.Count - 1; k >= 0; k--)
- {
- if (e.ids[k].Equals("0"))
- {
- e.ids.Remove(e.ids[k]);
- }
- }
- e.ids.ForEach(s =>
- {
- if (e.result[i].Sum() != 0)
- {
- List<string> info = new List<string>
- {
- s,
- "-",
- sta[i].ToString(),
- pass[i].ToString(),
- i + 1 + "",
- e.result[i].Sum().ToString()
- };
- int right = 0;
- int wrong = 0;
- foreach (int p in e.result[i])
- {
- if (p > 0)
- {
- right++;
- }
- else
- {
- wrong++;
- }
- }
- info.Add(right + "");
- info.Add(wrong + "");
- int[] str = strive[i];
- string striveAll = "";
- foreach (int n in str)
- {
- striveAll += n.ToString() + ",";
- }
- int[] care = careful[i];
- string careAll = "";
- foreach (int n in care)
- {
- careAll += n.ToString() + ",";
- }
- 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);
- }
- i++;
- });
- AchievementService.ReName(datas, idToName, classToName, students);
- detail.Add("datas", datas);
- subject.Add("scatter", detail);
- scatterAnalysis.Add(subject);
- }
- catch (Exception ex)
- {
- //builder.Data(exams);
- //ex.Message;
- Console.WriteLine("---------------------" + ex.Message + "--------------------------");
- }
- });
- //Redis处理结果集
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), scatterAnalysis);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), scatterAnalysis);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return scatterAnalysis;
- }
- else return scatterAnalysis;
- }
- [HttpPost("ExerciseScatter")]
- public async Task<BaseResponse> ExerciseScatter(JsonElement request)
- {
- 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>>();
- if (RedisHelper.Instance != null)
- {
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "ExerciseScatter",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExerciseScatterRedis(dict, "ExerciseScatter"); });
- //数据从redis读取过后进行转换格式
- builder.Data(info);
- }
- else
- {
- info = await FindExerciseScatterRedis(dict, "ExerciseScatter");
- builder.Data(info);
- }
- return builder.build();
- }
- public async Task<List<Dictionary<string, dynamic>>> FindExerciseScatterRedis(Dictionary<string, object> dict, string method)
- {
- ResponseBuilder builder = ResponseBuilder.custom();
- HashSet<string> classList = new HashSet<string>();
- List<Dictionary<string, object>> exerciseScatter = new List<Dictionary<string, object>>();
- Dictionary<string, object> scatterAnalysis = new Dictionary<string, object>();
- dict.TryGetValue("subjectCode", out object subjectCode);
- dict.TryGetValue("schoolCode", out object schoolCode);
- dict.TryGetValue("code", out object code);
- //dict.TryGetValue("scopeCode", out object scopeCode);
- /* Dictionary<string, object> sub = new Dictionary<string, object>
- {
- { "subjectCode", subjectCode.ToString()},
- { "code",code.ToString()}
- };
- Dictionary<string, object> examMap = new Dictionary<string, object>
- {
- { "subjectCode", subjectCode.ToString()},
- { "code", code.ToString()},
- { "schoolCode", schoolCode.ToString()}
- };*/
- //List<ExamResult> exams = await azureCosmosDBRepository.FindByDict<ExamResult>(examMap);
- List<ExamResult> exams = new List<ExamResult>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCode.ToString()))
- {
- ExamResult result = RedisHelper.HGet<ExamResult>(CacheCosmosPrefix + "examResult" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- exams.Add(result);
- }
- List<Paper> paper = new List<Paper>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString()))
- {
- Paper paper1 = RedisHelper.HGet<Paper>(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- paper.Add(paper1);
- }
- List<string> key = new List<string>
- {
- "id",
- "type",
- "areaName",
- "score",
- "diff",
- "identify",
- "classScoreRate",
- "gradeScoreRate",
- "areaScoreRate",
- "highScoreRate",
- "lowScoreRate",
- "knowledgePoint",
- "R1",
- "R2",
- "R3",
- "R4",
- "R5",
- "R6",
- "PH",
- "PL",
- "X",
- "Y",
- "knowledge"
- };
- //key.Add("areaName");
- if (exams.IsNotEmpty())
- {
- exams.ForEach(e =>
- {
- List<double> gradeAnswer = new List<double>();
- List<string> grasdepersent = new List<string>();
- for (int n = 0; n < e.point.Count; n++)
- {
- gradeAnswer.Add(0);
- }
- //参考人数
- double Qnum = 0;
- e.ids.ForEach(i =>
- {
- if (!i.Equals("0"))
- {
- Qnum++;
- }
- });
- Dictionary<string, object> detail = new Dictionary<string, object>
- {
- { "keys", key }
- };
- List<List<string>> datas = new List<List<string>>();
- List<string[]> itemAnalysis = new List<string[]>();
- Dictionary<string, object> subject = new Dictionary<string, object>
- {
- { "name", e.subjectCode }
- };
- Dictionary<string, object> classPersent = new Dictionary<string, object>();
- List<List<string>> classdatas = new List<List<string>>();
- try
- {
- e.classes.ForEach(c =>
- {
- //初始化每题得分情况
- List<int> answerCount = new List<int>();
- List<string> persent = new List<string>();
- double peopleCount = 0;
- for (int n = 0; n < e.point.Count; n++)
- {
- answerCount.Add(0);
- }
- int qCount = 0;
- //int right = 0;
- //c.Keys遍历key值
- foreach (string keys in c.Keys)
- {
- classList.Add(keys);
- }
- //每个班级得分占比
- foreach (int[] value in c.Values)
- {
- for (int i = value[0]; i <= value[1]; i++)
- {
- if (e.result[i].Sum() > 0)
- {
- for (int j = 0; j < e.result[i].Count; j++)
- {
- if (e.result[i][j] > 0)
- {
- //记录班级每题得分数
- answerCount[j] = answerCount[j] + 1;
- //记录年级每题得分数
- gradeAnswer[j] = gradeAnswer[j] + 1;
- //right++;
- }
- }
- }
- else
- {
- qCount++;
- }
- peopleCount = value[1] - value[0] + 1 - qCount;
- }
- }
- foreach (int p in answerCount)
- {
- var t = Math.Floor(Math.Round(decimal.Parse((p / peopleCount).ToString("0.000")), 2) * 100);
- persent.Add(t.ToString());
- }
- classdatas.Add(persent);
- });
- classPersent.Add("classList", classList);
- classPersent.Add("datas", classdatas);
- exerciseScatter.Add(classPersent);
- double[] point = StringHelper.ListTodouble(e.point);
- double[,] result = StringHelper.ListToDouble(e.result);
- var cdm = new ClouDASMatrix(result, point);
- //试题Y
- List<double> answer = cdm.AnswerRate;
- //试题X
- List<double> quality = cdm.QualityRate;
- //试题区域
- List<string> topic = cdm.TopicFallArea;
- //试题相关分析结果
- List<(double Diff, double Identify, double R1, double R2, double R3, double R4, double R5, double R6, double RH, double RL)> rs = cdm.RS;
- for (int i = 0; i < rs.Count; i++)
- {
- string[] ex = new string[] { };
- string ss = rs[i].ToString()[1..^1];
- ex = ss.Split(",");
- itemAnalysis.Add(ex);
- }
- foreach (int p in gradeAnswer)
- {
- var t = Math.Floor(Math.Round(decimal.Parse((p / Qnum).ToString("0.000")), 2) * 100);
- grasdepersent.Add(t.ToString());
- }
- for (int k = 0; k < e.point.Count; k++)
- {
- List<string> values = new List<string>();
- key.ForEach(x =>
- {
- values.Add("-");
- });
- values[0] = (k + 1).ToString();
- values[1] = paper[0].item[k].type;
- values[2] = topic[k].ToString();
- values[3] = e.point[k].ToString();
- values[4] = itemAnalysis[k][0];
- values[5] = itemAnalysis[k][1];
- values[7] = grasdepersent[k];
- values[8] = grasdepersent[k];
- values[12] = itemAnalysis[k][2];
- values[13] = itemAnalysis[k][3];
- values[14] = itemAnalysis[k][4];
- values[15] = itemAnalysis[k][5];
- values[16] = itemAnalysis[k][6];
- values[17] = itemAnalysis[k][7];
- values[18] = itemAnalysis[k][8];
- values[19] = itemAnalysis[k][9];
- values[20] = quality[k].ToString();
- values[21] = answer[k].ToString();
- string pointName = "";
- if (paper[0].item[k].points.Count == 1)
- {
- foreach (string index in paper[0].item[k].points)
- {
- pointName = index;
- }
- }
- else if (paper[0].item[k].points.Count > 1)
- {
- foreach (string index in paper[0].item[k].points)
- {
- pointName += index + ",";
- }
- }
- values[22] = pointName;
- datas.Add(values);
- }
- subject.Add("keys", key);
- subject.Add("datas", datas);
- exerciseScatter.Add(subject);
- }
- catch (Exception ex)
- {
- throw new BizException(ex.Message);
- }
- });
- //Redis处理结果集
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), exerciseScatter);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), exerciseScatter);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return exerciseScatter;
- }
- else return exerciseScatter;
- }
- public async Task<Dictionary<string, dynamic>> FindKnowledgePointRedis(Dictionary<string, object> dict, string method)
- {
- //ResponseBuilder builder = ResponseBuilder.custom();
- dict.TryGetValue("subjectCode", out object subjectCode);
- dict.TryGetValue("schoolCode", out object schoolCode);
- dict.TryGetValue("code", out object code);
- //dict.TryGetValue("scopeCode", out object scopeCode);
- /* Dictionary<string, object> sub = new Dictionary<string, object>
- {
- { "subjectCode", subjectCode.ToString()},
- { "code",code.ToString()}
- };
- Dictionary<string, object> examMap = new Dictionary<string, object>
- {
- { "schoolCode", schoolCode.ToString()},
- { "code", code.ToString()},
- { "subjectCode", subjectCode.ToString()}
- };*/
- List<ExamResult> exams = new List<ExamResult>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + subjectCode.ToString()))
- {
- ExamResult res = RedisHelper.HGet<ExamResult>(CacheCosmosPrefix + "examResult" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- exams.Add(res);
- }
- List<Paper> paper = new List<Paper>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString()))
- {
- Paper papers = RedisHelper.HGet<Paper>(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- paper.Add(papers);
- }
- Dictionary<string, object> stuMap = new Dictionary<string, object>
- {
- { "schoolCode", "Habook" }
- };
- //List<Student> students = await azureCosmosDBRepository.FindByDict<Student>(stuMap);
- List<Student> students = null;
- if (RedisHelper.Exists(CacheCosmosPrefix + "students"))
- {
- students = RedisHelper.HGet<List<Student>>(CacheCosmosPrefix + "students", ShaHashHelper.GetSHA1(schoolCode.ToString()));
- //builder.Data(info);
- //students.Add(student);
- }
- HashSet<string> knowledge = new HashSet<string>();
- HashSet<string> area = new HashSet<string>();
- List<double> point = new List<double>();
- List<List<double>> result = new List<List<double>>();
- List<Dictionary<string, int[]>> classes = new List<Dictionary<string, int[]>>();
- List<string> ids = new List<string>();
- //string Type = "";
- if (dict.TryGetValue("type", out object Type))
- {
- paper.ForEach(p =>
- {
- p.item.ForEach(i =>
- {
- knowledge.Add(i.field);
- area.Add(i.field);
- });
- });
- }
- else
- {
- paper.ForEach(p =>
- {
- p.item.ForEach(i =>
- {
- i.points.ForEach(o =>
- {
- knowledge.Add(o);
- });
- area.Add(i.field);
- });
- });
- }
- double Qnum = 0;
- //确定高分组 低分组人数
- List<List<double>> re = exams[0].result;
- List<double> resultSum = new List<double>();
- foreach (List<double> data in re)
- {
- resultSum.Add(data.Sum());
- }
- //确定高分组 最低分数
- resultSum.Sort(delegate (double s1, double s2) { return s2.CompareTo(s1); });
- for (int i = resultSum.Count - 1; i >= 0; i--)
- {
- if (resultSum[i] == 0)
- {
- resultSum.Remove(resultSum[i]);
- }
- }
- double rhwCount = resultSum.Count * 0.27;
- double rhw = resultSum[int.Parse(rhwCount.ToString("0"))];
- //确定低分组 最高分数
- resultSum.Sort(delegate (double s1, double s2) { return s1.CompareTo(s2); });
- double rhlCount = resultSum.Count * 0.27;
- double rhl = resultSum[int.Parse(rhwCount.ToString("0"))];
- foreach (ExamResult ex in exams)
- {
- point = ex.point;
- result = ex.result;
- classes = ex.classes;
- ids = ex.ids;
- }
- /* exams.ForEach(e =>
- {
- point = e.Point;
- result = e.Result;
- classes = e.Classes;
- ids = e.Ids;
- });*/
- List<string> knowledgeName = new List<string>();
- foreach (string cla in knowledge)
- {
- knowledgeName.Add(cla);
- }
- for (int k = 0; k < knowledgeName.Count; k++)
- {
- if (null == knowledgeName[k])
- {
- knowledgeName.Remove(knowledgeName[k]);
- }
- }
- List<string> areaName = new List<string>();
- foreach (string cla in area)
- {
- areaName.Add(cla);
- }
- for (int k = 0; k < areaName.Count; k++)
- {
- if (null == areaName[k])
- {
- areaName.Remove(areaName[k]);
- }
- }
- //初始化年级总分
- double total = 0;
- //处理年级单个知识点得分率
- foreach (List<double> grade in result)
- {
- total += grade.Sum();
- }
- foreach (string id in ids)
- {
- if (!id.Equals("0"))
- {
- Qnum++;
- }
- }
- //试卷总分
- double TotalPoint = point.Sum();
- //计算认知层次占比
- List<string> fper = new List<string>();
- for (int a = 0; a < areaName.Count; a++)
- {
- double fieldPoint = 0;
- paper.ForEach(p =>
- {
- int n = 0;
- p.item.ForEach(i =>
- {
- if (i.field != null && i.field.Contains(areaName[a]))
- {
- fieldPoint += point[n];
- }
- n++;
- });
- });
- double fieldPersent = fieldPoint / TotalPoint;
- fper.Add(fieldPersent.ToString("0.00"));
- }
- //求单个知识点所占分数
- List<string> per = new List<string>();
- List<string> gper = new List<string>();
- List<string> knowPer = new List<string>();
- List<Dictionary<string, double>> eper = new List<Dictionary<string, double>>();
- Dictionary<string, object> knowledgeALL = new Dictionary<string, object>();
- Dictionary<string, object> knowledgeMap = new Dictionary<string, object>();
- Dictionary<string, object> classMap = new Dictionary<string, object>();
- Dictionary<string, object> wrongMap = new Dictionary<string, object>();
- HashSet<string> className = new HashSet<string>();
- List<List<string>> wrongPersent = new List<List<string>>();
- List<string> key = new List<string>
- {
- "id",
- "className",
- "seatNO",
- "point",
- "anwPoint",
- "persent"
- };
- List<string> keyWrong = new List<string>
- {
- "name",
- "point",
- "itemNO",
- "persent",
- "wrong",
- "rhw",
- "rlw"
- };
- for (int k = 0; k < knowledgeName.Count; k++)
- {
- List<string> knowledgeClass = new List<string>();
- List<List<string>> stuPersent = new List<List<string>>();
- double OnePoint = 0;
- //获取每个知识点占有多少分值
- double ePoint = 0;
- double anwGPoint = 0;
- double poG = 0;
- int m = 0;
- List<string> valuew = new List<string>();
- List<string> itemNo = new List<string>();
- keyWrong.ForEach(x =>
- {
- valuew.Add("-");
- });
- int wrongCount = 0;
- valuew[0] = knowledgeName[k];
- paper.ForEach(p =>
- {
- int n = 0;
- if (dict.TryGetValue("type", out object Type))
- {
- p.item.ForEach(i =>
- {
- if (i.field != null && i.field.Contains(knowledgeName[k]))
- {
- OnePoint += point[n];
- itemNo.Add((n + 1).ToString());
- }
- n++;
- });
- }
- else
- {
- p.item.ForEach(i =>
- {
- if (i.points != null && i.points.Contains(knowledgeName[k]))
- {
- OnePoint += 1 / Convert.ToDouble(i.points.Count) * point[n];
- itemNo.Add((n + 1).ToString());
- }
- n++;
- });
- }
- valuew[1] = OnePoint.ToString();
- string itemNos = "";
- foreach (string index in itemNo)
- {
- itemNos += index + ",";
- }
- valuew[2] = itemNos[0..^1];
- });
- int rhwC = 0;
- int rhlC = 0;
- foreach (string id in ids)
- {
- if (id.Equals("0") || result[m].Sum() == 0)
- {
- m++;
- continue;
- }
- List<string> values = new List<string>();
- key.ForEach(x =>
- {
- values.Add("-");
- });
- foreach (Student info in students)
- {
- if (info.studentId.Equals(id))
- {
- values[2] = info.seatNo.ToString();
- break;
- }
- }
- //List<string> stu = new List<string>();
- values[0] = id;
- values[1] = "-";
- //List<List<string>> stuItem = new List<List<string>>();
- int statuCount = 0;
- paper.ForEach(p =>
- {
- int n = 0;
- double anwPoint = 0;
- double po = 0;
- p.item.ForEach(i =>
- {
- if (dict.TryGetValue("type", out object Type))
- {
- if (i.field != null && i.field.Contains(knowledgeName[k]))
- {
- //Dictionary<string, double> mapkeyItem = new Dictionary<string, double>();
- //OnePoint += 1 / Convert.ToDouble(i.points.Count) * point[n];
- //当前认知层次在该题占比多少
- ePoint = 1;
- anwPoint += result[m][n] * ePoint;
- //所有学生单个认知层次得分情况
- anwGPoint += result[m][n] * ePoint;
- po += point[n] * ePoint;
- //认知层次所占分数
- poG += point[n] * ePoint;
- if (result[m][n] == 0 && statuCount == 0)
- {
- statuCount++;
- wrongCount++;
- if (result[m].Sum() >= rhw)
- {
- rhwC++;
- }
- if (result[m].Sum() <= rhl)
- {
- rhlC++;
- }
- }
- }
- n++;
- }
- else
- {
- if (i.points != null && i.points.Contains(knowledgeName[k]))
- {
- //Dictionary<string, double> mapkeyItem = new Dictionary<string, double>();
- //OnePoint += 1 / Convert.ToDouble(i.points.Count) * point[n];
- //当前知识点在该题占比多少
- ePoint = 1 / Convert.ToDouble(i.points.Count);
- anwPoint += result[m][n] * ePoint;
- //所有学生单个知识点得分情况
- anwGPoint += result[m][n] * ePoint;
- po += point[n] * ePoint;
- //知识点所占分数
- poG += point[n] * ePoint;
- if (result[m][n] == 0 && statuCount == 0)
- {
- statuCount++;
- wrongCount++;
- if (result[m].Sum() >= rhw)
- {
- rhwC++;
- }
- if (result[m].Sum() <= rhl)
- {
- rhlC++;
- }
- }
- }
- n++;
- }
- });
- double stuPser = anwPoint / po;
- values[3] = po.ToString();
- values[4] = anwPoint.ToString();
- values[5] = stuPser.ToString("0.00");
- //stuItem.Add(values);
- });
- stuPersent.Add(values);
- m++;
- }
- AchievementService.ReName(stuPersent, ids, classes, students);
- double knowPser = anwGPoint / poG;
- knowPer.Add(knowPser.ToString("0.00"));
- //错题关系表
- valuew[3] = knowPser.ToString("0.00");
- valuew[4] = wrongCount.ToString();
- valuew[5] = rhwC.ToString();
- valuew[6] = rhlC.ToString();
- wrongPersent.Add(valuew);
- knowledgeMap.Add(knowledgeName[k], stuPersent);
- //知识点占比
- double persent = OnePoint / TotalPoint;
- foreach (Dictionary<string, int[]> map in classes)
- {
- List<string> classPoints = new List<string>();
- //初始化班级得分
- double anwCPoint = 0;
- double cpo = 0;
- foreach (KeyValuePair<string, int[]> kvp in map)
- {
- className.Add(kvp.Key);
- for (int n = kvp.Value[0]; n < kvp.Value[1]; n++)
- {
- if (result[n].Sum() == 0) continue;
- paper.ForEach(p =>
- {
- int x = 0;
- p.item.ForEach(i =>
- {
- if (dict.TryGetValue("type", out object Type))
- {
- if (i.field != null && i.field.Contains(knowledgeName[k]))
- {
- //当前认知层次在该题占比多少
- ePoint = 1;
- anwCPoint += result[n][x] * ePoint;
- cpo += point[x] * ePoint;
- }
- x++;
- }
- else
- {
- if (i.points != null && i.points.Contains(knowledgeName[k]))
- {
- //当前知识点在该题占比多少
- ePoint = 1 / Convert.ToDouble(i.points.Count);
- anwCPoint += result[n][x] * ePoint;
- cpo += point[x] * ePoint;
- }
- x++;
- }
- });
- });
- }
- }
- double classPser = anwCPoint / cpo;
- knowledgeClass.Add(classPser.ToString("0.00"));
- }
- classMap.Add(knowledgeName[k], knowledgeClass);
- per.Add(persent.ToString("0.00"));
- }
- knowledgeMap.Add("grade", knowPer);
- knowledgeMap.Add("keys", key);
- classMap.Add("className", className);
- wrongMap.Add("keys", keyWrong);
- wrongMap.Add("datas", wrongPersent);
- knowledgeALL.Add("pointList", knowledgeName);
- knowledgeALL.Add("per", per);
- knowledgeALL.Add("level", areaName);
- knowledgeALL.Add("fper", fper);
- knowledgeALL.Add("stupercent", knowledgeMap);
- knowledgeALL.Add("classpercent", classMap);
- knowledgeALL.Add("wrong", wrongMap);
- //builder.Data(knowledgeALL);
- //Redis处理结果集
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), knowledgeALL);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), knowledgeALL);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return knowledgeALL;
- }
- [HttpPost("knowledgePoint")]
- public async Task<BaseResponse> KnowledgePoint(JsonElement request)
- {
- 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>();
- if (RedisHelper.Instance != null)
- {
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "knowledgePoint",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindKnowledgePointRedis(dict, "knowledgePoint"); });
- //数据从redis读取过后进行转换格式
- builder.Data(info);
- }
- else
- {
- info = await FindKnowledgePointRedis(dict, "knowledgePoint");
- builder.Data(info);
- }
- return builder.build();
- }
- [HttpPost("FindExamInfo")]
- public async Task<BaseResponse> FindExamInfo(JsonElement request)
- {
- 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)
- {
- try
- {
- ///RedisHelper.Instance.CurrentSerialize = obj => System.Text.Json.JsonSerializer.Serialize(obj);
- /// RedisHelper.Instance.CurrentDeserialize = (json, type) => System.Text.Json.JsonSerializer.Deserialize(json, type);
- List<ExamInfo> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "FindExamInfo",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindExamInfoRedis(dict, "FindExamInfo"); });
-
- builder.Data(info);
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- else
- {
- List<ExamInfo> info = await FindExamInfoRedis(dict, "FindExamInfo");
- builder.Data(info);
- }
- return builder.build();
- }
- public async Task<List<ExamInfo>> FindExamInfoRedis(Dictionary<string, object> dict, string method)
- {
- try
- {
- List<ExamInfo> info = await _azureCosmos.FindByDict<ExamInfo>(dict);
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return info;
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- [HttpPost("FindExamPaper")]
- public BaseResponse FindExamPaper(JsonElement request)
- {
- //Dictionary<string, object> dict = new Dictionary<string, object>();
- /* var emobj = request.EnumerateObject();
- while (emobj.MoveNext())
- {
- dict[emobj.Current.Name] = emobj.Current.Value;
- }*/
- request.TryGetProperty("subjectCode", out JsonElement subjectCode);
- request.TryGetProperty("code", out JsonElement code);
- /*dict.TryGetValue("subjectCode", out object subjectCode);
- dict.TryGetValue("code", out object code);*/
- ResponseBuilder builder = ResponseBuilder.custom();
- /*if (RedisHelper.Instance != null)
- {
- List<Paper> info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + request.method,
- ShaHashHelper.GetSHA1(JsonNetHelper.ToJson(request.@params)), timeoutSeconds, () => { return FindExamPaperRedis(request.@params, request.method); });
- builder.Data(info);
- }
- else
- {
- List<Paper> info = await FindExamPaperRedis(request.@params, request.method);
- builder.Data(info);
- }*/
- List<Paper> paper = new List<Paper>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString()))
- {
- Paper paper1 = RedisHelper.HGet<Paper>(CacheCosmosPrefix + "paperInfo" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- paper.Add(paper1);
- builder.Data(paper);
- }
- return builder.build();
- }
- public async Task<List<Paper>> FindExamPaperRedis(Dictionary<string, object> dict, string method)
- {
- try
- {
- List<Paper> info = await _azureCosmos.FindByDict<Paper>(dict);
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return info;
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- [HttpPost("FindExamAnswer")]
- public BaseResponse FindExamAnswer(JsonElement request)
- {
- request.TryGetProperty("subjectCode", out JsonElement subjectCode);
- request.TryGetProperty("code", out JsonElement code);
- ResponseBuilder builder = ResponseBuilder.custom();
- List<ExamAnswer> exams = new List<ExamAnswer>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString()))
- {
- ExamAnswer exam = RedisHelper.HGet<ExamAnswer>(CacheCosmosPrefix + "examAnswer" + subjectCode.ToString(), ShaHashHelper.GetSHA1(code.ToString()));
- exams.Add(exam);
- builder.Data(exams);
- }
- return builder.build();
- }
- public async Task<List<ExamAnswer>> FindExamAnswerRedis(Dictionary<string, object> dict, string method)
- {
- try
- {
- List<ExamAnswer> info = await _azureCosmos.FindByDict<ExamAnswer>(dict);
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return info;
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- public async Task<List<ExamAnswer>> FindExamAnswerRedis(Dictionary<string, object> dict)
- {
- try
- {
- List<ExamAnswer> info = await _azureCosmos.FindByDict<ExamAnswer>(dict);
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + "FindExamAnswer"))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "FindExamAnswer", ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + "FindExamAnswer", ShaHashHelper.GetSHA1(dict.ToJsonString()), info);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + "FindExamAnswer", timeoutSeconds);
- }
- }
- return info;
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- [HttpPost("HomeStatistics")]
- public async Task<BaseResponse> HomeStatistics(JsonElement request)
- {
- 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>>();
- if (RedisHelper.Instance != null)
- {
- info = await RedisHelper.CacheShellAsync(CacheCosmosPrefix + "HomeStatistics",
- ShaHashHelper.GetSHA1(dict.ToJsonString()), timeoutSeconds, () => { return FindHomeStatisticsRedis(dict, "HomeStatistics"); });
- //数据从redis读取过后进行转换格式
- builder.Data(info);
- }
- else
- {
- info = await FindHomeStatisticsRedis(dict, "HomeStatistics");
- builder.Data(info);
- }
- return builder.build();
- }
- public async Task<List<Dictionary<string, dynamic>>> FindHomeStatisticsRedis(Dictionary<string, object> dict, string method)
- {
- //request.@params.TryGetValue("subjectCode", out object subjectCode);
- dict.TryGetValue("schoolCode", out object schoolCode);
- dict.TryGetValue("code", out object code);
- Dictionary<string, object> eMap = new Dictionary<string, object>
- {
- { "code", code.ToString()},
- { "type","normal"}
- };
- Dictionary<string, object> SCMap = new Dictionary<string, object>
- {
- { "schoolCode", schoolCode.ToString()},
- };
- //说明 同学校、同类型考试数据
- //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(eMap.ToJsonString()), timeoutSeconds, () => { return FindExamInfoRedis(eMap, "FindExamInfo"); });
- }
- else
- {
- exams = await FindExamInfoRedis(eMap, "FindExamInfo");
- }
- List<ExamInfo> newInfo = new List<ExamInfo>();
- //获取各个学段最新的考试信息
- foreach (IGrouping<string, ExamInfo> group in exams.GroupBy(c => c.conditions.period))
- {
- ExamInfo examInfo = group.ToList().OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
- newInfo.Add(examInfo);
- };
- //newInfo.Select(e => e.type.Equals("union"));
- //List<ExamInfo> unionInfo = newInfo.Where(e => e.type.Equals("union")).ToList();
- //exams.GroupBy(e => e.conditions.period);
- //ExamInfo info = exams.OrderByDescending(e => e.createTime).ToList().FirstOrDefault();
- //查询学校对应的年级信息
- //List<School> schools = await azureCosmosDBRepository.FindByDict<School>(SCMap);
- List<School> schools = new List<School>();
- if (RedisHelper.Exists(CacheCosmosPrefix + "schoolInfo"))
- {
- School sc = RedisHelper.HGet<School>(CacheCosmosPrefix + "schoolInfo",
- ShaHashHelper.GetSHA1(schoolCode.ToString()));
- schools.Add(sc);
- }
- HashSet<string> classList = new HashSet<string>();
- HashSet<string> subjectList = new HashSet<string>();
- List<List<List<string>>> AllPoint = new List<List<List<string>>>();
- List<List<List<string>>> AllPointAverage = new List<List<List<string>>>();
- List<List<List<string>>> AllKeyLine = new List<List<List<string>>>();
- string Period = "";
- string Grade = "";
- List<double> CoreAverage = new List<double>();
- double weightSum = 0;
- try
- {
- List<Period> periods = new List<Period>();
- List<Grade> grades = new List<Grade>();
- foreach (School s in schools)
- {
- periods = s.period;
- }
- periods.ForEach(p =>
- {
- if (p.periodName.Equals("初中"))
- {
- grades = p.grades;
- }
- else if (p.periodName.Equals("高中"))
- {
- grades = p.grades;
- }
- else
- {
- grades = p.grades;
- }
- });
- List<Dictionary<string, object>> map = new List<Dictionary<string, object>>();
- //循环处理不同年级考试信息
- foreach (Grade g in grades)
- {
- for (int i = 0; i < newInfo.Count; i++)
- {
- if (g.gradeCode.Equals(newInfo[i].conditions.grade))
- {
- List<ExamResult> simples = new List<ExamResult>();
- for (int j = 0; j < newInfo[i].conditions.subject.Count; j++)
- {
- ExamResult result = new ExamResult();
- if (RedisHelper.Exists(CacheCosmosPrefix + "examResult" + newInfo[i].conditions.subject[j]))
- {
- result = RedisHelper.HGet<ExamResult>(CacheCosmosPrefix + "examResult" + newInfo[i].conditions.subject[j],
- ShaHashHelper.GetSHA1(newInfo[i].examCode));
- simples.Add(result);
- }
- }
- //List<ExamResult> examResults = new List<ExamResult>();
- /*Dictionary<string, object> sub = new Dictionary<string, object>
- {
- { "code", newInfo[i].id}
- };*/
- Period = newInfo[i].conditions.period;
- Grade = newInfo[i].conditions.grade;
- List<string> subjects = new List<string>();
- List<List<string>> SubjectClassAverage = new List<List<string>>();
- List<List<string>> SubjectAverage = new List<List<string>>();
- //List<List<string>> SubjectClassAverage = new List<List<string>>();
- //List<ExamResult> simples = await azureCosmosDBRepository.FindByDict<ExamResult>(sub);
- // 学生总分
- double coreSum = 0;
- int stuCount = newInfo[i].stuCount;
- //初始化进行人数
- double iPersons = 0;
- //获取进线人数
- iPersons = stuCount * 0.4;
- //
- List<List<double>> subSum = new List<List<double>>();
- if (simples.IsEmpty()) continue;
- double weight = 0.5;
- weightSum += weight;
- int classLen = simples[0].classes.Count;
- for (int cls = 0; cls < classLen; cls++)
- {
- if (simples[0].classes[cls].TryGetValue(simples[0].classes[cls].Keys.ToArray<string>()[0], out int[] indexs))
- {
- List<double> stuScore = new List<double>();
- int stdLen = indexs[1] - indexs[0] + 1;
- for (int n = 0; n < stdLen; n++)
- {
- stuScore.Add(0);
- }
- subSum.Add(stuScore);
- }
- }
- simples.ForEach(s =>
- {
- subjectList.Add(s.subjectCode);
- //计算试卷总分
- double sum = s.point.Sum();
- //int stuSum = 0;
- int classIndex = 0;
- List<string> ClassAverage = new List<string>();
- List<string> Average = new List<string>();
- List<string> passList = new List<string>();
- s.classes.ForEach(c =>
- {
- List<List<string>> classPRL = new List<List<string>>();
- //初始化班级总分
- double classPoint = 0;
- //初始化班级缺考人数
- int classCount = 0;
- //初始化班级平均得分率
- double points = 0;
- //初始化班级平均得分率
- double AveragePoints = 0;
- //初始化各班参考人数
- int counts = 0;
- //c.Keys遍历key值
- foreach (string key in c.Keys)
- {
- classList.Add(key);
- }
- //每个班级平均分
- foreach (int[] value in c.Values)
- {
- for (int i = value[0]; i <= value[1]; i++)
- {
- //初始化学生单科个人得分
- double stuPoints = s.result[i].Sum();
- subSum[classIndex][i - value[0]] = stuPoints + subSum[classIndex][i - value[0]];
- classPoint += s.result[i].Sum();
- coreSum += s.result[i].Sum();
- if (s.result[i].Sum() == 0)
- {
- classCount++;
- }
- }
- //每个班级实际参考人数
- counts = value[1] - value[0] - classCount + 1;
- //stuSum += counts;
- points = Convert.ToDouble(classPoint) / counts / sum;
- //计算每个班级平均得分
- AveragePoints = Convert.ToDouble(classPoint) / counts;
- ClassAverage.Add(points.ToString("0.000"));
- Average.Add(AveragePoints.ToString());
- }
- classIndex += 1;
- });
- SubjectClassAverage.Add(ClassAverage);
- SubjectAverage.Add(Average);
- //subAverage = subjectPoint / ClassAverage.Count();
- //subjectAverage.Add(subAverage.ToString("0.00"));
- });
- double core = coreSum / stuCount * weight;
- CoreAverage.Add(core);
- AllPoint.Add(SubjectClassAverage);
- AllPointAverage.Add(SubjectAverage);
- //处理人数为整
- string ip = iPersons.ToString("0");
- //初始化进线分数
- int ipoint = 0;
- List<int> AllPoints = new List<int>();
- foreach (List<double> points in subSum)
- {
- foreach (int po in points)
- {
- AllPoints.Add(po);
- }
- }
- for (int sn = 0; sn < subSum.Count; sn++)
- {
- for (int j = 0; j < subSum[sn].Count; j++)
- {
- if (subSum[sn][j].Equals("0"))
- {
- subSum[sn].Remove(subSum[sn][j]);
- }
- }
- }
- //计算成绩年级排名
- AllPoints.Sort(delegate (int s1, int s2) { return s2.CompareTo(s1); });
- ipoint = AllPoints[int.Parse(ip)];
- int m = 0;
- List<List<string>> KeyLine = new List<List<string>>();
- foreach (List<double> points in subSum)
- {
- List<string> detail = new List<string>();
- double sum = points.Count;
- int l = 0;
- for (int mq = 0; mq < points.Count; mq++)
- {
- if (points[i] > ipoint)
- {
- l++;
- }
- }
- double Lines = l;
- detail.Add(Lines.ToString());
- detail.Add(points.Count.ToString());
- var t3 = Math.Floor(Math.Round(decimal.Parse((Lines / sum).ToString("0.000")), 2) * 100);
- detail.Add(t3.ToString());
- KeyLine.Add(detail);
- m++;
- }
- AllKeyLine.Add(KeyLine);
- }
- //年级成就指标
- if (weightSum == 0)
- {
- weightSum = 1;
- }
- double index = CoreAverage.Sum() / weightSum;
- List<List<double>> AveragePoint = new List<List<double>>();
- List<List<double>> AverageClassPoint = new List<List<double>>();
- //List<double> ClassCore = new List<double>();
- int k = AllPoint.Count;
- if (k > 0)
- {
- for (int m = 0; m < AllPoint[0].Count; m++)
- {
- List<double> SubjectAverage = new List<double>();
- for (int n = 0; n < AllPoint[0][m].Count; n++)
- {
- double startPoint = 0;
- for (int f = 0; f < k; f++)
- {
- startPoint = double.Parse(AllPoint[f][m][n]) + startPoint;
- }
- SubjectAverage.Add(startPoint / k);
- }
- AveragePoint.Add(SubjectAverage);
- }
- }
- //每个班级成就指标
- int p = AllPointAverage.Count;
- if (p > 0)
- {
- for (int m = 0; m < AllPointAverage[0].Count; m++)
- {
- List<double> SubjectAverage = new List<double>();
- for (int n = 0; n < AllPointAverage[0][m].Count; n++)
- {
- double startPoint = 0;
- for (int f = 0; f < k; f++)
- {
- startPoint = double.Parse(AllPointAverage[f][m][n]) + startPoint;
- }
- SubjectAverage.Add(startPoint / k);
- }
- AverageClassPoint.Add(SubjectAverage);
- }
- }
- int c = AverageClassPoint.Count;
- List<double> ClassCore = new List<double>();
- if (c > 0)
- {
- for (int j = 0; j < AverageClassPoint[0].Count; j++)
- {
- double startAverage = 0;
- for (int f = 0; f < c; f++)
- {
- startAverage = AverageClassPoint[f][j] + startAverage;
- }
- ClassCore.Add(startAverage / weightSum);
- }
- }
- //班级平均进线率
- int ExamCount = AllKeyLine.Count;
- List<List<double>> KeyLines = new List<List<double>>();
- if (ExamCount > 0)
- {
- for (int m = 0; m < AllKeyLine[0].Count; m++)
- {
- List<double> ClassLine = new List<double>();
- for (int n = 0; n < AllKeyLine[0][m].Count; n++)
- {
- double startPoint = 0;
- for (int f = 0; f < ExamCount; f++)
- {
- startPoint = double.Parse(AllKeyLine[f][m][n]) + startPoint;
- }
- ClassLine.Add(startPoint / ExamCount);
- }
- KeyLines.Add(ClassLine);
- }
- }
- Dictionary<string, object> AveragePointMap = new Dictionary<string, object>
- {
- { "Period",Period},
- { "Grade",Grade},
- { "index", index},
- { "className", classList },
- { "subjectName", subjectList },
- { "AveragePoint", AveragePoint },
- //{ "AverageClassPoint", AverageClassPoint },
- { "ClassCore", ClassCore },
- { "KeyLines",KeyLines}
- };
- map.Add(AveragePointMap);
- }
- }
- //Redis处理结果集
- if (RedisHelper.Instance != null)
- {
- if (!RedisHelper.Exists(CacheCosmosPrefix + method))
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), map);
- }
- else
- {
- await RedisHelper.HSetAsync(CacheCosmosPrefix + method, ShaHashHelper.GetSHA1(dict.ToJsonString()), map);
- await RedisHelper.ExpireAsync(CacheCosmosPrefix + method, timeoutSeconds);
- }
- }
- return map;
- }
- catch (Exception e)
- {
- throw new BizException(e.Message);
- }
- }
- }
- }
|