TriggerExam.cs 91 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. using Azure.Cosmos;
  2. using Azure.Messaging.ServiceBus;
  3. using TEAMModelOS.SDK.DI;
  4. using TEAMModelOS.SDK.Extension;
  5. using TEAMModelOS.SDK;
  6. using TEAMModelOS.SDK.Models;
  7. using TEAMModelOS.SDK.Models.Service;
  8. using HTEXLib.COMM.Helpers;
  9. using ClouDASLibx;
  10. using System.Text.Json;
  11. using System.Collections.Generic;
  12. using System.Threading.Tasks;
  13. using System;
  14. using System.Linq;
  15. using TEAMModelOS.SDK.Models.Service.BI;
  16. using Azure.Storage.Blobs.Models;
  17. using System.IO;
  18. using System.Text;
  19. using System.Text.Json.Nodes;
  20. using TEAMModelOS.SDK.Helper.Common.JsonHelper.JsonPath;
  21. using Newtonsoft.Json.Linq;
  22. using TEAMModelOS.SDK.Models.Cosmos.Student;
  23. using HTEXLib.Helpers.ShapeHelpers;
  24. using TEAMModelOS.Models.Dto;
  25. using TEAMModelOS.SDK.Models.Cosmos.Common;
  26. using DocumentFormat.OpenXml.Office2010.Excel;
  27. using DocumentFormat.OpenXml.Drawing.Charts;
  28. using DocumentFormat.OpenXml.Vml;
  29. using System.Net.Http;
  30. using Newtonsoft.Json;
  31. using System.Net;
  32. using System.Security.Policy;
  33. using Microsoft.Extensions.Configuration;
  34. using DocumentFormat.OpenXml.EMMA;
  35. using Microsoft.Extensions.Options;
  36. using TEAMModelOS.Models;
  37. namespace TEAMModelOS.FunctionV4
  38. {
  39. public class TriggerExam
  40. {
  41. public static async Task Trigger(CoreAPIHttpService _coreAPIHttpService, AzureCosmosFactory _azureCosmos, AzureServiceBusFactory _serviceBus, AzureStorageFactory _azureStorage, DingDing _dingDing,
  42. CosmosClient client, JsonElement input, TriggerData data, IHttpClientFactory _httpClient, IConfiguration _configuration, HttpTrigger _httpTrigger)
  43. {
  44. List<ExamClassResult> examClassResults = new();
  45. List<ExamSubject> examSubjects = new();
  46. try
  47. {
  48. if ((data.status != null && data.status.Value == 404))
  49. {
  50. await client.GetContainer(Constant.TEAMModelOS, "Common").DeleteItemStreamAsync(data.id, new PartitionKey(data.code));
  51. ActivityList activity = input.ToObject<ActivityList>();
  52. await ActivityService.DeleteActivity(_coreAPIHttpService, client, _dingDing, activity);
  53. var table_cancel = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
  54. List<ChangeRecord> records = await table_cancel.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", data.id } });
  55. foreach (var record in records)
  56. {
  57. try
  58. {
  59. await table_cancel.DeleteSingle<ChangeRecord>(record.PartitionKey, record.RowKey);
  60. await _serviceBus.GetServiceBusClient().CancelMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), record.sequenceNumber);
  61. }
  62. catch (Exception)
  63. {
  64. continue;
  65. }
  66. }
  67. await BIStats.SetTypeAddStats(client, _dingDing, data.school, "Exam", -1, careDate: data.startTime);//BI统计增/减量
  68. return;
  69. }
  70. ExamInfo info = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ExamInfo>(data.id, new Azure.Cosmos.PartitionKey($"{data.code}"));
  71. if (info != null)
  72. {
  73. if (info.scope.Equals("teacher", StringComparison.OrdinalIgnoreCase) || info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
  74. {
  75. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{info.creatorId}") }))
  76. {
  77. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  78. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  79. {
  80. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  81. {
  82. examClassResults.Add(obj.ToObject<ExamClassResult>());
  83. }
  84. }
  85. }
  86. }
  87. else
  88. {
  89. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamClassResult-{data.school}") }))
  90. {
  91. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  92. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  93. {
  94. foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
  95. {
  96. examClassResults.Add(obj.ToObject<ExamClassResult>());
  97. }
  98. }
  99. }
  100. }
  101. var table = _azureStorage.GetCloudTableClient().GetTableReference("ChangeRecord");
  102. string PartitionKey = string.Format("{0}{1}{2}", info.code, "-", info.progress);
  103. List<ChangeRecord> records = await table.FindListByDict<ChangeRecord>(new Dictionary<string, object>() { { "RowKey", data.id }, { "PartitionKey", PartitionKey } });
  104. //处理科目信息
  105. List<string> sub = new List<string>();
  106. School sc = new();
  107. if (!string.IsNullOrEmpty(info.school) && !info.school.Equals("SYSTEM_NO_SCHOOL")) {
  108. sc = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(info.school, new Azure.Cosmos.PartitionKey("Base"));
  109. }
  110. foreach (ExamSubject subject in info.subjects)
  111. {
  112. sub.Add(subject.id);
  113. }
  114. //整合名单
  115. List<string> classes = ExamService.getClasses(info.classes, info.stuLists);
  116. //ChangeRecord record = await client.GetContainer(Constant.TEAMModelOS, "Common").ReadItemAsync<ChangeRecord>(input.Id, new Azure.Cosmos.PartitionKey($"{info.progress}"));
  117. switch (info.progress)
  118. {
  119. case "pending":
  120. var message = new ServiceBusMessage(new { id = data.id, progress = "going", code = data.code }.ToJsonString());
  121. message.ApplicationProperties.Add("name", "Exam");
  122. if (records.Count > 0)
  123. {
  124. try
  125. {
  126. await _serviceBus.GetServiceBusClient().CancelMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
  127. }
  128. catch (Exception)
  129. {
  130. }
  131. long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(data.startTime));
  132. records[0].sequenceNumber = start;
  133. await table.SaveOrUpdate<ChangeRecord>(records[0]);
  134. //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
  135. }
  136. else
  137. {
  138. long start = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), message, DateTimeOffset.FromUnixTimeMilliseconds(data.startTime));
  139. //string pk = String.Format("{0}{1}{2}", info.code, "-", "pending");
  140. ChangeRecord changeRecord = new ChangeRecord
  141. {
  142. RowKey = data.id,
  143. PartitionKey = PartitionKey,
  144. sequenceNumber = start,
  145. msgId = message.MessageId
  146. };
  147. await table.Save<ChangeRecord>(changeRecord);
  148. //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
  149. }
  150. break;
  151. case "going":
  152. try
  153. {
  154. //向学生或醍摩豆账号发起通知
  155. #region
  156. //Notice notice = new Notice()
  157. //{
  158. // msgId = info.id,
  159. // creation = info.startTime,
  160. // expire = info.endTime,
  161. // creatorId = info.creatorId,
  162. // stuids = studentss,
  163. // tmdids = tmdids,
  164. // type = "notice",//评测参加通知
  165. // priority = "normal",
  166. // school = info.school,
  167. // scope = info.scope,
  168. // //data = new { }.ToJsonString()
  169. // body = new Body { sid = info.id, scode = info.code, spk = info.pk, biztype = "exam-join" }
  170. //};
  171. //var messageBlob = new ServiceBusMessage(notice.ToJsonString());
  172. //messageBlob.ApplicationProperties.Add("name", "Notice");
  173. //await _serviceBus.GetServiceBusClient().SendMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageBlob);
  174. #endregion
  175. //List<string> classes = new List<string>();
  176. //处理活动中间件
  177. List<RGroupList> members = await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
  178. if (examClassResults.Count == 0)
  179. {
  180. foreach (string cla in classes)
  181. {
  182. int m = 0;
  183. RGroupList rGroup = new();
  184. rGroup = members.Where(m => m.id.Equals(cla)).FirstOrDefault();
  185. foreach (ExamSubject subject in info.subjects)
  186. {
  187. string classCode = string.Empty;
  188. string cname = string.Empty;
  189. if (string.IsNullOrEmpty(info.school) || !info.scope.Equals("school", StringComparison.OrdinalIgnoreCase))
  190. {
  191. classCode = "ExamClassResult-" + info.creatorId;
  192. }
  193. else
  194. {
  195. classCode = "ExamClassResult-" + info.school;
  196. }
  197. cname = members.Where(m => m.id.Equals(cla)).FirstOrDefault()?.name;
  198. // 预处理活动中间件信息
  199. ExamClassResult result = new()
  200. {
  201. code = classCode,
  202. examId = info.id,
  203. id = Guid.NewGuid().ToString(),
  204. subjectId = subject.id,
  205. year = info.year,
  206. scope = info.scope
  207. };
  208. result.info.id = cla;
  209. result.info.name = cname;
  210. List<string> ans = new();
  211. List<List<string>> anses = new();
  212. List<List<Details>> marks = new();
  213. List<double> ansPoint = new();
  214. List<(string sId, string scode)> ids = new();
  215. foreach (double p in info.papers[m].point)
  216. {
  217. //Details details = new Details();
  218. //ans.Add(new List<string>());
  219. anses.Add(new List<string>());
  220. marks.Add(new List<Details>());
  221. ansPoint.Add(-1);
  222. }
  223. var sresponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"Class-{info.school}"));
  224. if (sresponse.Status == 200)
  225. {
  226. using var json = await JsonDocument.ParseAsync(sresponse.ContentStream);
  227. Class classroom = json.ToObject<Class>();
  228. foreach (SDK.Models.Period period in sc.period)
  229. {
  230. if (period.id.Equals(classroom.periodId))
  231. {
  232. foreach (Semester semester in period.semesters)
  233. {
  234. if (semester.start == 1)
  235. {
  236. int year = DateTimeOffset.UtcNow.Year;
  237. int month = DateTimeOffset.UtcNow.Month;
  238. int day = DateTimeOffset.UtcNow.Day;
  239. int time = 0;
  240. if (month == semester.month)
  241. {
  242. time = day >= semester.day ? 0 : 1;
  243. }
  244. else
  245. {
  246. time = month > semester.month ? 0 : 1;
  247. }
  248. int eyear = year - time;
  249. result.gradeId = (eyear - classroom.year).ToString();
  250. }
  251. }
  252. }
  253. }
  254. //result.info.id = classroom.id;
  255. //result.info.name = classroom.name;
  256. //result.gradeId = classroom.year.ToString();
  257. //处理班级人数
  258. /* await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryStreamIterator(queryText: $"select c.id from c where c.classId = '{classroom.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{info.school}") }))
  259. {
  260. using var json_stu = await JsonDocument.ParseAsync(item.ContentStream);
  261. if (json_stu.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  262. {
  263. var accounts = json_stu.RootElement.GetProperty("Documents").EnumerateArray();
  264. while (accounts.MoveNext())
  265. {
  266. JsonElement account = accounts.Current;
  267. ids.Add(account.GetProperty("id").GetString());
  268. }
  269. }
  270. }*/
  271. }
  272. /*if (info.scope.Equals("private", StringComparison.OrdinalIgnoreCase))
  273. {
  274. var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"GroupList"));
  275. if (stuResponse.Status == 200)
  276. {
  277. using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
  278. GroupList stuList = json.ToObject<GroupList>();
  279. //result.info.id = stuList.id;
  280. result.info.name = stuList.name;
  281. //处理发布对象为自选名单(个人)
  282. foreach (Member stus in stuList.members)
  283. {
  284. if (!ids.Contains(stus.id))
  285. {
  286. ids.Add(stus.id);
  287. }
  288. }
  289. }
  290. }
  291. else
  292. {
  293. var stuResponse = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(cla, new Azure.Cosmos.PartitionKey($"GroupList-{info.school}"));
  294. if (stuResponse.Status == 200)
  295. {
  296. using var json = await JsonDocument.ParseAsync(stuResponse.ContentStream);
  297. GroupList stuList = json.ToObject<GroupList>();
  298. //result.info.id = stuList.id;
  299. result.info.name = stuList.name;
  300. //处理发布对象为自选名单(校本)
  301. foreach (Member stus in stuList.members)
  302. {
  303. if (!ids.Contains(stus.id))
  304. {
  305. ids.Add(stus.id);
  306. }
  307. }
  308. }
  309. }*/
  310. foreach (RMember member in rGroup.members)
  311. {
  312. ids.Add((member.id, member.code));
  313. }
  314. //ids = members.Where(c => c.id.Equals(cla)).SelectMany(m => m.members).Select(g => g.id).ToList();
  315. foreach (var (sId, scode) in ids)
  316. {
  317. result.mark.Add(marks);
  318. result.studentIds.Add(sId);
  319. //result.scIds.Add(scode ?? "");
  320. result.studentAnswers.Add(ans);
  321. result.studentScores.Add(ansPoint);
  322. result.ans.Add(anses);
  323. result.sum.Add(0);
  324. result.status.Add(1);
  325. }
  326. //result.progress = info.progress;
  327. result.school = info.school;
  328. m++;
  329. await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(result, new Azure.Cosmos.PartitionKey($"{result.code}"));
  330. }
  331. }
  332. }
  333. else
  334. {
  335. //处理单科结算时科目与试卷信息匹配的问题
  336. int gno = 0;
  337. foreach (ExamSubject subject in info.subjects)
  338. {
  339. if (subject.classCount == classes.Count)
  340. {
  341. await createClassResultAsync(info, examClassResults, subject, gno, _azureCosmos, _dingDing, _azureStorage, _httpClient, _configuration);
  342. }
  343. gno++;
  344. }
  345. var isScore = examClassResults.SelectMany(e => e.studentScores).ToList().Exists(c => c.Contains(-1));
  346. int newStatus = 0;
  347. if (!isScore)
  348. {
  349. newStatus = 1;
  350. }
  351. Settlement settlement = await getMore(client, info);
  352. long nowTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
  353. //判断评分状态是否发生变化,便于实时的更新评测基本信息
  354. if (info.average != settlement.score || info.sStatus != newStatus)
  355. {
  356. info.sRate = settlement.rate;
  357. info.sStatus = newStatus;
  358. info.updateTime = nowTime;
  359. info.average = settlement.score;
  360. await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
  361. }
  362. }
  363. }
  364. catch (Exception e)
  365. {
  366. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测going状态异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  367. }
  368. finally
  369. {
  370. // 发送信息通知
  371. var messageEnd = new ServiceBusMessage(new { id = data.id, progress = "finish", code = data.code }.ToJsonString());
  372. messageEnd.ApplicationProperties.Add("name", "Exam");
  373. if (records.Count > 0)
  374. {
  375. long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(data.endTime));
  376. try
  377. {
  378. await _serviceBus.GetServiceBusClient().CancelMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), records[0].sequenceNumber);
  379. }
  380. catch (Exception)
  381. {
  382. }
  383. records[0].sequenceNumber = end;
  384. await table.SaveOrUpdate<ChangeRecord>(records[0]);
  385. //await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(record, record.id, new Azure.Cosmos.PartitionKey($"{record.code}"));
  386. }
  387. else
  388. {
  389. long end = await _serviceBus.GetServiceBusClient().SendScheduleMessageAsync(Environment.GetEnvironmentVariable("Azure:ServiceBus:ActiveTask"), messageEnd, DateTimeOffset.FromUnixTimeMilliseconds(data.endTime));
  390. //string pk = String.Format("{0}{1}{2}", info.code, "-", "going");
  391. ChangeRecord changeRecord = new ChangeRecord
  392. {
  393. RowKey = data.id,
  394. PartitionKey = PartitionKey,
  395. sequenceNumber = end,
  396. msgId = messageEnd.MessageId
  397. };
  398. await table.Save<ChangeRecord>(changeRecord);
  399. //await client.GetContainer(Constant.TEAMModelOS, "Common").CreateItemAsync(changeRecord, new Azure.Cosmos.PartitionKey($"{changeRecord.code}"));
  400. }
  401. }
  402. break;
  403. case "finish":
  404. int fno = 0;
  405. try
  406. {
  407. //用来判定是否完成评分
  408. //bool isScore = true;
  409. await resultStatus(client, examClassResults);
  410. await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
  411. foreach (ExamSubject subject in info.subjects)
  412. {
  413. await createClassResultAsync(info, examClassResults, subject, fno, _azureCosmos, _dingDing, _azureStorage, _httpClient, _configuration);
  414. fno++;
  415. }
  416. Settlement settlement = await getMore(client, info);
  417. var isScore = examClassResults.SelectMany(e => e.studentScores).ToList().Exists(c => c.Contains(-1));
  418. int newStatus = 0;
  419. if (!isScore)
  420. {
  421. newStatus = 1;
  422. }
  423. //判断均分是否发生变化,便于实时的更新评测基本信息
  424. if (info.sRate != settlement.rate || info.average != settlement.score || info.sStatus != newStatus || info.qRate != settlement.qrate)
  425. {
  426. info.sRate = settlement.rate;
  427. info.average = settlement.score;
  428. info.sStatus = newStatus;
  429. info.lostStu = settlement.stus;
  430. info.stuCount = settlement.total;
  431. info.qRate = settlement.qrate;
  432. //新增数据推送 obj => Portrait
  433. Portrait portrait = new()
  434. {
  435. schoolCode = info.school,
  436. periodId = info.period.id,
  437. subjectId = "subject_exam"
  438. };
  439. var period = sc.period.Where(x => x.id.Equals(info.period.id)).FirstOrDefault();
  440. //获取学期信息
  441. if (null != period) {
  442. var (currSemester, studyYear, date, nextSemester) = SchoolService.GetSemester(period, info.startTime);
  443. //获取学生信息
  444. (List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, info.classes, info.school);
  445. foreach (var member in rmembers)
  446. {
  447. if (info.lostStu.Contains(member.id))
  448. {
  449. continue;
  450. }
  451. PortraitStudent student = new()
  452. {
  453. studentId = member.id,
  454. name = member.name,
  455. classId = member.classId
  456. };
  457. SemesterData semesterData = new()
  458. {
  459. examName = info.name,
  460. examId = info.id,
  461. examDate = info.startTime,
  462. examType = info.examType?.name,
  463. year = info.year,
  464. semesterId = currSemester.id,
  465. totalScore = info.papers.SelectMany(x => x.point).Sum(),
  466. sumScore = examClassResults.SelectMany(x => x.sum).Sum(),
  467. excellenceRate = 0,
  468. passRate = 0,
  469. };
  470. int index = 0;
  471. foreach (var sj in info.subjects)
  472. {
  473. ItemScore item = new()
  474. {
  475. name = sj.name,
  476. score = examClassResults.Where(x => x.subjectId.Equals(sj.id)).FirstOrDefault().sum.Sum(),
  477. time = info.startTime,
  478. totalScore = info.papers[index].point.Sum(),
  479. type = sj.id
  480. };
  481. index++;
  482. semesterData.itemScore.Add(item);
  483. }
  484. student.semesterData.Add(semesterData);
  485. portrait.students.Add(student);
  486. }
  487. string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
  488. var (status, json) = await _httpTrigger.RequestHttpTrigger(portrait.ToJson(), location, "upsert-student-portrait");
  489. }
  490. //PortraitStudent student = new();
  491. //处理试卷活动结束统计账户信息
  492. List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, info.school, info.classes, info.stuLists, null);
  493. info.staffIds = idList;
  494. await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
  495. }
  496. }
  497. catch (Exception e)
  498. {
  499. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测finish状态异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  500. }
  501. break;
  502. }
  503. }
  504. }
  505. catch (CosmosException e)
  506. {
  507. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
  508. }
  509. catch (Exception e)
  510. {
  511. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测结算异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  512. }
  513. }
  514. public static async Task resultStatus(CosmosClient client, List<ExamClassResult> examClassResults)
  515. {
  516. List<Task<ItemResponse<ExamClassResult>>> tasks = new();
  517. //结算单科单班的标准差和平均分
  518. foreach (ExamClassResult classResult in examClassResults)
  519. {
  520. //标记单科单班总得分
  521. double subScore = 0;
  522. //标准差
  523. double sPowSum = 0;
  524. List<double> newSumScore = new List<double>();
  525. List<double> effectiveScore = new List<double>();
  526. int lostStu = classResult.status.Where(c => c == 1).ToList().Count;
  527. var scount = classResult.studentIds.Count - lostStu;
  528. int index = 0;
  529. if (classResult.status.Count > 0)
  530. {
  531. foreach (var sta in classResult.status)
  532. {
  533. if (sta == 1)
  534. {
  535. for (int i = 0; i < classResult.studentScores[index].Count; i++)
  536. {
  537. if (classResult.studentScores[index][i] == -1)
  538. {
  539. classResult.studentScores[index][i] = 0;
  540. }
  541. }
  542. }
  543. else if (sta == 0)
  544. {
  545. //var ans = classResult.studentAnswers[index];
  546. //该学生缺考,历史数据的判定
  547. //if (ans.Count == 0)
  548. //{
  549. for (int i = 0; i < classResult.studentScores[index].Count; i++)
  550. {
  551. if (classResult.studentScores[index][i] == -1)
  552. {
  553. classResult.studentScores[index][i] = 0;
  554. }
  555. }
  556. /*if (ans.Count == 0)
  557. {
  558. classResult.status[index] = 1;
  559. } */
  560. //}
  561. }
  562. index++;
  563. }
  564. }
  565. else
  566. {
  567. List<int> sta = new();
  568. foreach (var id in classResult.studentIds)
  569. {
  570. sta.Add(0);
  571. }
  572. classResult.status = sta;
  573. foreach (var ans in classResult.studentAnswers)
  574. {
  575. //该学生缺考,历史数据的判定
  576. if (ans.Count == 0)
  577. {
  578. for (int i = 0; i < classResult.studentScores[index].Count; i++)
  579. {
  580. if (classResult.studentScores[index][i] == -1)
  581. {
  582. classResult.studentScores[index][i] = 0;
  583. }
  584. }
  585. classResult.status[index] = 1;
  586. }
  587. index++;
  588. }
  589. }
  590. int sIndex = 0;
  591. foreach (List<double> sc in classResult.studentScores)
  592. {
  593. List<double> newSc = new List<double>();
  594. foreach (double ssc in sc)
  595. {
  596. if (ssc == -1)
  597. {
  598. newSc.Add(0);
  599. }
  600. else
  601. {
  602. newSc.Add(ssc);
  603. }
  604. }
  605. double nc = Math.Round(newSc.Sum(), 2);
  606. if (classResult.status[sIndex] == 0)
  607. {
  608. effectiveScore.Add(nc);
  609. };
  610. newSumScore.Add(nc);
  611. subScore += nc;
  612. classResult.sum[sIndex] = nc;
  613. sIndex++;
  614. }
  615. double rateScore = scount > 0 ? Math.Round(subScore * 1.0 / scount, 2) : 0;
  616. //有效分数
  617. foreach (double scs in effectiveScore)
  618. {
  619. sPowSum += Math.Pow(scs - rateScore, 2);
  620. }
  621. classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
  622. classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
  623. classResult.progress = true;
  624. tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}")));
  625. }
  626. await Task.WhenAll(tasks);
  627. }
  628. public static async Task<Settlement> getMore(CosmosClient client, ExamInfo info)
  629. {
  630. //计算单次考试简易统计信息
  631. Settlement settlement = new();
  632. List<ExamResult> examResults = new();
  633. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
  634. queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
  635. {
  636. examResults.Add(item);
  637. }
  638. if (examResults.Count > 0)
  639. {
  640. //记录某次考试所有学生得分总分
  641. double score = 0;
  642. double allScore = 0;
  643. int stuCount = 0;
  644. //标准差
  645. double powSum = 0;
  646. List<string> losStu = new List<string>();
  647. //当前完成考试得人数
  648. int total = examResults[0].studentIds.Distinct().Count();
  649. //先与第一个值取并集
  650. losStu = losStu.Union(examResults[0].lostStus).ToList();
  651. foreach (ExamResult examResult in examResults)
  652. {
  653. //取交集
  654. losStu = losStu.Intersect(examResult.lostStus).ToList();
  655. }
  656. //处理缺考的学生
  657. List<string> stus = examResults[0].studentIds.Except(losStu).ToList();
  658. foreach (ExamResult examResult in examResults)
  659. {
  660. foreach (var id in stus)
  661. {
  662. int index = examResult.studentIds.IndexOf(id);
  663. score += examResult.studentScores[index].Sum();
  664. }
  665. }
  666. stuCount = total - losStu.Count;
  667. double NewsRateScore = stuCount > 0 ? Math.Round(score * 1.0 / stuCount, 2) : 0;
  668. foreach (PaperSimple simple in info.papers)
  669. {
  670. allScore += simple.point.Sum();
  671. }
  672. //计算全科标准差
  673. foreach (string id in stus)
  674. {
  675. double sc = 0;
  676. foreach (ExamResult result in examResults)
  677. {
  678. if (result.studentScores.Count > 0)
  679. {
  680. sc += result.studentScores[result.studentIds.IndexOf(id)].Sum();
  681. }
  682. }
  683. powSum += Math.Pow(sc - NewsRateScore, 2);
  684. }
  685. info.standard = Math.Round(total - losStu.Count > 0 ? Math.Pow(powSum / (total - losStu.Count), 0.5) : 0, 2);
  686. double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
  687. double qrate = Math.Round(total > 0 ? losStu.Count * 1.0 / total * 100 : 0, 2);
  688. settlement.rate = NewsRate;
  689. settlement.score = NewsRateScore;
  690. settlement.stus = losStu;
  691. settlement.total = total;
  692. settlement.qrate = qrate;
  693. }
  694. return settlement;
  695. }
  696. //处理全部学生选题计数
  697. public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult er, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
  698. {
  699. try
  700. {
  701. List<double> scores = new List<double>();
  702. foreach (List<double> sc in er.studentScores)
  703. {
  704. scores.Add(sc.Sum());
  705. }
  706. //确定高分组 最低分数
  707. //var srowallorder = scores.EnumerateIndexed().OrderByDescending(g => g.Item2); //各生總分排序
  708. //var srowallorder = scores.OrderByDescending(g => g);
  709. double[] point = StringHelper.ListTodouble(er.paper.point);
  710. double[,] result = StringHelper.ListToDouble(er.studentScores);
  711. var cdm = new ClouDASMatrix(result, point);
  712. scores.Sort((s1, s2) => { return s2.CompareTo(s1); });
  713. int rhwCount = cdm.SH.Count();
  714. double rhw = cdm.SH.LastOrDefault().Item2;
  715. int rhlCount = cdm.SL.Count();
  716. double rhl = cdm.SL.FirstOrDefault().Item2;
  717. List<string> phs = new();
  718. List<string> pls = new();
  719. //分别获取高分组低分组人员
  720. foreach (var ph in cdm.SH)
  721. {
  722. phs.Add(er.studentIds[ph.Item1]);
  723. }
  724. foreach (var pl in cdm.SL)
  725. {
  726. pls.Add(er.studentIds[pl.Item1]);
  727. }
  728. /* if (scores.Count > 3)
  729. {
  730. rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
  731. rhw = rhwCount > 0 ? scores[rhwCount - 1] : 0;
  732. rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
  733. rhl = rhlCount > 0 ? scores[rhlCount] : 0;
  734. }
  735. else
  736. {
  737. rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
  738. rhw = rhwCount > 0 ? scores[rhwCount] : 0;
  739. rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
  740. rhl = rhlCount > 0 ? scores[rhlCount - 1] : 0;
  741. }*/
  742. /*int rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
  743. double rhw = rhwCount > 0 ? scores[rhwCount-1] : 0;
  744. //var rhww = srowallorder.Take(Convert.ToInt32(Math.Floor(scores.Count * 0.27)));
  745. //确定低分组 最高分数
  746. //scores.Sort((s1, s2) => { return s1.CompareTo(s2); });
  747. int rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
  748. double rhl = rhlCount > 0 ? scores[rhlCount-1] : 0;*/
  749. //var rhll = srowallorder.Skip(Convert.ToInt32(Math.Ceiling(scores.Count * 0.73)));
  750. //存放高分组学生ID
  751. List<string> phId = new();
  752. List<string> plId = new();
  753. List<List<List<string>>> opth = new();
  754. List<List<List<string>>> optl = new();
  755. List<double> akp = await knowledgeCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
  756. List<double> afp = await fieldCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
  757. int PHCount = 0;
  758. int PLCount = 0;
  759. foreach (ExamClassResult classResult in classResults)
  760. {
  761. if (classResult.subjectId.Equals(subject.id))
  762. {
  763. foreach (string id in classResult.studentIds)
  764. {
  765. int index = classResult.studentIds.IndexOf(id);
  766. if (classResult.studentScores.Count > 0)
  767. {
  768. if (phs.Contains(id))
  769. {
  770. if (classResult.ans.Count > 0)
  771. {
  772. opth.Add(classResult.ans[index]);
  773. PHCount++;
  774. continue;
  775. }
  776. }
  777. if (pls.Contains(id))
  778. {
  779. if (classResult.ans.Count > 0)
  780. {
  781. optl.Add(classResult.ans[index]);
  782. PLCount++;
  783. continue;
  784. }
  785. }
  786. }
  787. }
  788. }
  789. }
  790. er.phc = getMore(info, no, opth);
  791. er.plc = getMore(info, no, optl);
  792. er.afp = afp;
  793. er.akp = akp;
  794. }
  795. catch (Exception ex)
  796. {
  797. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测作答记录结算异常{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  798. }
  799. }
  800. public static async Task<List<RGroupList>> Activity(CoreAPIHttpService _coreAPIHttpService, ExamInfo info, List<string> classes, CosmosClient client, DingDing _dingDing, List<string> sub, List<ExamClassResult> results)
  801. {
  802. List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();
  803. if (info.groupLists.Count > 0)
  804. {
  805. var group = info.groupLists;
  806. foreach (var gp in group)
  807. {
  808. foreach (KeyValuePair<string, List<string>> pp in gp)
  809. {
  810. ps.Add((pp.Key, pp.Value));
  811. }
  812. }
  813. }
  814. (List<RMember> tchList, List<RGroupList> classLists) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, classes, info.school, ps);
  815. var addStudentsCls = tchList.FindAll(x => x.type == 2);
  816. var addTmdidsCls = tchList.FindAll(x => x.type == 1);
  817. List<StuActivity> stuActivities = new List<StuActivity>();
  818. List<StuActivity> tmdActivities = new List<StuActivity>();
  819. if (addTmdidsCls.IsNotEmpty())
  820. {
  821. addTmdidsCls.ForEach(x =>
  822. {
  823. HashSet<string> classIds = new HashSet<string>();
  824. classLists.ForEach(z =>
  825. {
  826. z.members.ForEach(y =>
  827. {
  828. if (y.id.Equals(x.id) && y.type == 1)
  829. {
  830. classIds.Add(z.id);
  831. }
  832. });
  833. });
  834. bool iss = false;
  835. //标记学生作答状态
  836. int ts = 0;
  837. if (results.Count > 0)
  838. {
  839. foreach (ExamClassResult exam in results)
  840. {
  841. int index = exam.studentIds.IndexOf(x.id);
  842. if (index != -1)
  843. {
  844. if (exam.studentAnswers[index].Count > 0)
  845. {
  846. bool flag = exam.studentScores[index].Exists(x => x == -1);
  847. if (!flag)
  848. {
  849. ts = 1;
  850. iss = true;
  851. break;
  852. }
  853. else
  854. {
  855. ts = 0;
  856. }
  857. }
  858. else
  859. {
  860. ts = -1;
  861. }
  862. }
  863. }
  864. }
  865. else
  866. {
  867. ts = -1;
  868. }
  869. tmdActivities.Add(new StuActivity
  870. {
  871. pk = "Activity",
  872. id = info.id,
  873. code = $"Activity-{x.id}",
  874. type = "Exam",
  875. name = info.name,
  876. source = info.source,
  877. startTime = info.startTime,
  878. endTime = info.endTime,
  879. scode = info.code,
  880. scope = info.scope,
  881. school = info.school,
  882. creatorId = info.creatorId,
  883. subjects = sub,
  884. blob = null,
  885. owner = info.owner,
  886. createTime = info.createTime,
  887. taskStatus = ts,
  888. qamode = info.qamode,
  889. ext = new Dictionary<string, JsonElement>() { { "type", info.examType.ToJsonString().ToObject<JsonElement>() },
  890. { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
  891. sStatus = iss ? 1 : 0,
  892. classIds = classIds.ToList()
  893. });
  894. });
  895. }
  896. if (addStudentsCls.IsNotEmpty())
  897. {
  898. addStudentsCls.ForEach(x =>
  899. {
  900. HashSet<string> classIds = new HashSet<string>();
  901. classLists.ForEach(z =>
  902. {
  903. z.members.ForEach(y =>
  904. {
  905. if (y.id.Equals(x.id) && y.code.Equals(info.school) && y.type == 2)
  906. {
  907. classIds.Add(z.id);
  908. }
  909. });
  910. });
  911. bool iss = false;
  912. //标记学生作答状态
  913. int ts = 0;
  914. if (results.Count > 0)
  915. {
  916. foreach (ExamClassResult exam in results)
  917. {
  918. int index = exam.studentIds.IndexOf(x.id);
  919. if (index != -1)
  920. {
  921. if (exam.studentAnswers[index].Count > 0)
  922. {
  923. bool flag = exam.studentScores[index].Exists(x => x == -1);
  924. if (!flag)
  925. {
  926. ts = 1;
  927. iss = true;
  928. break;
  929. }
  930. else
  931. {
  932. ts = 0;
  933. }
  934. }
  935. else
  936. {
  937. ts = -1;
  938. }
  939. }
  940. }
  941. }
  942. else
  943. {
  944. ts = -1;
  945. }
  946. stuActivities.Add(new StuActivity
  947. {
  948. pk = "Activity",
  949. id = info.id,
  950. code = $"Activity-{x.code.Replace("Base-", "")}-{x.id}",
  951. type = "Exam",
  952. name = info.name,
  953. source = info.source,
  954. startTime = info.startTime,
  955. endTime = info.endTime,
  956. scode = info.code,
  957. scope = info.scope,
  958. school = info.school,
  959. creatorId = info.creatorId,
  960. subjects = sub,
  961. blob = null,
  962. owner = info.owner,
  963. classIds = classIds.ToList(),
  964. createTime = info.createTime,
  965. qamode = info.qamode,
  966. ext = new Dictionary<string, JsonElement>() { { "type", info.examType.ToJsonString().ToObject<JsonElement>() },
  967. { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
  968. taskStatus = ts,
  969. sStatus = iss ? 1 : 0,
  970. });
  971. });
  972. }
  973. await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, null);
  974. return classLists;
  975. }
  976. public static async Task<List<double>> knowledgeCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
  977. double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
  978. {
  979. List<double> akp = new();
  980. try
  981. {
  982. int phcount = 0;
  983. int plcount = 0;
  984. //存放并去重知识点
  985. HashSet<string> kname = new HashSet<string>();
  986. if (info.papers[no].knowledge.Count > 0)
  987. {
  988. info.papers[no].knowledge.ForEach(kno =>
  989. {
  990. kno.ForEach(k =>
  991. {
  992. kname.Add(k);
  993. });
  994. });
  995. List<string> knowledgeName = new List<string>();
  996. foreach (string cla in kname)
  997. {
  998. knowledgeName.Add(cla);
  999. }
  1000. for (int k = 0; k < knowledgeName.Count; k++)
  1001. {
  1002. if (null == knowledgeName[k])
  1003. {
  1004. knowledgeName.Remove(knowledgeName[k]);
  1005. }
  1006. }
  1007. foreach (ExamClassResult classResult in classResults)
  1008. {
  1009. if (classResult.subjectId.Equals(subject.id))
  1010. {
  1011. //List<int> phc = new List<int>();
  1012. List<int> ph = new List<int>();
  1013. List<int> pl = new List<int>();
  1014. List<int> pc = new List<int>();
  1015. List<double> persent = new List<double>();
  1016. int lostStu = classResult.status.Where(c => c == 1).ToList().Count;
  1017. for (int i = 0; i < knowledgeName.Count; i++)
  1018. {
  1019. //初始化单个知识点得分
  1020. double score = 0;
  1021. int n = 0;
  1022. int phCount = 0;
  1023. int plCount = 0;
  1024. int pCount = 0;
  1025. double classScore = 0;
  1026. foreach (List<string> str in info.papers[no].knowledge)
  1027. {
  1028. if (str.Contains(knowledgeName[i]))
  1029. {
  1030. var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
  1031. classScore += info.papers[no].point.Count > 0 ? (info.papers[no].point[n] * itemPersent) : 0;
  1032. foreach (string id in classResult.studentIds)
  1033. {
  1034. int index = classResult.studentIds.IndexOf(id);
  1035. if (classResult.studentScores.Count > 0)
  1036. {
  1037. if (classResult.studentScores[index].Count > 0)
  1038. {
  1039. double realScore = classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n] * itemPersent;
  1040. score += realScore;
  1041. //score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n] * itemPersent;
  1042. if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
  1043. {
  1044. if (classResult.studentScores[index][n] <= 0)
  1045. {
  1046. phCount++;
  1047. }
  1048. phcount++;
  1049. continue;
  1050. }
  1051. if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
  1052. {
  1053. if (classResult.studentScores[index][n] <= 0)
  1054. {
  1055. plCount++;
  1056. }
  1057. plcount++;
  1058. continue;
  1059. }
  1060. if (classResult.studentScores[index][n] <= 0)
  1061. {
  1062. pCount++;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. }
  1068. n++;
  1069. }
  1070. pc.Add(pCount);
  1071. ph.Add(phCount);
  1072. pl.Add(plCount);
  1073. double per = classResult.studentIds.Count - lostStu > 0 ? Math.Round(score / (classResult.studentIds.Count - lostStu), 2) : 0;
  1074. persent.Add(classScore > 0 ? Math.Round(per * 1.0 / classScore, 2) : 0);
  1075. }
  1076. classResult.phc = ph;
  1077. classResult.plc = pl;
  1078. classResult.pc = pc;
  1079. classResult.krate = persent;
  1080. }
  1081. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
  1082. }
  1083. foreach (string k in knowledgeName)
  1084. {
  1085. double score = 0;
  1086. double allScore = 0;
  1087. int count = 0;
  1088. int m = 0;
  1089. foreach (List<string> str in info.papers[no].knowledge)
  1090. {
  1091. if (str.Contains(k))
  1092. {
  1093. var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
  1094. allScore += info.papers[no].point.Count > 0 ? info.papers[no].point[m] * itemPersent : 0;
  1095. }
  1096. m++;
  1097. }
  1098. foreach (ExamClassResult result in classResults)
  1099. {
  1100. if (result.subjectId.Equals(subject.id))
  1101. {
  1102. int n = 0;
  1103. foreach (List<string> str in info.papers[no].knowledge)
  1104. {
  1105. if (str.Contains(k))
  1106. {
  1107. var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
  1108. if (result.studentScores.Count > 0)
  1109. {
  1110. foreach (List<double> sc in result.studentScores)
  1111. {
  1112. double tsc = sc[n] == -1 ? 0 : sc[n];
  1113. score += (tsc * itemPersent);
  1114. }
  1115. }
  1116. }
  1117. n++;
  1118. }
  1119. count += result.studentIds.Count;
  1120. }
  1121. }
  1122. double per = count - info.lostStu.Count > 0 ? Math.Round(score / (count - info.lostStu.Count), 2) : 0;
  1123. akp.Add(allScore > 0 ? Math.Round(per / allScore, 2) : 0);
  1124. }
  1125. }
  1126. return akp;
  1127. }
  1128. catch (Exception ex)
  1129. {
  1130. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测知识点结算异常{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  1131. return null;
  1132. }
  1133. }
  1134. public static async Task<List<double>> fieldCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
  1135. double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
  1136. {
  1137. List<double> afp = new();
  1138. try
  1139. {
  1140. int phcount = 0;
  1141. int plcount = 0;
  1142. //存放并去重知识点
  1143. List<int> knowledgeName = new List<int>() { 1, 2, 3, 4, 5, 6 };
  1144. /* knowledgeName.Add(1);
  1145. knowledgeName.Add(2);
  1146. knowledgeName.Add(3);
  1147. knowledgeName.Add(4);
  1148. knowledgeName.Add(5);
  1149. knowledgeName.Add(6);*/
  1150. foreach (ExamClassResult classResult in classResults)
  1151. {
  1152. if (classResult.subjectId.Equals(subject.id))
  1153. {
  1154. //List<int> phc = new List<int>();
  1155. List<int> ph = new List<int>();
  1156. List<int> pl = new List<int>();
  1157. List<int> pc = new List<int>();
  1158. List<double> persent = new List<double>();
  1159. int lostStu = classResult.status.Where(c => c == 1).ToList().Count;
  1160. for (int i = 0; i < knowledgeName.Count; i++)
  1161. {
  1162. //初始化单个知识点得分
  1163. double score = 0;
  1164. int n = 0;
  1165. int phCount = 0;
  1166. int plCount = 0;
  1167. int pCount = 0;
  1168. double classScore = 0;
  1169. if (info.papers[no].field.Count > 0)
  1170. {
  1171. foreach (int str in info.papers[no].field)
  1172. {
  1173. if (str == knowledgeName[i])
  1174. {
  1175. var itemPersent = 1;
  1176. classScore += info.papers[no].point.Count > 0 ? info.papers[no].point[n] * itemPersent : 0;
  1177. foreach (string id in classResult.studentIds)
  1178. {
  1179. int index = classResult.studentIds.IndexOf(id);
  1180. if (classResult.studentScores.Count > 0)
  1181. {
  1182. if (classResult.studentScores[index].Count > 0)
  1183. {
  1184. score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n];
  1185. if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
  1186. {
  1187. if (classResult.studentScores[index][n] <= 0)
  1188. {
  1189. phCount++;
  1190. }
  1191. phcount++;
  1192. continue;
  1193. }
  1194. if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
  1195. {
  1196. if (classResult.studentScores[index][n] <= 0)
  1197. {
  1198. plCount++;
  1199. }
  1200. plcount++;
  1201. continue;
  1202. }
  1203. if (classResult.studentScores[index][n] <= 0)
  1204. {
  1205. pCount++;
  1206. }
  1207. }
  1208. }
  1209. }
  1210. }
  1211. n++;
  1212. }
  1213. pc.Add(pCount);
  1214. ph.Add(phCount);
  1215. pl.Add(plCount);
  1216. double per = classResult.studentIds.Count - lostStu > 0 ? Math.Round(score / (classResult.studentIds.Count - lostStu), 2) : 0;
  1217. persent.Add(classScore > 0 ? Math.Round(per / classScore, 2) : 0);
  1218. }
  1219. }
  1220. classResult.fphc = ph;
  1221. classResult.fplc = pl;
  1222. classResult.fpc = pc;
  1223. classResult.frate = persent;
  1224. }
  1225. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
  1226. }
  1227. for (int i = 0; i < knowledgeName.Count; i++)
  1228. {
  1229. double score = 0;
  1230. double allScore = 0;
  1231. int count = 0;
  1232. int m = 0;
  1233. foreach (int str in info.papers[no].field)
  1234. {
  1235. if (str == knowledgeName[i])
  1236. {
  1237. var itemPersent = 1;
  1238. allScore += info.papers[no].point.Count > 0 ? info.papers[no].point[m] * itemPersent : 0;
  1239. }
  1240. m++;
  1241. }
  1242. foreach (ExamClassResult result in classResults)
  1243. {
  1244. if (result.subjectId.Equals(subject.id))
  1245. {
  1246. int n = 0;
  1247. foreach (int str in info.papers[no].field)
  1248. {
  1249. var itemPersent = 1;
  1250. if (str == knowledgeName[i])
  1251. {
  1252. if (result.studentScores.Count > 0)
  1253. {
  1254. foreach (List<double> sc in result.studentScores)
  1255. {
  1256. double tsc = sc[n] == -1 ? 0 : sc[n];
  1257. score += tsc * itemPersent;
  1258. }
  1259. }
  1260. }
  1261. n++;
  1262. }
  1263. count += result.studentIds.Count;
  1264. }
  1265. }
  1266. double per = count - info.lostStu.Count > 0 ? Math.Round(score / (count - info.lostStu.Count), 2) : 0;
  1267. afp.Add(allScore > 0 ? Math.Round(per / allScore, 2) : 0);
  1268. }
  1269. return afp;
  1270. }
  1271. catch (Exception ex)
  1272. {
  1273. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测认知层次结算异常{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  1274. return null;
  1275. }
  1276. }
  1277. //处理选题计数
  1278. public static List<Dictionary<string, int>> getMore(ExamInfo info, int no, List<List<List<string>>> list)
  1279. {
  1280. List<Dictionary<string, int>> recorde = new List<Dictionary<string, int>>();
  1281. try
  1282. {
  1283. for (int i = 0; i < info.papers[no].answers.Count; i++)
  1284. {
  1285. if (info.papers[no].answers[i].Count <= 0)
  1286. {
  1287. recorde.Add(new Dictionary<string, int>());
  1288. continue;
  1289. }
  1290. Dictionary<string, int> optCount = new Dictionary<string, int>();
  1291. foreach (List<List<string>> stu in list)
  1292. {
  1293. if (stu.Count == info.papers[no].answers.Count)
  1294. {
  1295. var item = stu[i];
  1296. foreach (string opt in item)
  1297. {
  1298. if (optCount.ContainsKey(opt))
  1299. {
  1300. optCount[opt] = optCount[opt] + 1;
  1301. }
  1302. else
  1303. {
  1304. optCount[opt] = 1;
  1305. }
  1306. }
  1307. }
  1308. }
  1309. recorde.Add(optCount);
  1310. }
  1311. return recorde;
  1312. }
  1313. catch (Exception)
  1314. {
  1315. return recorde;
  1316. }
  1317. }
  1318. public static async Task createClassResultAsync(ExamInfo info, List<ExamClassResult> examClassResults, ExamSubject subject, int no, AzureCosmosFactory _azureCosmos, DingDing _dingDing, AzureStorageFactory _azureStorage, IHttpClientFactory _httpClient, IConfiguration _configuration)
  1319. {
  1320. //保证试卷信息与科目信息同步
  1321. ExamResult result = new ExamResult();
  1322. //人数总和
  1323. int Count = 0;
  1324. int m = 0;
  1325. double score = 0;
  1326. //标准差
  1327. //double powSum = 0;
  1328. double allScore = info.papers[no].point.Sum();
  1329. List<ClassRange> classRanges = new List<ClassRange>();
  1330. List<string> lostStu = new List<string>();
  1331. List<double> csRate = new List<double>();
  1332. List<List<List<string>>> opt = new List<List<List<string>>>();
  1333. //List<Task<ItemResponse<ExamClassResult>>> tasks = new();
  1334. foreach (ExamClassResult classResult in examClassResults)
  1335. {
  1336. double classSrate = 0;
  1337. if (classResult.subjectId.Equals(subject.id))
  1338. {
  1339. foreach (List<List<string>> op in classResult.ans)
  1340. {
  1341. opt.Add(op);
  1342. }
  1343. //记录缺考学生索引位置
  1344. int index_stu = 0;
  1345. foreach (var ans in classResult.studentAnswers)
  1346. {
  1347. if (ans.Count == 0)
  1348. {
  1349. if (!lostStu.Contains(classResult.studentIds[index_stu]))
  1350. {
  1351. lostStu.Add(classResult.studentIds[index_stu]);
  1352. }
  1353. }
  1354. else
  1355. {
  1356. if (classResult.status[index_stu] == 1)
  1357. {
  1358. if (!lostStu.Contains(classResult.studentIds[index_stu]))
  1359. {
  1360. lostStu.Add(classResult.studentIds[index_stu]);
  1361. }
  1362. }
  1363. }
  1364. index_stu++;
  1365. }
  1366. int index = 0;
  1367. foreach (List<double> scores in classResult.studentScores)
  1368. {
  1369. List<double> newScores = new List<double>();
  1370. //int count = 0;
  1371. foreach (double sc in scores)
  1372. {
  1373. newScores.Add(sc > -1 ? sc : 0);
  1374. }
  1375. classSrate += newScores.Sum();
  1376. score += newScores.Sum();
  1377. result.studentScores.Add(newScores);
  1378. index++;
  1379. }
  1380. //处理班级信息
  1381. ClassRange range = new ClassRange();
  1382. range.id = classResult.info.id;
  1383. range.name = classResult.info.name;
  1384. range.gradeId = classResult.gradeId;
  1385. List<int> ran = new List<int>();
  1386. int stuCount = classResult.studentIds.Count;
  1387. //todo 与实际的缺考人数比较
  1388. int lostStus = classResult.status.Where(c => c == 1).ToList().Count;
  1389. Count += stuCount;
  1390. if (m == 0)
  1391. {
  1392. ran.Add(0);
  1393. ran.Add(stuCount - 1);
  1394. }
  1395. else
  1396. {
  1397. ran.Add(Count - stuCount);
  1398. ran.Add(Count - 1);
  1399. }
  1400. m++;
  1401. range.range = ran;
  1402. classRanges.Add(range);
  1403. //处理学生ID
  1404. foreach (string id in classResult.studentIds)
  1405. {
  1406. result.studentIds.Add(id);
  1407. }
  1408. if (allScore > 0)
  1409. {
  1410. csRate.Add(classResult.studentIds.Count - lostStus > 0 ? Math.Round(classSrate * 1.0 / (classResult.studentIds.Count - lostStus), 2) : 0 / allScore);
  1411. }
  1412. else
  1413. {
  1414. csRate.Add(0);
  1415. }
  1416. //powSum += Math.Pow(classSrate - result.average, 2);
  1417. //处理选项计数内容
  1418. }
  1419. //tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}")));
  1420. }
  1421. //await tasks.TaskPage(10);
  1422. /*foreach (string id in result.lostStus) {
  1423. if (!examClassResults[0].studentIds.Contains(id)) {
  1424. int index = result.lostStus.IndexOf(id);
  1425. result.lostStus.RemoveAt(index);
  1426. }
  1427. }*/
  1428. //处理人员变更时被移除的人员
  1429. result.lostStus = lostStu;
  1430. if (result.lostStus.Count > 0)
  1431. {
  1432. for (int i = 0; i < result.lostStus.Count; i++)
  1433. {
  1434. if (!examClassResults[0].studentIds.Contains(result.lostStus[i]))
  1435. {
  1436. result.lostStus.RemoveAt(i);
  1437. }
  1438. }
  1439. }
  1440. result.record = getMore(info, no, opt);
  1441. result.average = result.studentIds.Count - result.lostStus.Count > 0 ? Math.Round(score * 1.0 / (result.studentIds.Count - result.lostStus.Count), 2) : 0;
  1442. double powSum = 0;
  1443. //int sco = 0;
  1444. result.studentIds.ForEach(x =>
  1445. {
  1446. double sc = result.studentScores[result.studentIds.IndexOf(x)].Sum();
  1447. if (!result.lostStus.Contains(x))
  1448. {
  1449. powSum += Math.Pow(sc - result.average, 2);
  1450. }
  1451. });
  1452. result.standard = Math.Round((result.studentIds.Count - result.lostStus.Count) > 0 ? Math.Pow(powSum / (result.studentIds.Count - result.lostStus.Count), 0.5) : 0, 2);
  1453. result.csRate = csRate;
  1454. result.sRate = allScore > 0 ? Math.Round(result.average / allScore * 100, 2) : 0;
  1455. result.classes = classRanges;
  1456. result.code = "ExamResult-" + info.id;
  1457. result.school = info.school;
  1458. result.id = subject.id;
  1459. result.examId = info.id;
  1460. result.subjectId = subject.id;
  1461. result.year = info.year;
  1462. result.paper = info.papers[no];
  1463. //result.point = info.papers[j].point;
  1464. result.scope = info.scope;
  1465. result.name = info.name;
  1466. result.time = info.startTime;
  1467. await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
  1468. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
  1469. List<ErrorItems> errorItems = new();
  1470. string sqlqueryText = $"select value(c) from c where c.activityId = '{info.id}'and c.subjectId = '{info.subjects[no].id}' and c.stuId in ({string.Join(",", result.studentIds.Select(x => $"'{x}'"))})";
  1471. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ErrorItems") }))
  1472. {
  1473. errorItems.Add(item);
  1474. }
  1475. if (errorItems.Count == 0)
  1476. {
  1477. // 新增逻辑 收集错题内容
  1478. BlobDownloadResult index_json;
  1479. if (info.scope.Equals("school"))
  1480. {
  1481. index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  1482. }
  1483. else
  1484. {
  1485. index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  1486. }
  1487. //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  1488. JObject jo = JObject.Parse(index_json.Content.ToString());
  1489. JArray array = jo.Value<JArray>("slides");
  1490. List<string> urls = new();
  1491. foreach (var ne in array)
  1492. {
  1493. if (!ne["type"].ToString().Equals("compose"))
  1494. {
  1495. urls.Add(ne["url"].ToString());
  1496. }
  1497. }
  1498. string code = string.Empty;
  1499. string pk = string.Empty;
  1500. string table = "School";
  1501. if (info.scope.Equals("school"))
  1502. {
  1503. code = $"ErrorItems-{info.school}";
  1504. pk = $"Item-{info.school}";
  1505. }
  1506. else
  1507. {
  1508. code = "ErrorItems";
  1509. pk = $"Item-{info.creatorId}";
  1510. table = "Teacher";
  1511. }
  1512. // 获取整体的题目ID集合
  1513. List<string> ids = new();
  1514. List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
  1515. foreach (string url in urls)
  1516. {
  1517. string id = url.Replace(".json", "");
  1518. BlobDownloadResult index_item_json;
  1519. if (info.scope.Equals("school"))
  1520. {
  1521. index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
  1522. }
  1523. else
  1524. {
  1525. index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
  1526. }
  1527. JObject keys = JObject.Parse(index_item_json.Content.ToString());
  1528. string type = keys["exercise"].Value<string>("type");
  1529. int level = keys["exercise"].Value<int>("level");
  1530. var knowledge = keys["exercise"].Value<JArray>("knowledge")?.ToObject<List<string>>();
  1531. string pid = keys.Value<string>("pid");
  1532. itemInfos.Add((id, pid, level, type, knowledge));
  1533. }
  1534. /*await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, table).GetItemQueryStreamIterator(
  1535. queryText: $"select c.id,c.pid,c.level,c.type from c where c.id in ({string.Join(",", ids.Select(o => $"'{o}'"))})", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{pk}") }))
  1536. {
  1537. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  1538. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  1539. {
  1540. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  1541. while (accounts.MoveNext())
  1542. {
  1543. JsonElement account = accounts.Current;
  1544. string pid = "";
  1545. if (account.TryGetProperty("pid",out JsonElement element)) {
  1546. pid = element.GetString();
  1547. }
  1548. itemInfos.Add((account.GetProperty("id").GetString(), pid, account.GetProperty("level").GetInt32(), account.GetProperty("type").GetString()));
  1549. }
  1550. }
  1551. }*/
  1552. double[] point = StringHelper.ListTodouble(result.paper.point);
  1553. double[,] res = StringHelper.ListToDouble(result.studentScores);
  1554. var cdm = new ClouDASMatrix(res, point);
  1555. //需要努力的题目
  1556. var ss = cdm.StriveTopic;
  1557. int n = 0;
  1558. List<Task<ItemResponse<ErrorItems>>> task_error = new();
  1559. List<ErrorItems> errors = new();
  1560. foreach (var sIds in result.studentIds)
  1561. {
  1562. ErrorItems error = new()
  1563. {
  1564. ttl = -1,
  1565. code = code,
  1566. id = Guid.NewGuid().ToString(),
  1567. stuId = sIds,
  1568. school = info.school,
  1569. activityId = info.id,
  1570. subjectId = result.subjectId,
  1571. time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  1572. };
  1573. //顺序学生错题的索引
  1574. int[] item_index = ss[n];
  1575. foreach (var item in item_index)
  1576. {
  1577. Items items = new()
  1578. {
  1579. id = urls[item - 1].Replace(".json", ""),
  1580. blob = info.papers[no].blob
  1581. };
  1582. items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
  1583. items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
  1584. items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
  1585. items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
  1586. error.its.Add(items);
  1587. }
  1588. errors.Add(error);
  1589. n++;
  1590. task_error.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(error, new PartitionKey($"{error.code}")));
  1591. }
  1592. //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
  1593. string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
  1594. string urlAction = string.Empty;
  1595. if (location.Contains("China") || location.Contains("China-Dep"))
  1596. {
  1597. urlAction = "https://malearnfunction.chinacloudsites.cn";
  1598. }
  1599. else if (location.Contains("Global"))
  1600. {
  1601. urlAction = "https://malearnfunction.azurewebsites.net";
  1602. }
  1603. else if (location.Contains("Global-Test"))
  1604. {
  1605. urlAction = "https://malearn-test.azurewebsites.net";
  1606. }
  1607. string connect = $"{urlAction}/api/crtmabank";
  1608. var htc = _httpClient.CreateClient();
  1609. if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
  1610. {
  1611. htc.DefaultRequestHeaders.Remove("x-functions-key");
  1612. }
  1613. htc.DefaultRequestHeaders.Add("x-functions-key", "QUzQqbqbnLsTDTeaJy4Br6wUuqPoAlKpzRK2S6PGImRHAzFuySGAeA==");
  1614. string paramJson = JsonConvert.SerializeObject(errors);
  1615. var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
  1616. await htc.PostAsync(connect, content);
  1617. await task_error.TaskPage(10);
  1618. }
  1619. }
  1620. public class Settlement
  1621. {
  1622. public double rate { get; set; }
  1623. public double score { get; set; }
  1624. public List<string> stus { get; set; } = new List<string>();
  1625. public int total { get; set; }
  1626. public double qrate { get; set; }
  1627. }
  1628. }
  1629. }