TriggerExam.cs 91 KB

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