TriggerExam.cs 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675
  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)) {
  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. var (currSemester, studyYear, date, nextSemester) = SchoolService.GetSemester(period, info.startTime);
  442. //获取学生信息
  443. (List<RMember> rmembers, List<RGroupList> groups) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, info.classes, info.school);
  444. foreach (var member in rmembers) {
  445. if (info.lostStu.Contains(member.id)) {
  446. continue;
  447. }
  448. PortraitStudent student = new()
  449. {
  450. studentId = member.id,
  451. name = member.name,
  452. classId = member.classId
  453. };
  454. SemesterData semesterData = new()
  455. {
  456. examName = info.name,
  457. examId = info.id,
  458. examDate = info.startTime,
  459. examType = info.examType?.name,
  460. year = info.year,
  461. semesterId = currSemester.id,
  462. totalScore = info.papers.SelectMany(x => x.point).Sum(),
  463. sumScore = examClassResults.SelectMany(x => x.sum).Sum(),
  464. excellenceRate = 0,
  465. passRate = 0,
  466. };
  467. int index = 0;
  468. foreach (var sj in info.subjects) {
  469. ItemScore item = new()
  470. {
  471. name = sj.name,
  472. score = examClassResults.Where(x => x.subjectId.Equals(sj.id)).FirstOrDefault().sum.Sum(),
  473. time = info.startTime,
  474. totalScore = info.papers[index].point.Sum(),
  475. type = sj.id
  476. };
  477. index++;
  478. semesterData.itemScore.Add(item);
  479. }
  480. student.semesterData.Add(semesterData);
  481. portrait.students.Add(student);
  482. }
  483. string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
  484. var (status, json) = await _httpTrigger.RequestHttpTrigger(portrait.ToJson(), location, "upsert-student-portrait");
  485. //PortraitStudent student = new();
  486. //处理试卷活动结束统计账户信息
  487. List<FMember> idList = await GroupListService.GetFinishMemberInfo(_coreAPIHttpService, client, _dingDing, info.school, info.classes, info.stuLists, null);
  488. info.staffIds = idList;
  489. await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new Azure.Cosmos.PartitionKey(info.code));
  490. }
  491. }
  492. catch (Exception e)
  493. {
  494. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测finish状态异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  495. }
  496. break;
  497. }
  498. }
  499. }
  500. catch (CosmosException e)
  501. {
  502. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-CosmosDB异常{e.Message}\n{e.StackTrace}\n{e.Status}", GroupNames.醍摩豆服務運維群組);
  503. }
  504. catch (Exception e)
  505. {
  506. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-评测结算异常{e.Message}\n{e.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  507. }
  508. }
  509. public static async Task resultStatus(CosmosClient client, List<ExamClassResult> examClassResults)
  510. {
  511. List<Task<ItemResponse<ExamClassResult>>> tasks = new();
  512. //结算单科单班的标准差和平均分
  513. foreach (ExamClassResult classResult in examClassResults)
  514. {
  515. //标记单科单班总得分
  516. double subScore = 0;
  517. //标准差
  518. double sPowSum = 0;
  519. List<double> newSumScore = new List<double>();
  520. List<double> effectiveScore = new List<double>();
  521. int lostStu = classResult.status.Where(c => c == 1).ToList().Count;
  522. var scount = classResult.studentIds.Count - lostStu;
  523. int index = 0;
  524. if (classResult.status.Count > 0)
  525. {
  526. foreach (var sta in classResult.status)
  527. {
  528. if (sta == 1)
  529. {
  530. for (int i = 0; i < classResult.studentScores[index].Count; i++)
  531. {
  532. if (classResult.studentScores[index][i] == -1)
  533. {
  534. classResult.studentScores[index][i] = 0;
  535. }
  536. }
  537. }
  538. else if (sta == 0)
  539. {
  540. //var ans = classResult.studentAnswers[index];
  541. //该学生缺考,历史数据的判定
  542. //if (ans.Count == 0)
  543. //{
  544. for (int i = 0; i < classResult.studentScores[index].Count; i++)
  545. {
  546. if (classResult.studentScores[index][i] == -1)
  547. {
  548. classResult.studentScores[index][i] = 0;
  549. }
  550. }
  551. /*if (ans.Count == 0)
  552. {
  553. classResult.status[index] = 1;
  554. } */
  555. //}
  556. }
  557. index++;
  558. }
  559. }
  560. else
  561. {
  562. List<int> sta = new();
  563. foreach (var id in classResult.studentIds)
  564. {
  565. sta.Add(0);
  566. }
  567. classResult.status = sta;
  568. foreach (var ans in classResult.studentAnswers)
  569. {
  570. //该学生缺考,历史数据的判定
  571. if (ans.Count == 0)
  572. {
  573. for (int i = 0; i < classResult.studentScores[index].Count; i++)
  574. {
  575. if (classResult.studentScores[index][i] == -1)
  576. {
  577. classResult.studentScores[index][i] = 0;
  578. }
  579. }
  580. classResult.status[index] = 1;
  581. }
  582. index++;
  583. }
  584. }
  585. int sIndex = 0;
  586. foreach (List<double> sc in classResult.studentScores)
  587. {
  588. List<double> newSc = new List<double>();
  589. foreach (double ssc in sc)
  590. {
  591. if (ssc == -1)
  592. {
  593. newSc.Add(0);
  594. }
  595. else
  596. {
  597. newSc.Add(ssc);
  598. }
  599. }
  600. double nc = Math.Round(newSc.Sum(), 2);
  601. if (classResult.status[sIndex] == 0)
  602. {
  603. effectiveScore.Add(nc);
  604. };
  605. newSumScore.Add(nc);
  606. subScore += nc;
  607. classResult.sum[sIndex] = nc;
  608. sIndex++;
  609. }
  610. double rateScore = scount > 0 ? Math.Round(subScore * 1.0 / scount, 2) : 0;
  611. //有效分数
  612. foreach (double scs in effectiveScore)
  613. {
  614. sPowSum += Math.Pow(scs - rateScore, 2);
  615. }
  616. classResult.standard = Math.Round(scount > 0 ? Math.Pow(sPowSum / scount, 0.5) : 0, 2);
  617. classResult.average = scount > 0 ? Math.Round(subScore / scount, 2) : 0;
  618. classResult.progress = true;
  619. tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}")));
  620. }
  621. await Task.WhenAll(tasks);
  622. }
  623. public static async Task<Settlement> getMore(CosmosClient client, ExamInfo info)
  624. {
  625. //计算单次考试简易统计信息
  626. Settlement settlement = new();
  627. List<ExamResult> examResults = new();
  628. await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
  629. queryText: $"select value(c) from c where c.examId = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}") }))
  630. {
  631. examResults.Add(item);
  632. }
  633. if (examResults.Count > 0)
  634. {
  635. //记录某次考试所有学生得分总分
  636. double score = 0;
  637. double allScore = 0;
  638. int stuCount = 0;
  639. //标准差
  640. double powSum = 0;
  641. List<string> losStu = new List<string>();
  642. //当前完成考试得人数
  643. int total = examResults[0].studentIds.Distinct().Count();
  644. //先与第一个值取并集
  645. losStu = losStu.Union(examResults[0].lostStus).ToList();
  646. foreach (ExamResult examResult in examResults)
  647. {
  648. //取交集
  649. losStu = losStu.Intersect(examResult.lostStus).ToList();
  650. }
  651. //处理缺考的学生
  652. List<string> stus = examResults[0].studentIds.Except(losStu).ToList();
  653. foreach (ExamResult examResult in examResults)
  654. {
  655. foreach (var id in stus)
  656. {
  657. int index = examResult.studentIds.IndexOf(id);
  658. score += examResult.studentScores[index].Sum();
  659. }
  660. }
  661. stuCount = total - losStu.Count;
  662. double NewsRateScore = stuCount > 0 ? Math.Round(score * 1.0 / stuCount, 2) : 0;
  663. foreach (PaperSimple simple in info.papers)
  664. {
  665. allScore += simple.point.Sum();
  666. }
  667. //计算全科标准差
  668. foreach (string id in stus)
  669. {
  670. double sc = 0;
  671. foreach (ExamResult result in examResults)
  672. {
  673. if (result.studentScores.Count > 0)
  674. {
  675. sc += result.studentScores[result.studentIds.IndexOf(id)].Sum();
  676. }
  677. }
  678. powSum += Math.Pow(sc - NewsRateScore, 2);
  679. }
  680. info.standard = Math.Round(total - losStu.Count > 0 ? Math.Pow(powSum / (total - losStu.Count), 0.5) : 0, 2);
  681. double NewsRate = allScore > 0 ? Math.Round(NewsRateScore / allScore * 100, 2) : 0;
  682. double qrate = Math.Round(total > 0 ? losStu.Count * 1.0 / total * 100 : 0, 2);
  683. settlement.rate = NewsRate;
  684. settlement.score = NewsRateScore;
  685. settlement.stus = losStu;
  686. settlement.total = total;
  687. settlement.qrate = qrate;
  688. }
  689. return settlement;
  690. }
  691. //处理全部学生选题计数
  692. public static async Task examRecordCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, ExamResult er, List<ExamClassResult> classResults, AzureCosmosFactory _azureCosmos)
  693. {
  694. try
  695. {
  696. List<double> scores = new List<double>();
  697. foreach (List<double> sc in er.studentScores)
  698. {
  699. scores.Add(sc.Sum());
  700. }
  701. //确定高分组 最低分数
  702. //var srowallorder = scores.EnumerateIndexed().OrderByDescending(g => g.Item2); //各生總分排序
  703. //var srowallorder = scores.OrderByDescending(g => g);
  704. double[] point = StringHelper.ListTodouble(er.paper.point);
  705. double[,] result = StringHelper.ListToDouble(er.studentScores);
  706. var cdm = new ClouDASMatrix(result, point);
  707. scores.Sort((s1, s2) => { return s2.CompareTo(s1); });
  708. int rhwCount = cdm.SH.Count();
  709. double rhw = cdm.SH.LastOrDefault().Item2;
  710. int rhlCount = cdm.SL.Count();
  711. double rhl = cdm.SL.FirstOrDefault().Item2;
  712. List<string> phs = new();
  713. List<string> pls = new();
  714. //分别获取高分组低分组人员
  715. foreach (var ph in cdm.SH)
  716. {
  717. phs.Add(er.studentIds[ph.Item1]);
  718. }
  719. foreach (var pl in cdm.SL)
  720. {
  721. pls.Add(er.studentIds[pl.Item1]);
  722. }
  723. /* if (scores.Count > 3)
  724. {
  725. rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
  726. rhw = rhwCount > 0 ? scores[rhwCount - 1] : 0;
  727. rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
  728. rhl = rhlCount > 0 ? scores[rhlCount] : 0;
  729. }
  730. else
  731. {
  732. rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
  733. rhw = rhwCount > 0 ? scores[rhwCount] : 0;
  734. rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
  735. rhl = rhlCount > 0 ? scores[rhlCount - 1] : 0;
  736. }*/
  737. /*int rhwCount = Convert.ToInt32(Math.Floor(scores.Count * 0.27));
  738. double rhw = rhwCount > 0 ? scores[rhwCount-1] : 0;
  739. //var rhww = srowallorder.Take(Convert.ToInt32(Math.Floor(scores.Count * 0.27)));
  740. //确定低分组 最高分数
  741. //scores.Sort((s1, s2) => { return s1.CompareTo(s2); });
  742. int rhlCount = Convert.ToInt32(Math.Ceiling(scores.Count * 0.73));
  743. double rhl = rhlCount > 0 ? scores[rhlCount-1] : 0;*/
  744. //var rhll = srowallorder.Skip(Convert.ToInt32(Math.Ceiling(scores.Count * 0.73)));
  745. //存放高分组学生ID
  746. List<string> phId = new();
  747. List<string> plId = new();
  748. List<List<List<string>>> opth = new();
  749. List<List<List<string>>> optl = new();
  750. List<double> akp = await knowledgeCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
  751. List<double> afp = await fieldCount(info, subject, _dingDing, no, classResults, rhwCount, rhw, rhlCount, rhl, _azureCosmos);
  752. int PHCount = 0;
  753. int PLCount = 0;
  754. foreach (ExamClassResult classResult in classResults)
  755. {
  756. if (classResult.subjectId.Equals(subject.id))
  757. {
  758. foreach (string id in classResult.studentIds)
  759. {
  760. int index = classResult.studentIds.IndexOf(id);
  761. if (classResult.studentScores.Count > 0)
  762. {
  763. if (phs.Contains(id))
  764. {
  765. if (classResult.ans.Count > 0)
  766. {
  767. opth.Add(classResult.ans[index]);
  768. PHCount++;
  769. continue;
  770. }
  771. }
  772. if (pls.Contains(id))
  773. {
  774. if (classResult.ans.Count > 0)
  775. {
  776. optl.Add(classResult.ans[index]);
  777. PLCount++;
  778. continue;
  779. }
  780. }
  781. }
  782. }
  783. }
  784. }
  785. er.phc = getMore(info, no, opth);
  786. er.plc = getMore(info, no, optl);
  787. er.afp = afp;
  788. er.akp = akp;
  789. }
  790. catch (Exception ex)
  791. {
  792. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测作答记录结算异常{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  793. }
  794. }
  795. public static async Task<List<RGroupList>> Activity(CoreAPIHttpService _coreAPIHttpService, ExamInfo info, List<string> classes, CosmosClient client, DingDing _dingDing, List<string> sub, List<ExamClassResult> results)
  796. {
  797. List<(string pId, List<string> gid)> ps = new List<(string pId, List<string> gid)>();
  798. if (info.groupLists.Count > 0)
  799. {
  800. var group = info.groupLists;
  801. foreach (var gp in group)
  802. {
  803. foreach (KeyValuePair<string, List<string>> pp in gp)
  804. {
  805. ps.Add((pp.Key, pp.Value));
  806. }
  807. }
  808. }
  809. (List<RMember> tchList, List<RGroupList> classLists) = await GroupListService.GetMemberByListids(_coreAPIHttpService, client, _dingDing, classes, info.school, ps);
  810. var addStudentsCls = tchList.FindAll(x => x.type == 2);
  811. var addTmdidsCls = tchList.FindAll(x => x.type == 1);
  812. List<StuActivity> stuActivities = new List<StuActivity>();
  813. List<StuActivity> tmdActivities = new List<StuActivity>();
  814. if (addTmdidsCls.IsNotEmpty())
  815. {
  816. addTmdidsCls.ForEach(x =>
  817. {
  818. HashSet<string> classIds = new HashSet<string>();
  819. classLists.ForEach(z =>
  820. {
  821. z.members.ForEach(y =>
  822. {
  823. if (y.id.Equals(x.id) && y.type == 1)
  824. {
  825. classIds.Add(z.id);
  826. }
  827. });
  828. });
  829. bool iss = false;
  830. //标记学生作答状态
  831. int ts = 0;
  832. if (results.Count > 0)
  833. {
  834. foreach (ExamClassResult exam in results)
  835. {
  836. int index = exam.studentIds.IndexOf(x.id);
  837. if (index != -1)
  838. {
  839. if (exam.studentAnswers[index].Count > 0)
  840. {
  841. bool flag = exam.studentScores[index].Exists(x => x == -1);
  842. if (!flag)
  843. {
  844. ts = 1;
  845. iss = true;
  846. break;
  847. }
  848. else
  849. {
  850. ts = 0;
  851. }
  852. }
  853. else
  854. {
  855. ts = -1;
  856. }
  857. }
  858. }
  859. }
  860. else
  861. {
  862. ts = -1;
  863. }
  864. tmdActivities.Add(new StuActivity
  865. {
  866. pk = "Activity",
  867. id = info.id,
  868. code = $"Activity-{x.id}",
  869. type = "Exam",
  870. name = info.name,
  871. source = info.source,
  872. startTime = info.startTime,
  873. endTime = info.endTime,
  874. scode = info.code,
  875. scope = info.scope,
  876. school = info.school,
  877. creatorId = info.creatorId,
  878. subjects = sub,
  879. blob = null,
  880. owner = info.owner,
  881. createTime = info.createTime,
  882. taskStatus = ts,
  883. qamode = info.qamode,
  884. ext = new Dictionary<string, JsonElement>() { { "type", info.examType.ToJsonString().ToObject<JsonElement>() },
  885. { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
  886. sStatus = iss ? 1 : 0,
  887. classIds = classIds.ToList()
  888. });
  889. });
  890. }
  891. if (addStudentsCls.IsNotEmpty())
  892. {
  893. addStudentsCls.ForEach(x =>
  894. {
  895. HashSet<string> classIds = new HashSet<string>();
  896. classLists.ForEach(z =>
  897. {
  898. z.members.ForEach(y =>
  899. {
  900. if (y.id.Equals(x.id) && y.code.Equals(info.school) && y.type == 2)
  901. {
  902. classIds.Add(z.id);
  903. }
  904. });
  905. });
  906. bool iss = false;
  907. //标记学生作答状态
  908. int ts = 0;
  909. if (results.Count > 0)
  910. {
  911. foreach (ExamClassResult exam in results)
  912. {
  913. int index = exam.studentIds.IndexOf(x.id);
  914. if (index != -1)
  915. {
  916. if (exam.studentAnswers[index].Count > 0)
  917. {
  918. bool flag = exam.studentScores[index].Exists(x => x == -1);
  919. if (!flag)
  920. {
  921. ts = 1;
  922. iss = true;
  923. break;
  924. }
  925. else
  926. {
  927. ts = 0;
  928. }
  929. }
  930. else
  931. {
  932. ts = -1;
  933. }
  934. }
  935. }
  936. }
  937. else
  938. {
  939. ts = -1;
  940. }
  941. stuActivities.Add(new StuActivity
  942. {
  943. pk = "Activity",
  944. id = info.id,
  945. code = $"Activity-{x.code.Replace("Base-", "")}-{x.id}",
  946. type = "Exam",
  947. name = info.name,
  948. source = info.source,
  949. startTime = info.startTime,
  950. endTime = info.endTime,
  951. scode = info.code,
  952. scope = info.scope,
  953. school = info.school,
  954. creatorId = info.creatorId,
  955. subjects = sub,
  956. blob = null,
  957. owner = info.owner,
  958. classIds = classIds.ToList(),
  959. createTime = info.createTime,
  960. qamode = info.qamode,
  961. ext = new Dictionary<string, JsonElement>() { { "type", info.examType.ToJsonString().ToObject<JsonElement>() },
  962. { "subjects", info.subjects.ToJsonString().ToObject<JsonElement>() } },
  963. taskStatus = ts,
  964. sStatus = iss ? 1 : 0,
  965. });
  966. });
  967. }
  968. await ActivityService.SaveStuActivity(client, _dingDing, stuActivities, tmdActivities, null);
  969. return classLists;
  970. }
  971. public static async Task<List<double>> knowledgeCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
  972. double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
  973. {
  974. List<double> akp = new();
  975. try
  976. {
  977. int phcount = 0;
  978. int plcount = 0;
  979. //存放并去重知识点
  980. HashSet<string> kname = new HashSet<string>();
  981. if (info.papers[no].knowledge.Count > 0)
  982. {
  983. info.papers[no].knowledge.ForEach(kno =>
  984. {
  985. kno.ForEach(k =>
  986. {
  987. kname.Add(k);
  988. });
  989. });
  990. List<string> knowledgeName = new List<string>();
  991. foreach (string cla in kname)
  992. {
  993. knowledgeName.Add(cla);
  994. }
  995. for (int k = 0; k < knowledgeName.Count; k++)
  996. {
  997. if (null == knowledgeName[k])
  998. {
  999. knowledgeName.Remove(knowledgeName[k]);
  1000. }
  1001. }
  1002. foreach (ExamClassResult classResult in classResults)
  1003. {
  1004. if (classResult.subjectId.Equals(subject.id))
  1005. {
  1006. //List<int> phc = new List<int>();
  1007. List<int> ph = new List<int>();
  1008. List<int> pl = new List<int>();
  1009. List<int> pc = new List<int>();
  1010. List<double> persent = new List<double>();
  1011. int lostStu = classResult.status.Where(c => c == 1).ToList().Count;
  1012. for (int i = 0; i < knowledgeName.Count; i++)
  1013. {
  1014. //初始化单个知识点得分
  1015. double score = 0;
  1016. int n = 0;
  1017. int phCount = 0;
  1018. int plCount = 0;
  1019. int pCount = 0;
  1020. double classScore = 0;
  1021. foreach (List<string> str in info.papers[no].knowledge)
  1022. {
  1023. if (str.Contains(knowledgeName[i]))
  1024. {
  1025. var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
  1026. classScore += info.papers[no].point.Count > 0 ? (info.papers[no].point[n] * itemPersent) : 0;
  1027. foreach (string id in classResult.studentIds)
  1028. {
  1029. int index = classResult.studentIds.IndexOf(id);
  1030. if (classResult.studentScores.Count > 0)
  1031. {
  1032. if (classResult.studentScores[index].Count > 0)
  1033. {
  1034. double realScore = classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n] * itemPersent;
  1035. score += realScore;
  1036. //score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n] * itemPersent;
  1037. if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
  1038. {
  1039. if (classResult.studentScores[index][n] <= 0)
  1040. {
  1041. phCount++;
  1042. }
  1043. phcount++;
  1044. continue;
  1045. }
  1046. if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
  1047. {
  1048. if (classResult.studentScores[index][n] <= 0)
  1049. {
  1050. plCount++;
  1051. }
  1052. plcount++;
  1053. continue;
  1054. }
  1055. if (classResult.studentScores[index][n] <= 0)
  1056. {
  1057. pCount++;
  1058. }
  1059. }
  1060. }
  1061. }
  1062. }
  1063. n++;
  1064. }
  1065. pc.Add(pCount);
  1066. ph.Add(phCount);
  1067. pl.Add(plCount);
  1068. double per = classResult.studentIds.Count - lostStu > 0 ? Math.Round(score / (classResult.studentIds.Count - lostStu), 2) : 0;
  1069. persent.Add(classScore > 0 ? Math.Round(per * 1.0 / classScore, 2) : 0);
  1070. }
  1071. classResult.phc = ph;
  1072. classResult.plc = pl;
  1073. classResult.pc = pc;
  1074. classResult.krate = persent;
  1075. }
  1076. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
  1077. }
  1078. foreach (string k in knowledgeName)
  1079. {
  1080. double score = 0;
  1081. double allScore = 0;
  1082. int count = 0;
  1083. int m = 0;
  1084. foreach (List<string> str in info.papers[no].knowledge)
  1085. {
  1086. if (str.Contains(k))
  1087. {
  1088. var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
  1089. allScore += info.papers[no].point.Count > 0 ? info.papers[no].point[m] * itemPersent : 0;
  1090. }
  1091. m++;
  1092. }
  1093. foreach (ExamClassResult result in classResults)
  1094. {
  1095. if (result.subjectId.Equals(subject.id))
  1096. {
  1097. int n = 0;
  1098. foreach (List<string> str in info.papers[no].knowledge)
  1099. {
  1100. if (str.Contains(k))
  1101. {
  1102. var itemPersent = str.Count > 0 ? 1 / Convert.ToDouble(str.Count) : 0;
  1103. if (result.studentScores.Count > 0)
  1104. {
  1105. foreach (List<double> sc in result.studentScores)
  1106. {
  1107. double tsc = sc[n] == -1 ? 0 : sc[n];
  1108. score += (tsc * itemPersent);
  1109. }
  1110. }
  1111. }
  1112. n++;
  1113. }
  1114. count += result.studentIds.Count;
  1115. }
  1116. }
  1117. double per = count - info.lostStu.Count > 0 ? Math.Round(score / (count - info.lostStu.Count), 2) : 0;
  1118. akp.Add(allScore > 0 ? Math.Round(per / allScore, 2) : 0);
  1119. }
  1120. }
  1121. return akp;
  1122. }
  1123. catch (Exception ex)
  1124. {
  1125. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测知识点结算异常{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  1126. return null;
  1127. }
  1128. }
  1129. public static async Task<List<double>> fieldCount(ExamInfo info, ExamSubject subject, DingDing _dingDing, int no, List<ExamClassResult> classResults,
  1130. double rhwCount, double rhw, double rhlCount, double rhl, AzureCosmosFactory _azureCosmos)
  1131. {
  1132. List<double> afp = new();
  1133. try
  1134. {
  1135. int phcount = 0;
  1136. int plcount = 0;
  1137. //存放并去重知识点
  1138. List<int> knowledgeName = new List<int>() { 1, 2, 3, 4, 5, 6 };
  1139. /* knowledgeName.Add(1);
  1140. knowledgeName.Add(2);
  1141. knowledgeName.Add(3);
  1142. knowledgeName.Add(4);
  1143. knowledgeName.Add(5);
  1144. knowledgeName.Add(6);*/
  1145. foreach (ExamClassResult classResult in classResults)
  1146. {
  1147. if (classResult.subjectId.Equals(subject.id))
  1148. {
  1149. //List<int> phc = new List<int>();
  1150. List<int> ph = new List<int>();
  1151. List<int> pl = new List<int>();
  1152. List<int> pc = new List<int>();
  1153. List<double> persent = new List<double>();
  1154. int lostStu = classResult.status.Where(c => c == 1).ToList().Count;
  1155. for (int i = 0; i < knowledgeName.Count; i++)
  1156. {
  1157. //初始化单个知识点得分
  1158. double score = 0;
  1159. int n = 0;
  1160. int phCount = 0;
  1161. int plCount = 0;
  1162. int pCount = 0;
  1163. double classScore = 0;
  1164. if (info.papers[no].field.Count > 0)
  1165. {
  1166. foreach (int str in info.papers[no].field)
  1167. {
  1168. if (str == knowledgeName[i])
  1169. {
  1170. var itemPersent = 1;
  1171. classScore += info.papers[no].point.Count > 0 ? info.papers[no].point[n] * itemPersent : 0;
  1172. foreach (string id in classResult.studentIds)
  1173. {
  1174. int index = classResult.studentIds.IndexOf(id);
  1175. if (classResult.studentScores.Count > 0)
  1176. {
  1177. if (classResult.studentScores[index].Count > 0)
  1178. {
  1179. score += classResult.studentScores[index][n] == -1 ? 0 : classResult.studentScores[index][n];
  1180. if (classResult.studentScores[index].Sum() >= rhw && phcount < rhwCount)
  1181. {
  1182. if (classResult.studentScores[index][n] <= 0)
  1183. {
  1184. phCount++;
  1185. }
  1186. phcount++;
  1187. continue;
  1188. }
  1189. if (classResult.studentScores[index].Sum() <= rhl && plcount < (info.stuCount - rhlCount))
  1190. {
  1191. if (classResult.studentScores[index][n] <= 0)
  1192. {
  1193. plCount++;
  1194. }
  1195. plcount++;
  1196. continue;
  1197. }
  1198. if (classResult.studentScores[index][n] <= 0)
  1199. {
  1200. pCount++;
  1201. }
  1202. }
  1203. }
  1204. }
  1205. }
  1206. n++;
  1207. }
  1208. pc.Add(pCount);
  1209. ph.Add(phCount);
  1210. pl.Add(plCount);
  1211. double per = classResult.studentIds.Count - lostStu > 0 ? Math.Round(score / (classResult.studentIds.Count - lostStu), 2) : 0;
  1212. persent.Add(classScore > 0 ? Math.Round(per / classScore, 2) : 0);
  1213. }
  1214. }
  1215. classResult.fphc = ph;
  1216. classResult.fplc = pl;
  1217. classResult.fpc = pc;
  1218. classResult.frate = persent;
  1219. }
  1220. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new Azure.Cosmos.PartitionKey($"{classResult.code}"));
  1221. }
  1222. for (int i = 0; i < knowledgeName.Count; i++)
  1223. {
  1224. double score = 0;
  1225. double allScore = 0;
  1226. int count = 0;
  1227. int m = 0;
  1228. foreach (int str in info.papers[no].field)
  1229. {
  1230. if (str == knowledgeName[i])
  1231. {
  1232. var itemPersent = 1;
  1233. allScore += info.papers[no].point.Count > 0 ? info.papers[no].point[m] * itemPersent : 0;
  1234. }
  1235. m++;
  1236. }
  1237. foreach (ExamClassResult result in classResults)
  1238. {
  1239. if (result.subjectId.Equals(subject.id))
  1240. {
  1241. int n = 0;
  1242. foreach (int str in info.papers[no].field)
  1243. {
  1244. var itemPersent = 1;
  1245. if (str == knowledgeName[i])
  1246. {
  1247. if (result.studentScores.Count > 0)
  1248. {
  1249. foreach (List<double> sc in result.studentScores)
  1250. {
  1251. double tsc = sc[n] == -1 ? 0 : sc[n];
  1252. score += tsc * itemPersent;
  1253. }
  1254. }
  1255. }
  1256. n++;
  1257. }
  1258. count += result.studentIds.Count;
  1259. }
  1260. }
  1261. double per = count - info.lostStu.Count > 0 ? Math.Round(score / (count - info.lostStu.Count), 2) : 0;
  1262. afp.Add(allScore > 0 ? Math.Round(per / allScore, 2) : 0);
  1263. }
  1264. return afp;
  1265. }
  1266. catch (Exception ex)
  1267. {
  1268. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-{info.id}-评测认知层次结算异常{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
  1269. return null;
  1270. }
  1271. }
  1272. //处理选题计数
  1273. public static List<Dictionary<string, int>> getMore(ExamInfo info, int no, List<List<List<string>>> list)
  1274. {
  1275. List<Dictionary<string, int>> recorde = new List<Dictionary<string, int>>();
  1276. try
  1277. {
  1278. for (int i = 0; i < info.papers[no].answers.Count; i++)
  1279. {
  1280. if (info.papers[no].answers[i].Count <= 0)
  1281. {
  1282. recorde.Add(new Dictionary<string, int>());
  1283. continue;
  1284. }
  1285. Dictionary<string, int> optCount = new Dictionary<string, int>();
  1286. foreach (List<List<string>> stu in list)
  1287. {
  1288. if (stu.Count == info.papers[no].answers.Count)
  1289. {
  1290. var item = stu[i];
  1291. foreach (string opt in item)
  1292. {
  1293. if (optCount.ContainsKey(opt))
  1294. {
  1295. optCount[opt] = optCount[opt] + 1;
  1296. }
  1297. else
  1298. {
  1299. optCount[opt] = 1;
  1300. }
  1301. }
  1302. }
  1303. }
  1304. recorde.Add(optCount);
  1305. }
  1306. return recorde;
  1307. }
  1308. catch (Exception)
  1309. {
  1310. return recorde;
  1311. }
  1312. }
  1313. public static async Task createClassResultAsync(ExamInfo info, List<ExamClassResult> examClassResults, ExamSubject subject, int no, AzureCosmosFactory _azureCosmos, DingDing _dingDing, AzureStorageFactory _azureStorage, IHttpClientFactory _httpClient, IConfiguration _configuration)
  1314. {
  1315. //保证试卷信息与科目信息同步
  1316. ExamResult result = new ExamResult();
  1317. //人数总和
  1318. int Count = 0;
  1319. int m = 0;
  1320. double score = 0;
  1321. //标准差
  1322. //double powSum = 0;
  1323. double allScore = info.papers[no].point.Sum();
  1324. List<ClassRange> classRanges = new List<ClassRange>();
  1325. List<string> lostStu = new List<string>();
  1326. List<double> csRate = new List<double>();
  1327. List<List<List<string>>> opt = new List<List<List<string>>>();
  1328. //List<Task<ItemResponse<ExamClassResult>>> tasks = new();
  1329. foreach (ExamClassResult classResult in examClassResults)
  1330. {
  1331. double classSrate = 0;
  1332. if (classResult.subjectId.Equals(subject.id))
  1333. {
  1334. foreach (List<List<string>> op in classResult.ans)
  1335. {
  1336. opt.Add(op);
  1337. }
  1338. //记录缺考学生索引位置
  1339. int index_stu = 0;
  1340. foreach (var ans in classResult.studentAnswers)
  1341. {
  1342. if (ans.Count == 0)
  1343. {
  1344. if (!lostStu.Contains(classResult.studentIds[index_stu]))
  1345. {
  1346. lostStu.Add(classResult.studentIds[index_stu]);
  1347. }
  1348. }
  1349. else
  1350. {
  1351. if (classResult.status[index_stu] == 1)
  1352. {
  1353. if (!lostStu.Contains(classResult.studentIds[index_stu]))
  1354. {
  1355. lostStu.Add(classResult.studentIds[index_stu]);
  1356. }
  1357. }
  1358. }
  1359. index_stu++;
  1360. }
  1361. int index = 0;
  1362. foreach (List<double> scores in classResult.studentScores)
  1363. {
  1364. List<double> newScores = new List<double>();
  1365. //int count = 0;
  1366. foreach (double sc in scores)
  1367. {
  1368. newScores.Add(sc > -1 ? sc : 0);
  1369. }
  1370. classSrate += newScores.Sum();
  1371. score += newScores.Sum();
  1372. result.studentScores.Add(newScores);
  1373. index++;
  1374. }
  1375. //处理班级信息
  1376. ClassRange range = new ClassRange();
  1377. range.id = classResult.info.id;
  1378. range.name = classResult.info.name;
  1379. range.gradeId = classResult.gradeId;
  1380. List<int> ran = new List<int>();
  1381. int stuCount = classResult.studentIds.Count;
  1382. //todo 与实际的缺考人数比较
  1383. int lostStus = classResult.status.Where(c => c == 1).ToList().Count;
  1384. Count += stuCount;
  1385. if (m == 0)
  1386. {
  1387. ran.Add(0);
  1388. ran.Add(stuCount - 1);
  1389. }
  1390. else
  1391. {
  1392. ran.Add(Count - stuCount);
  1393. ran.Add(Count - 1);
  1394. }
  1395. m++;
  1396. range.range = ran;
  1397. classRanges.Add(range);
  1398. //处理学生ID
  1399. foreach (string id in classResult.studentIds)
  1400. {
  1401. result.studentIds.Add(id);
  1402. }
  1403. if (allScore > 0)
  1404. {
  1405. csRate.Add(classResult.studentIds.Count - lostStus > 0 ? Math.Round(classSrate * 1.0 / (classResult.studentIds.Count - lostStus), 2) : 0 / allScore);
  1406. }
  1407. else
  1408. {
  1409. csRate.Add(0);
  1410. }
  1411. //powSum += Math.Pow(classSrate - result.average, 2);
  1412. //处理选项计数内容
  1413. }
  1414. //tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync(classResult, classResult.id, new PartitionKey($"{classResult.code}")));
  1415. }
  1416. //await tasks.TaskPage(10);
  1417. /*foreach (string id in result.lostStus) {
  1418. if (!examClassResults[0].studentIds.Contains(id)) {
  1419. int index = result.lostStus.IndexOf(id);
  1420. result.lostStus.RemoveAt(index);
  1421. }
  1422. }*/
  1423. //处理人员变更时被移除的人员
  1424. result.lostStus = lostStu;
  1425. if (result.lostStus.Count > 0)
  1426. {
  1427. for (int i = 0; i < result.lostStus.Count; i++)
  1428. {
  1429. if (!examClassResults[0].studentIds.Contains(result.lostStus[i]))
  1430. {
  1431. result.lostStus.RemoveAt(i);
  1432. }
  1433. }
  1434. }
  1435. result.record = getMore(info, no, opt);
  1436. result.average = result.studentIds.Count - result.lostStus.Count > 0 ? Math.Round(score * 1.0 / (result.studentIds.Count - result.lostStus.Count), 2) : 0;
  1437. double powSum = 0;
  1438. //int sco = 0;
  1439. result.studentIds.ForEach(x =>
  1440. {
  1441. double sc = result.studentScores[result.studentIds.IndexOf(x)].Sum();
  1442. if (!result.lostStus.Contains(x))
  1443. {
  1444. powSum += Math.Pow(sc - result.average, 2);
  1445. }
  1446. });
  1447. result.standard = Math.Round((result.studentIds.Count - result.lostStus.Count) > 0 ? Math.Pow(powSum / (result.studentIds.Count - result.lostStus.Count), 0.5) : 0, 2);
  1448. result.csRate = csRate;
  1449. result.sRate = allScore > 0 ? Math.Round(result.average / allScore * 100, 2) : 0;
  1450. result.classes = classRanges;
  1451. result.code = "ExamResult-" + info.id;
  1452. result.school = info.school;
  1453. result.id = subject.id;
  1454. result.examId = info.id;
  1455. result.subjectId = subject.id;
  1456. result.year = info.year;
  1457. result.paper = info.papers[no];
  1458. //result.point = info.papers[j].point;
  1459. result.scope = info.scope;
  1460. result.name = info.name;
  1461. result.time = info.startTime;
  1462. await examRecordCount(info, subject, _dingDing, no, result, examClassResults, _azureCosmos);
  1463. await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Common").UpsertItemAsync(result, new Azure.Cosmos.PartitionKey($"ExamResult-{info.id}"));
  1464. List<ErrorItems> errorItems = new();
  1465. 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}'"))})";
  1466. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Student").GetItemQueryIterator<ErrorItems>(queryText: sqlqueryText, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("ErrorItems") }))
  1467. {
  1468. errorItems.Add(item);
  1469. }
  1470. if (errorItems.Count == 0)
  1471. {
  1472. // 新增逻辑 收集错题内容
  1473. BlobDownloadResult index_json;
  1474. if (info.scope.Equals("school"))
  1475. {
  1476. index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  1477. }
  1478. else
  1479. {
  1480. index_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  1481. }
  1482. //BlobDownloadResult index_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/index.json").DownloadContentAsync();
  1483. JObject jo = JObject.Parse(index_json.Content.ToString());
  1484. JArray array = jo.Value<JArray>("slides");
  1485. List<string> urls = new();
  1486. foreach (var ne in array)
  1487. {
  1488. if (!ne["type"].ToString().Equals("compose"))
  1489. {
  1490. urls.Add(ne["url"].ToString());
  1491. }
  1492. }
  1493. string code = string.Empty;
  1494. string pk = string.Empty;
  1495. string table = "School";
  1496. if (info.scope.Equals("school"))
  1497. {
  1498. code = $"ErrorItems-{info.school}";
  1499. pk = $"Item-{info.school}";
  1500. }
  1501. else
  1502. {
  1503. code = "ErrorItems";
  1504. pk = $"Item-{info.creatorId}";
  1505. table = "Teacher";
  1506. }
  1507. // 获取整体的题目ID集合
  1508. List<string> ids = new();
  1509. List<(string id, string pid, int level, string type, List<string> knows)> itemInfos = new();
  1510. foreach (string url in urls)
  1511. {
  1512. string id = url.Replace(".json", "");
  1513. BlobDownloadResult index_item_json;
  1514. if (info.scope.Equals("school"))
  1515. {
  1516. index_item_json = await _azureStorage.GetBlobContainerClient($"{info.school}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
  1517. }
  1518. else
  1519. {
  1520. index_item_json = await _azureStorage.GetBlobContainerClient($"{info.creatorId}").GetBlobClient($"{info.papers[no].blob}/{url}").DownloadContentAsync();
  1521. }
  1522. JObject keys = JObject.Parse(index_item_json.Content.ToString());
  1523. string type = keys["exercise"].Value<string>("type");
  1524. int level = keys["exercise"].Value<int>("level");
  1525. var knowledge = keys["exercise"].Value<JArray>("knowledge")?.ToObject<List<string>>();
  1526. string pid = keys.Value<string>("pid");
  1527. itemInfos.Add((id, pid, level, type, knowledge));
  1528. }
  1529. /*await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, table).GetItemQueryStreamIterator(
  1530. 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}") }))
  1531. {
  1532. using var json = await JsonDocument.ParseAsync(item.ContentStream);
  1533. if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
  1534. {
  1535. var accounts = json.RootElement.GetProperty("Documents").EnumerateArray();
  1536. while (accounts.MoveNext())
  1537. {
  1538. JsonElement account = accounts.Current;
  1539. string pid = "";
  1540. if (account.TryGetProperty("pid",out JsonElement element)) {
  1541. pid = element.GetString();
  1542. }
  1543. itemInfos.Add((account.GetProperty("id").GetString(), pid, account.GetProperty("level").GetInt32(), account.GetProperty("type").GetString()));
  1544. }
  1545. }
  1546. }*/
  1547. double[] point = StringHelper.ListTodouble(result.paper.point);
  1548. double[,] res = StringHelper.ListToDouble(result.studentScores);
  1549. var cdm = new ClouDASMatrix(res, point);
  1550. //需要努力的题目
  1551. var ss = cdm.StriveTopic;
  1552. int n = 0;
  1553. List<Task<ItemResponse<ErrorItems>>> task_error = new();
  1554. List<ErrorItems> errors = new();
  1555. foreach (var sIds in result.studentIds)
  1556. {
  1557. ErrorItems error = new()
  1558. {
  1559. ttl = -1,
  1560. code = code,
  1561. id = Guid.NewGuid().ToString(),
  1562. stuId = sIds,
  1563. school = info.school,
  1564. activityId = info.id,
  1565. subjectId = result.subjectId,
  1566. time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
  1567. };
  1568. //顺序学生错题的索引
  1569. int[] item_index = ss[n];
  1570. foreach (var item in item_index)
  1571. {
  1572. Items items = new()
  1573. {
  1574. id = urls[item - 1].Replace(".json", ""),
  1575. blob = info.papers[no].blob
  1576. };
  1577. items.level = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().level;
  1578. items.type = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().type;
  1579. items.pId = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().pid;
  1580. items.knowledge = itemInfos.Where(c => c.id.Equals(items.id)).FirstOrDefault().knows;
  1581. error.its.Add(items);
  1582. }
  1583. errors.Add(error);
  1584. n++;
  1585. task_error.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Student").CreateItemAsync(error, new PartitionKey($"{error.code}")));
  1586. }
  1587. //string connect = _configuration.GetValue<string>("HaBookAuth:Crtmabank") + "https://malearnfunction.chinacloudsites.cn/api/crtmabank";
  1588. string location = $"{Environment.GetEnvironmentVariable("Option:Location")}";
  1589. string urlAction = string.Empty;
  1590. if (location.Contains("China") || location.Contains("China-Dep"))
  1591. {
  1592. urlAction = "https://malearnfunction.chinacloudsites.cn";
  1593. }
  1594. else if (location.Contains("Global"))
  1595. {
  1596. urlAction = "https://malearnfunction.azurewebsites.net";
  1597. }
  1598. else if (location.Contains("Global-Test"))
  1599. {
  1600. urlAction = "https://malearn-test.azurewebsites.net";
  1601. }
  1602. string connect = $"{urlAction}/api/crtmabank";
  1603. var htc = _httpClient.CreateClient();
  1604. if (htc.DefaultRequestHeaders.Contains("x-functions-key"))
  1605. {
  1606. htc.DefaultRequestHeaders.Remove("x-functions-key");
  1607. }
  1608. htc.DefaultRequestHeaders.Add("x-functions-key", "QUzQqbqbnLsTDTeaJy4Br6wUuqPoAlKpzRK2S6PGImRHAzFuySGAeA==");
  1609. string paramJson = JsonConvert.SerializeObject(errors);
  1610. var content = new StringContent(paramJson, Encoding.UTF8, "application/json");
  1611. await htc.PostAsync(connect, content);
  1612. await task_error.TaskPage(10);
  1613. }
  1614. }
  1615. public class Settlement
  1616. {
  1617. public double rate { get; set; }
  1618. public double score { get; set; }
  1619. public List<string> stus { get; set; } = new List<string>();
  1620. public int total { get; set; }
  1621. public double qrate { get; set; }
  1622. }
  1623. }
  1624. }