ScsYxptApis.cs 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034
  1. using Azure.Cosmos;
  2. using HTEXLib.COMM.Helpers;
  3. using Microsoft.Azure.Functions.Worker;
  4. using Microsoft.Azure.Functions.Worker.Http;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.IO;
  8. using System.Linq;
  9. using System.Net;
  10. using System.Net.Http;
  11. using System.Text;
  12. using System.Text.Json;
  13. using System.Threading.Tasks;
  14. using TEAMModelOS.SDK;
  15. using TEAMModelOS.SDK.DI;
  16. using TEAMModelOS.SDK.Extension;
  17. using TEAMModelOS.SDK.Models;
  18. namespace TEAMModelOS.FunctionV4
  19. {
  20. public class ScsYxptApis
  21. {
  22. private readonly AzureCosmosFactory _azureCosmos;
  23. private readonly DingDing _dingDing;
  24. private readonly AzureStorageFactory _azureStorage;
  25. private readonly AzureRedisFactory _azureRedis;
  26. private readonly IHttpClientFactory _httpClient;
  27. public static string Code { get; set; }
  28. public static Dictionary<string, object> parameterMap = null;
  29. public ScsYxptApis(IHttpClientFactory httpClient,AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage
  30. , AzureRedisFactory azureRedis)
  31. {
  32. _azureCosmos = azureCosmos;
  33. _dingDing = dingDing;
  34. _azureStorage = azureStorage;
  35. _azureRedis = azureRedis;
  36. _httpClient= httpClient;
  37. }
  38. /// <summary>
  39. /// 5.3.1.1获取项目列表
  40. /// </summary>
  41. /// <param name="req"></param>
  42. /// <param name="log"></param>
  43. /// <returns></returns>
  44. // [Function("GetProjectInfoByTrainComIDV2")]
  45. public async Task<HttpResponseData> GetProjectInfoByTrainComIDV2([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  46. {
  47. var response = req.CreateResponse(HttpStatusCode.OK);
  48. List<ScProject> projects = new List<ScProject>();
  49. string data = await new StreamReader(req.Body).ReadToEndAsync();
  50. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  51. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  52. string areaId = null;
  53. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  54. {
  55. areaId = $"{_areaId}";
  56. }
  57. Code = "GetProjectInfoByTrainComID";
  58. parameterMap = new Dictionary<string, object>();
  59. parameterMap.Add("TrainComID", config.trainComID);
  60. ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.1获取项目列表" };
  61. try
  62. {
  63. result = await ThirdApisService.Post(_httpClient.CreateClient(), config.url, Code, config.passKey, config.privateKey, parameterMap);
  64. if (result.result)
  65. {
  66. projects = result.content.ToObject<List<ScProject>>();
  67. }
  68. else
  69. {
  70. }
  71. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  72. return response;
  73. }
  74. catch (Exception ex)
  75. {
  76. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetProjectInfoByTrainComID\n{ex.Message}\n{ex.StackTrace}\n{result.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  77. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  78. return response;
  79. }
  80. }
  81. /// <summary>
  82. /// 5.3.1.1获取项目列表
  83. /// </summary>
  84. /// <param name="req"></param>
  85. /// <param name="log"></param>
  86. /// <returns></returns>
  87. //[Function("GetProjectInfoByTrainComID")]
  88. public async Task<HttpResponseData> GetProjectInfoByTrainComID([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  89. {
  90. var response = req.CreateResponse(HttpStatusCode.OK);
  91. List<ScProject> projects = new List<ScProject>();
  92. string data = await new StreamReader(req.Body).ReadToEndAsync();
  93. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  94. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  95. string areaId = null;
  96. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  97. {
  98. areaId = $"{_areaId}";
  99. }
  100. Code = "GetProjectInfoByTrainComID";
  101. parameterMap = new Dictionary<string, object>();
  102. parameterMap.Add("TrainComID", config.trainComID);
  103. ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.1获取项目列表" };
  104. try
  105. {
  106. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  107. if (result.result)
  108. {
  109. projects = result.content.ToObject<List<ScProject>>();
  110. }
  111. else
  112. {
  113. }
  114. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  115. return response;
  116. }
  117. catch (Exception ex)
  118. {
  119. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetProjectInfoByTrainComID\n{ex.Message}\n{ex.StackTrace}\n{result.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  120. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  121. return response;
  122. }
  123. }
  124. /// <summary>
  125. /// 5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表
  126. /// </summary>
  127. /// <param name="req"></param>
  128. /// <param name="log"></param>
  129. /// <returns></returns>
  130. //[Function("GetSchoolList")]
  131. public async Task<HttpResponseData> GetSchoolList([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  132. {
  133. var response = req.CreateResponse(HttpStatusCode.OK);
  134. List<ScSchool> scSchools = new List<ScSchool>();
  135. string data = await new StreamReader(req.Body).ReadToEndAsync();
  136. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  137. string areaId = null;
  138. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  139. {
  140. areaId = $"{_areaId}";
  141. }
  142. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  143. Code = "GetSchoolList";
  144. parameterMap = new Dictionary<string, object>();
  145. parameterMap.Add("TrainComID", config.trainComID);
  146. List<ScsResult> results = new List<ScsResult>();
  147. try
  148. {
  149. if (config.p.IsNotEmpty())
  150. {
  151. foreach (var ps in config.p)
  152. {
  153. if (ps.status == 1) {
  154. parameterMap["ProjectID"] = ps.pd;
  155. parameterMap["ProjectItemID"] = ps.pid;
  156. ScsResult result = new ScsResult { bizcode = Code, title = " 5.3.1.18根据机构ID、项目ID、子项目ID返回学校列表" };
  157. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  158. if (result.result)
  159. {
  160. List<ScSchool> schools = result.content.ToObject<List<ScSchool>>();
  161. if (schools.IsNotEmpty())
  162. {
  163. //schools.ForEach(x => { x.ProjectID = int.Parse(ps.pd); x.ProjectItemID = int.Parse(ps.pid); });
  164. scSchools.AddRange(schools);
  165. }
  166. }
  167. results.Add(result);
  168. }
  169. }
  170. }
  171. await response.WriteAsJsonAsync(new { data = scSchools.ToJsonString() });
  172. return response;
  173. }
  174. catch (Exception ex)
  175. {
  176. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSchoolList\n{ex.Message}\n{ex.StackTrace}\n{results.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  177. await response.WriteAsJsonAsync(new { data = scSchools.ToJsonString() });
  178. return response;
  179. }
  180. }
  181. /// <summary>
  182. /// 5.3.1.2获取学员名单
  183. /// </summary>
  184. /// <param name="req"></param>
  185. /// <param name="log"></param>
  186. /// <returns></returns>
  187. //[Function("GetTeachersListByProject")]
  188. public async Task<HttpResponseData> GetTeachersListByProject([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  189. {
  190. var response = req.CreateResponse(HttpStatusCode.OK);
  191. List<ScTeacher> scTeachers = new List<ScTeacher>();
  192. string data = await new StreamReader(req.Body).ReadToEndAsync();
  193. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  194. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  195. string areaId = null;
  196. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  197. {
  198. areaId = $"{_areaId}";
  199. }
  200. Code = "GetTeachersListByProject";
  201. parameterMap = new Dictionary<string, object>();
  202. parameterMap.Add("TrainComID", config.trainComID);
  203. List<ScsResult> results = new List<ScsResult>();
  204. try
  205. {
  206. if (config.p.IsNotEmpty())
  207. {
  208. foreach (var ps in config.p)
  209. {
  210. if (ps.status == 1)
  211. {
  212. parameterMap["ProjectID"] = ps.pd;
  213. parameterMap["ProjectItemID"] = ps.pid;
  214. ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.2获取学员名单" };
  215. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  216. if (result.result)
  217. {
  218. List<ScTeacher> teachers = result.content.ToObject<List<ScTeacher>>();
  219. if (teachers.IsNotEmpty())
  220. {
  221. scTeachers.AddRange(teachers);
  222. }
  223. }
  224. results.Add(result);
  225. }
  226. }
  227. }
  228. await response.WriteAsJsonAsync(new { data = scTeachers.ToJsonString() });
  229. return response;
  230. }
  231. catch (Exception ex)
  232. {
  233. await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetTeachersListByProject\n{ex.Message}\n{ex.StackTrace}\n{results.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  234. await response.WriteAsJsonAsync(new { data = scTeachers.ToJsonString() });
  235. return response;
  236. }
  237. }
  238. /// <summary>
  239. /// 5.3.1.20获取学校设置的可选能力点
  240. /// </summary>
  241. /// <param name="req"></param>
  242. /// <param name="log"></param>
  243. /// <returns></returns>
  244. //[Function("GetSchoolDiagnosis")]
  245. public async Task<HttpResponseData> GetSchoolDiagnosis([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  246. {
  247. var response = req.CreateResponse(HttpStatusCode.OK);
  248. List<ScsProjectDiagnosis> projects = new List<ScsProjectDiagnosis>();
  249. string data = await new StreamReader(req.Body).ReadToEndAsync();
  250. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  251. JsonElement schoolCode = data.ToObject<JsonElement>().GetProperty("schoolCode");
  252. string areaId = null;
  253. if(data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  254. {
  255. areaId = $"{_areaId}";
  256. }
  257. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  258. Code = "GetSchoolDiagnosis";
  259. var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
  260. parameterMap = new Dictionary<string, object>();
  261. parameterMap.Add("TrainComID", config.trainComID);
  262. List<ScsResult> results = new List<ScsResult>();
  263. try
  264. {
  265. if (config.p.IsNotEmpty())
  266. {
  267. foreach (var ps in config.p)
  268. {
  269. if (ps.status == 1) {
  270. parameterMap["ProjectID"] = ps.pd;
  271. parameterMap["ProjectItemID"] = ps.pid;
  272. parameterMap["SchoolID"] = $"{schoolCode}";
  273. parameterMap["School"] = $"{schoolCode}";
  274. ScsResult result = new ScsResult { bizcode = Code, title = " 5.3.1.20获取学校设置的可选能力点" };
  275. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  276. if (result.result)
  277. {
  278. List<ScPDiagnosis> diagnoses = result.content.ToObject<List<ScPDiagnosis>>();
  279. if (diagnoses.IsNotEmpty())
  280. {
  281. projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = diagnoses, });
  282. await table.SaveOrUpdate<ScProjectDiagnosis>(new ScProjectDiagnosis
  283. {
  284. schoolCode = $"{schoolCode}",
  285. areaId = areaId,
  286. ProjectID = int.Parse(ps.pd),
  287. ProjectItemID = int.Parse(ps.pid),
  288. RowKey = $"{ps.pid}-{schoolCode}",
  289. PartitionKey = "ScSchoolDiagnosis",
  290. abilityNos = diagnoses.ToJsonString()
  291. });
  292. }
  293. }
  294. else
  295. {
  296. List<ScProjectDiagnosis> teacherDiagnoses = await table.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScSchoolDiagnosis" }, { "RowKey", $"{ps.pid}-{schoolCode}" } });
  297. if (teacherDiagnoses.IsNotEmpty())
  298. {
  299. projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
  300. }
  301. }
  302. results.Add(result);
  303. }
  304. }
  305. }
  306. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  307. return response;
  308. }
  309. catch (Exception ex)
  310. {
  311. //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSchoolDiagnosis\n{ex.Message}\n{ex.StackTrace}\n{results.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  312. if (config.p.IsNotEmpty())
  313. {
  314. foreach (var ps in config.p)
  315. {
  316. List<ScProjectDiagnosis> teacherDiagnoses = await table.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScSchoolDiagnosis" }, { "RowKey", $"{ps.pid}-{schoolCode}" } });
  317. if (teacherDiagnoses.IsNotEmpty())
  318. {
  319. projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
  320. }
  321. }
  322. }
  323. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  324. return response;
  325. }
  326. }
  327. /// <summary>
  328. /// 5.3.1.19获取项目设置的可选能力点
  329. /// </summary>
  330. /// <param name="req"></param>
  331. /// <param name="log"></param>
  332. /// <returns></returns>
  333. //[Function("GetProjectDiagnosis")]
  334. public async Task<HttpResponseData> GetProjectDiagnosis([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  335. {
  336. var response = req.CreateResponse(HttpStatusCode.OK);
  337. List<ScsProjectDiagnosis> projects = new List<ScsProjectDiagnosis>();
  338. string data = await new StreamReader(req.Body).ReadToEndAsync();
  339. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  340. string areaId = null;
  341. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  342. {
  343. areaId = $"{_areaId}";
  344. }
  345. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  346. Code = "GetProjectDiagnosis";
  347. var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
  348. parameterMap = new Dictionary<string, object>();
  349. parameterMap.Add("TrainComID", config.trainComID);
  350. List<ScsResult> results = new List<ScsResult>();
  351. try
  352. {
  353. if (config.p.IsNotEmpty())
  354. {
  355. foreach (var ps in config.p)
  356. {
  357. if (ps.status==1) {
  358. parameterMap["ProjectID"] = ps.pd;
  359. parameterMap["ProjectItemID"] = ps.pid;
  360. ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.19获取项目设置的可选能力点" };
  361. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  362. if (result.result)
  363. {
  364. List<ScPDiagnosis> diagnoses = result.content.ToObject<List<ScPDiagnosis>>();
  365. if (diagnoses.IsNotEmpty())
  366. {
  367. projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = diagnoses });
  368. await table.SaveOrUpdate<ScProjectDiagnosis>(new ScProjectDiagnosis { areaId = areaId, RowKey = $"{ps.pid}", PartitionKey = "ScProjectDiagnosis", abilityNos = diagnoses.ToJsonString() });
  369. }
  370. }
  371. else
  372. {
  373. List<ScProjectDiagnosis> teacherDiagnoses = await table.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScProjectDiagnosis" }, { "RowKey", $"{ps.pid}" } });
  374. if (teacherDiagnoses.IsNotEmpty())
  375. {
  376. projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
  377. }
  378. }
  379. results.Add(result);
  380. }
  381. }
  382. }
  383. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  384. return response;
  385. }
  386. catch (Exception ex)
  387. {
  388. if (config.p.IsNotEmpty())
  389. {
  390. foreach (var ps in config.p)
  391. {
  392. //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetProjectDiagnosis\n{ex.Message}\n{ex.StackTrace}\n{results.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  393. List<ScProjectDiagnosis> teacherDiagnoses = await table.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScProjectDiagnosis" }, { "RowKey", $"{ps.pid}" } });
  394. if (teacherDiagnoses.IsNotEmpty())
  395. {
  396. projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
  397. }
  398. }
  399. }
  400. await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
  401. return response;
  402. }
  403. }
  404. /// <summary>
  405. /// 5.3.1.3通过项目编号获取学员测评能力项V2
  406. /// </summary>
  407. /// <param name="req"></param>
  408. /// <param name="log"></param>
  409. /// <returns></returns>
  410. //[Function("GetDiagnosisListByProject_V2")]
  411. public async Task<HttpResponseData> GetDiagnosisListByProject_V2([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  412. {
  413. var response = req.CreateResponse(HttpStatusCode.OK);
  414. List<string> abilityNos = new List<string>();
  415. string data = await new StreamReader(req.Body).ReadToEndAsync();
  416. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  417. string areaId = null;
  418. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  419. {
  420. areaId = $"{_areaId}";
  421. }
  422. var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
  423. JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
  424. JsonElement schoolCode = data.ToObject<JsonElement>().GetProperty("schoolCode");
  425. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  426. Code = "GetDiagnosisListByProject_V2";
  427. parameterMap = new Dictionary<string, object>();
  428. parameterMap.Add("TrainComID", config.trainComID);
  429. parameterMap.Add("PXID", pxid);
  430. ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.3通过项目编号获取学员测评能力项V2" };
  431. try
  432. {
  433. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  434. if (result.result)
  435. {
  436. List<ScDiagnosis> diagnoses = result.content.ToObject<List<ScDiagnosis>>();
  437. if (diagnoses != null)
  438. {
  439. abilityNos = diagnoses.Select(x => x.DiagnosisDicNum).ToList();
  440. }
  441. if (abilityNos.IsNotEmpty())
  442. {
  443. await table.SaveOrUpdate<ScTeacherDiagnosis>(new ScTeacherDiagnosis {areaId = areaId,schoolCode=$"{schoolCode}", RowKey = $"{pxid}", PartitionKey = "ScTeacherDiagnosis", abilityNos = abilityNos.ToJsonString() });
  444. }
  445. }
  446. else
  447. {
  448. List<ScTeacherDiagnosis> teacherDiagnoses = await table.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "RowKey", $"{pxid}" } });
  449. if (teacherDiagnoses.IsNotEmpty())
  450. {
  451. abilityNos = teacherDiagnoses[0].abilityNos.ToObject<List<string>>();
  452. }
  453. }
  454. await response.WriteAsJsonAsync(new { data = abilityNos.ToJsonString() });
  455. return response;
  456. }
  457. catch (Exception ex)
  458. {
  459. //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}\n{ex.StackTrace}\n{result.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  460. List<ScTeacherDiagnosis> teacherDiagnoses = await table.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "RowKey", $"{pxid}" } });
  461. if (teacherDiagnoses.IsNotEmpty())
  462. {
  463. abilityNos = teacherDiagnoses[0].abilityNos.ToObject<List<string>>();
  464. }
  465. await response.WriteAsJsonAsync(new { data = abilityNos.ToJsonString() });
  466. return response;
  467. }
  468. }
  469. /// <summary>
  470. /// 5.3.1.11获取跳转学员信息,用于sso单点,后端验证。
  471. /// </summary>
  472. /// <param name="req"></param>
  473. /// <param name="log"></param>
  474. /// <returns></returns>
  475. //[Function("GetSingleTeacherByProject")]
  476. public async Task<HttpResponseData> GetSingleTeacherByProject([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  477. {
  478. var response = req.CreateResponse(HttpStatusCode.OK);
  479. string teacher = null;
  480. string data = await new StreamReader(req.Body).ReadToEndAsync();
  481. JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
  482. JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
  483. JsonElement tid = data.ToObject<JsonElement>().GetProperty("tid");
  484. ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
  485. string areaId = null;
  486. if (data.ToObject<JsonElement>().TryGetProperty("areaId", out JsonElement _areaId))
  487. {
  488. areaId = $"{_areaId}";
  489. }
  490. Code = "GetSingleTeacherByProject";
  491. parameterMap = new Dictionary<string, object>();
  492. parameterMap.Add("TrainComID", config.trainComID);
  493. parameterMap.Add("Pxid", $"{pxid}");
  494. parameterMap.Add("Tid", $"{tid}");
  495. ScsResult result = new ScsResult { bizcode = Code, title = "5.3.1.11获取跳转学员信息,用于sso单点,后端验证。" };
  496. try
  497. {
  498. ///{“result”:true,”reason”:null,”content”:”{“PXID”:””,”TID”:””,”TeacherName”:””,”ProjectTitle”:””,”ProjectItemTitle”:””,”CityName”:””,
  499. ///”DisName”:””,”SchoolName”:””,”Sex”:””,”PXXK”:””,”PXXD”:””,”TeacherXK”:””,”TeacherXD”:””,”Email”:””}”,”pagecount”:1}
  500. result = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, Code, config.passKey, config.privateKey, parameterMap);
  501. if (result.result)
  502. {
  503. teacher = result.content;
  504. }
  505. await response.WriteAsJsonAsync(new { data = teacher });
  506. return response;
  507. }
  508. catch (Exception ex)
  509. {
  510. //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}\n{ex.StackTrace}\n{result.ToJsonString()}\n{data}", GroupNames.醍摩豆服務運維群組);
  511. await response.WriteAsJsonAsync(new { data = teacher });
  512. return response;
  513. }
  514. }
  515. /// <summary>
  516. /// 数据推送接口
  517. /// </summary>
  518. /// <param name="req"></param>
  519. /// <param name="log"></param>
  520. /// <returns></returns>
  521. //[Function("SchoolDataPush")]
  522. public async Task<HttpResponseData> SchoolDataPush([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
  523. {
  524. var response = req.CreateResponse(HttpStatusCode.OK);
  525. var client = _azureCosmos.GetCosmosClient();
  526. string data = await new StreamReader(req.Body).ReadToEndAsync();
  527. JsonElement areaIdJson = data.ToObject<JsonElement>().GetProperty("areaId");
  528. AreaSetting areaSetting= await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Normal).ReadItemAsync<AreaSetting>($"{areaIdJson}", new PartitionKey("AreaSetting"));
  529. ScAccessConfig config = areaSetting.accessConfig.ToObject<ScAccessConfig>();
  530. JsonElement school = data.ToObject<JsonElement>().GetProperty("school");
  531. List<string> pushTeachers = data.ToObject<JsonElement>().GetProperty("pushTeachers").ToObject<List<string>>();
  532. StringBuilder queryText = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='yxtrain'");
  533. List<GroupList> yxtrain = new List<GroupList>();
  534. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryText.ToString(),
  535. requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
  536. {
  537. yxtrain.Add(item);
  538. }
  539. List<TeacherTrain> trains = new List<TeacherTrain>();
  540. var members = yxtrain.SelectMany(x => x.members).ToList();
  541. //指定推送一部分的教师
  542. if (pushTeachers.IsNotEmpty()) {
  543. members= members.FindAll(x => pushTeachers.Contains(x.id));
  544. }
  545. if (members.IsNotEmpty())
  546. {
  547. queryText = new StringBuilder($"SELECT distinct value(c) FROM c where 1=1 " +
  548. $"and c.id in ({string.Join(",", members.Select(x => $"'{x.id}'"))}) ");
  549. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TeacherTrain>(queryText: queryText.ToString(),
  550. requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"TeacherTrain-{school}") }))
  551. {
  552. trains.Add(item);
  553. }
  554. }
  555. //string sql = $" SELECT value(c) FROM c join a in c.binds where ARRAY_LENGTH(c.binds)>0 and a.type='{config.config}' ";
  556. //List<Teacher> teachers = new List<Teacher>();
  557. //await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(queryText: sql,
  558. // requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
  559. //{
  560. // teachers.Add(item);
  561. //}
  562. var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
  563. List<ScTeacher> scTeachers= await table.FindListByDict<ScTeacher>(new Dictionary<string, object> { { "PartitionKey", "ScTeacher" },{ "schoolCode",$"{school}" } });
  564. List<ScTeacherDiagnosis> scTeacherDiagnoses = await table.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "schoolCode", $"{school}" } });
  565. List<KeyValuePair<TeacherTrain, string>> trainsNO = new List<KeyValuePair<TeacherTrain, string>>();
  566. List<ScsResult> results = new List<ScsResult>();
  567. Dictionary<string, Dictionary<string, object>> pushDatas = new Dictionary<string, Dictionary<string, object>>();
  568. int pages = (trains.Count + 19) / 20; //pages = (total + max -1) / max;
  569. for (int i = 0; i < pages; i++) {
  570. List<TeacherTrain> lists = trains.Skip((i) * 20).Take(20).ToList();
  571. //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
  572. List<TeacherTrain> trains53112OK = new List<TeacherTrain>();
  573. ScsResult UpdateTeacherListSituation = null;
  574. Dictionary<string, object> parameterContent53112 = new Dictionary<string, object>();
  575. List<Dictionary<string, object>> list53112 = new List<Dictionary<string, object>>();
  576. parameterContent53112.Add("TrainComID", config.trainComID);
  577. parameterContent53112.Add("List", list53112);
  578. //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis 300条限制
  579. List<TeacherTrain> trains53113OK = new List<TeacherTrain>();
  580. ScsResult UpdateTeacherListDiagnosis = null;
  581. Dictionary<string, object> parameterContent53113 = new Dictionary<string, object>();
  582. List<Dictionary<string, object>> list53113 = new List<Dictionary<string, object>>();
  583. parameterContent53113.Add("TrainComID", config.trainComID);
  584. parameterContent53113.Add("List", list53113);
  585. //5.3.1.17学员课堂实录批量回写-UploadKTSLList 300条限制
  586. List<TeacherTrain> trains53117OK = new List<TeacherTrain>();
  587. ScsResult UploadKTSLList = null;
  588. Dictionary<string, object> parameterContent53117 = new Dictionary<string, object>();
  589. List<Dictionary<string, object>> list53117 = new List<Dictionary<string, object>>();
  590. parameterContent53117.Add("TrainComID", config.trainComID);
  591. parameterContent53117.Add("List", list53117);
  592. //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2 100条限制
  593. List<TeacherTrain> trains53122OK = new List<TeacherTrain>();
  594. ScsResult UploadSBTARPDFListV2 = null;
  595. Dictionary<string, object> parameterContent53122 = new Dictionary<string, object>();
  596. List<Dictionary<string, object>> list53122 = new List<Dictionary<string, object>>();
  597. parameterContent53122.Add("TrainComID", config.trainComID);
  598. parameterContent53122.Add("List", list53122);
  599. //装载数据
  600. foreach (var x in lists) {
  601. List<CodeValue> msgs = new List<CodeValue>();
  602. List<ScTeacher> teacher = scTeachers.FindAll(t => !string.IsNullOrWhiteSpace(t.tmdid) && t.tmdid.Equals(x.id));
  603. foreach (var t in teacher)
  604. {
  605. List<PushFail> fails = new List<PushFail>();
  606. Dictionary<string,object> pushData = new Dictionary<string, object>();
  607. string json = scTeacherDiagnoses.ToJsonString();
  608. ScTeacherDiagnosis diagnosis = scTeacherDiagnoses.Find(x => x.RowKey.Equals($"{t.PXID}"));
  609. (int t53112OK, List<CodeValue> msgs53112) = check53112(x, msgs);
  610. (int t53113OK, List<CodeValue> msgs53113, List<AbilitySub> abilitySubs) = await check53113(x, diagnosis, msgs);
  611. (int t53117OK, List<CodeValue> msgs53117) = check53117(x, msgs);
  612. (int t53122OK, List<CodeValue> msgs53122) = check53122(x, msgs);
  613. //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
  614. if (t53112OK == 1)
  615. {
  616. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  617. parameterMapData.Add("PXID", $"{t.PXID}");
  618. parameterMapData.Add("TID", $"{t.TID}");
  619. parameterMapData.Add("TeacherName", $"{t.TeacherName}");
  620. parameterMapData.Add("CourseHour", $"{x.totalTime}");
  621. parameterMapData.Add("ResearchText", $"{x.summary}");
  622. /// <summary>
  623. ///省上标准 最终结果 0未认定,1合格,2优秀,3不合格,4其他
  624. ///系统标准 -2 其他 -1 未认定,0不合格,1合格,2优秀
  625. /// </summary>
  626. string ComPassed = "0";
  627. switch (x.finalScore)
  628. {
  629. case -2:
  630. ComPassed = "4";
  631. break;
  632. case -1:
  633. ComPassed = "0";
  634. break;
  635. case 0:
  636. ComPassed = "3";
  637. break;
  638. case 1:
  639. ComPassed = "1";
  640. break;
  641. case 2:
  642. ComPassed = "2";
  643. break;
  644. default:
  645. ComPassed = "4";
  646. break;
  647. }
  648. parameterMapData.Add("ComPassed", ComPassed);//0、未认定 1、合格 2、优秀 3、不合格 4、其他
  649. pushData.Add("success-UpdateTeacherListSituation", parameterMapData);
  650. list53112.Add(parameterMapData);
  651. }
  652. else
  653. {
  654. pushData.Add("fail-UpdateTeacherListSituation", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53112 });
  655. fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53112 });
  656. }
  657. //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
  658. if (t53113OK == 1)
  659. {
  660. List<Dictionary<string, object>> parameterMapDatas = new List<Dictionary<string, object>>();
  661. x.currency.teacherAilities.ForEach(a => {
  662. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  663. parameterMapData.Add("PXID", $"{t.PXID}");
  664. parameterMapData.Add("TID", $"{t.TID}");
  665. parameterMapData.Add("DiagnosisNum", $"{a.no}");
  666. //0"未认定", 1"合格", 2"优秀", 3"不合格"
  667. //系统 -1 未认定,0 不合格,1 合格,2 优秀
  668. string zpscore = "0";
  669. switch (a.zpscore)
  670. {
  671. case -1:
  672. zpscore = "0";
  673. break;
  674. case 0:
  675. zpscore = "3";
  676. break;
  677. case 1:
  678. zpscore = "1";
  679. break;
  680. case 2:
  681. zpscore = "2";
  682. break;
  683. default:
  684. zpscore = "0";
  685. break;
  686. }
  687. string hpscore = "0";
  688. switch (a.hpscore)
  689. {
  690. case -1:
  691. hpscore = "0";
  692. break;
  693. case 0:
  694. hpscore = "3";
  695. break;
  696. case 1:
  697. hpscore = "1";
  698. break;
  699. case 2:
  700. hpscore = "2";
  701. break;
  702. default:
  703. hpscore = "0";
  704. break;
  705. }
  706. string xzpresult = "0";
  707. switch (a.xzscore)
  708. {
  709. case -1:
  710. xzpresult = "0";
  711. break;
  712. case 0:
  713. xzpresult = "3";
  714. break;
  715. case 1:
  716. xzpresult = "1";
  717. break;
  718. case 2:
  719. xzpresult = "2";
  720. break;
  721. default:
  722. xzpresult = "0";
  723. break;
  724. }
  725. parameterMapData.Add("zpresult", zpscore);
  726. parameterMapData.Add("hpresult", hpscore);
  727. parameterMapData.Add("xzpresult", xzpresult);
  728. List<Dictionary<string, object>> pfiles = new List<Dictionary<string, object>>();
  729. parameterMapData.Add("pfiles", pfiles);
  730. AbilitySub abilitySub = abilitySubs.Find(sub => sub.id.Equals(a.id));
  731. if (abilitySub != null)
  732. {
  733. abilitySub.uploads.ForEach(upload => {
  734. upload.urls.ForEach(url => {
  735. Dictionary<string, object> pfileMap = new Dictionary<string, object>();
  736. pfileMap.Add("url", url.url);
  737. pfileMap.Add("fileName", url.name);
  738. pfileMap.Add("fileSize", url.size);
  739. pfileMap.Add("md5", url.hash);
  740. string fileext = url.url.Substring(url.url.LastIndexOf(".") > 0 ? url.url.LastIndexOf(".") + 1 : 0);
  741. pfileMap.Add("fileType", fileext);
  742. pfiles.Add(pfileMap);
  743. });
  744. });
  745. }
  746. list53113.Add(parameterMapData);
  747. parameterMapDatas.Add(parameterMapData);
  748. });
  749. pushData.Add("success-UpdateTeacherListDiagnosis", parameterMapDatas);
  750. }
  751. else
  752. {
  753. pushData.Add("fail-UpdateTeacherListDiagnosis", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53113 });
  754. fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53113 });
  755. }
  756. //5.3.1.17学员课堂实录批量回写-UploadKTSLList
  757. if (t53117OK == 1)
  758. {
  759. List<Dictionary<string, object>> parameterMapDatas = new List<Dictionary<string, object>>();
  760. x.teacherClasses.ForEach(clss =>
  761. {
  762. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  763. parameterMapData.Add("PXID", $"{t.PXID}");
  764. parameterMapData.Add("TID", $"{t.TID}");
  765. parameterMapData.Add("url", clss.url);//添加访问授权
  766. parameterMapData.Add("url2", clss.url);
  767. parameterMapData.Add("fileName", clss.name);
  768. parameterMapData.Add("fileSize", clss.size);
  769. parameterMapData.Add("md5", clss.hash);
  770. string fileext = clss.url.Substring(clss.url.LastIndexOf(".") > 0 ? clss.url.LastIndexOf(".") + 1 : 0);
  771. parameterMapData.Add("fileType", fileext);
  772. list53117.Add(parameterMapData);
  773. parameterMapDatas.Add(parameterMapData);
  774. });
  775. pushData.Add("success-UploadKTSLList", parameterMapDatas);
  776. }
  777. else
  778. {
  779. pushData.Add("fail-UploadKTSLList", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53117 });
  780. fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53117 });
  781. }
  782. //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
  783. if (t53122OK == 1)
  784. {
  785. Dictionary<string, object> parameterMapData = new Dictionary<string, object>();
  786. parameterMapData.Add("PXID", $"{t.PXID}");
  787. parameterMapData.Add("TID", $"{t.TID}");
  788. List<Dictionary<string, object>> files = new List<Dictionary<string, object>>();
  789. x.offlineRecords.ForEach(record => {
  790. if (!string.IsNullOrWhiteSpace(record.url)) {
  791. Dictionary<string, object> fileMap = new Dictionary<string, object>();
  792. fileMap.Add("url", record.url);
  793. fileMap.Add("fileName", record.name);
  794. fileMap.Add("fileSize", record.size);
  795. fileMap.Add("md5", record.hash);
  796. string fileext = record.url.Substring(record.url.LastIndexOf(".") > 0 ? record.url.LastIndexOf(".") + 1 : 0);
  797. fileMap.Add("fileType", fileext);
  798. files.Add(fileMap);
  799. }
  800. });
  801. parameterMapData.Add("files", files);
  802. list53122.Add(parameterMapData);
  803. pushData.Add("success-UploadSBTARPDFListV2", parameterMapData);
  804. }
  805. else
  806. {
  807. pushData.Add("fail-UploadSBTARPDFListV2", new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53122 });
  808. fails.Add(new PushFail { tmdid = t.tmdid, name = t.TeacherName, msgs = msgs53122 });
  809. }
  810. pushDatas.Add(t.tmdid,pushData);
  811. }
  812. }
  813. //推送数据
  814. UpdateTeacherListSituation = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, "UpdateTeacherListSituation", config.passKey, config.privateKey, parameterContent53112);
  815. UpdateTeacherListSituation.bizcode = "UpdateTeacherListSituation";
  816. UpdateTeacherListSituation.title = "5.3.1.12学员培训基本情况批量回写";
  817. UpdateTeacherListDiagnosis = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, "UpdateTeacherListDiagnosis", config.passKey, config.privateKey, parameterContent53113);
  818. UpdateTeacherListDiagnosis.bizcode = "UpdateTeacherListDiagnosis";
  819. UpdateTeacherListDiagnosis.title = "5.3.1.13学员能力点测评结果批量回写";
  820. UploadKTSLList = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, "UploadKTSLList", config.passKey, config.privateKey, parameterContent53117);
  821. UploadKTSLList.bizcode = "UploadKTSLList";
  822. UploadKTSLList.title = "5.3.1.17学员课堂实录批量回写";
  823. UploadSBTARPDFListV2 = await ThirdApisService.Post(_httpClient.CreateClient(),config.url, "UploadSBTARPDFListV2", config.passKey, config.privateKey, parameterContent53122);
  824. UploadSBTARPDFListV2.bizcode = "UploadSBTARPDFListV2";
  825. UploadSBTARPDFListV2.title = "5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写";
  826. results.Add(UpdateTeacherListSituation);
  827. results.Add(UpdateTeacherListDiagnosis);
  828. results.Add(UploadKTSLList);
  829. results.Add(UploadSBTARPDFListV2);
  830. }
  831. await response.WriteAsJsonAsync(new { data= new { results, pushDatas } });
  832. return response;
  833. }
  834. //5.3.1.22学员校本教研PDF(每人可以返回多条)批量回写-UploadSBTARPDFListV2
  835. public (int t53122OK, List<CodeValue> msgs) check53122(TeacherTrain teacherTrain, List<CodeValue> msgs) {
  836. int t53122OK = 1;
  837. if (teacherTrain.offlineRecords.Count<= 0)
  838. {
  839. msgs.Add(new CodeValue("offlineRecord-count", $"文件个数为0"));
  840. }
  841. var hasUrl= teacherTrain.offlineRecords.Where(x => !string.IsNullOrWhiteSpace(x.url) && x.size > 0);
  842. if (!hasUrl.Any()) {
  843. msgs.Add(new CodeValue("offlineRecord-url", $"需要上传的校本研修作业至少有一个。"));
  844. }
  845. //不需要检查每一个校本研修的文件记录。
  846. //teacherTrain.offlineRecords.ForEach(x => {
  847. // if (string.IsNullOrEmpty(x.url)) {
  848. // msgs.Add(new CodeValue("offlineRecord-url", $"链接为空"));
  849. // }
  850. // if (x.size<=0)
  851. // {
  852. // msgs.Add(new CodeValue("offlineRecord-size", $"文件大小"));
  853. // }
  854. //});
  855. return (t53122OK, msgs);
  856. }
  857. //5.3.1.17学员课堂实录批量回写-UploadKTSLList
  858. public (int t53117OK, List<CodeValue> msgs) check53117(TeacherTrain teacherTrain, List<CodeValue> msgs) {
  859. //校验 基本情况是否满足
  860. int t53117OK = 1;
  861. if (teacherTrain.classTime <= 0)
  862. {
  863. msgs.Add(new CodeValue("classTime", $"未获得学时:{teacherTrain.classTime}"));
  864. t53117OK = 0;
  865. }
  866. if (teacherTrain.teacherClasses.Count() <= 0) {
  867. msgs.Add(new CodeValue("teacherClasses", $"未上传课堂实录:{teacherTrain.teacherClasses.Count()}个视频"));
  868. t53117OK = 0;
  869. }
  870. teacherTrain.teacherClasses.ForEach(x =>{
  871. if (string.IsNullOrWhiteSpace(x.url)) {
  872. t53117OK = 0;
  873. msgs.Add(new CodeValue("teacherClasses", $"课堂实录链接无效"));
  874. }
  875. });
  876. return (t53117OK, msgs);
  877. }
  878. //5.3.1.12学员培训基本情况批量回写-UpdateTeacherListSituation
  879. public (int t53112OK, List<CodeValue> msgs) check53112(TeacherTrain teacherTrain, List<CodeValue> msgs)
  880. {
  881. //校验 基本情况是否满足
  882. int t53112OK = 1;
  883. if (teacherTrain.finalScore < 0)
  884. {
  885. //总体认定结果0、未认定 1、合格 2、优秀 3、不合格 4、其他
  886. msgs.Add(new CodeValue("finalScore", $"最终评定结果参数:{teacherTrain.finalScore}"));
  887. t53112OK = 0;
  888. }
  889. //if (string.IsNullOrEmpty(teacherTrain.summary) || teacherTrain.summary.Length > 300)
  890. //{
  891. // string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
  892. // msgs.Add(new CodeValue("summary", $"教师培训总结:{msg}"));
  893. // t53112OK = 0;
  894. //}
  895. if (!string.IsNullOrEmpty(teacherTrain.summary) && teacherTrain.summary.Length > 300)
  896. {
  897. //string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
  898. msgs.Add(new CodeValue("summary", $"教师培训总结:字数超过300."));
  899. t53112OK = 0;
  900. }
  901. if (teacherTrain.totalTime <= 0)
  902. {
  903. msgs.Add(new CodeValue("totalTime", $"未获得学时:{teacherTrain.totalTime}"));
  904. t53112OK = 0;
  905. }
  906. return (t53112OK, msgs);
  907. }
  908. //5.3.1.13学员能力点测评结果批量回写-UpdateTeacherListDiagnosis
  909. public async Task<(int t53113OK, List<CodeValue> msgs, List<AbilitySub> abilitySubs)> check53113(TeacherTrain teacherTrain, ScTeacherDiagnosis diagnosis, List<CodeValue> msgs)
  910. {
  911. //校验 基本情况是否满足
  912. int t53113OK = 1;
  913. List<AbilitySub> abilitySubs = new List<AbilitySub>();
  914. if (teacherTrain.currency.videoTime < 0)
  915. {
  916. msgs.Add(new CodeValue("videoTime", $"视频学习时长:{teacherTrain.currency.videoTime}"));
  917. t53113OK = 0;
  918. }
  919. if (teacherTrain.currency.submitTime < 0)
  920. {
  921. msgs.Add(new CodeValue("submitTime", $"认证材料学习:{teacherTrain.currency.submitTime}"));
  922. t53113OK = 0;
  923. }
  924. if (teacherTrain.currency.teacherAilities.Count <= 0 )
  925. {
  926. msgs.Add(new CodeValue("teacherAilities", $"已学习能力点:0"));
  927. t53113OK = 0;
  928. }
  929. if (diagnosis != null)
  930. {
  931. if (!string.IsNullOrWhiteSpace(diagnosis.abilityNos))
  932. {
  933. List<string> nos = diagnosis.abilityNos.ToObject<List<string>>();
  934. if (nos.Count > 0 && teacherTrain.currency.teacherAilities.Count > 0)
  935. {
  936. var notin = nos.Except(teacherTrain.currency.teacherAilities.Select(x => x.no).Where(z=>!string.IsNullOrWhiteSpace(z)));
  937. if (notin.Any())
  938. {
  939. msgs.Add(new CodeValue("diagnosisNos", $"省平台勾选的能力点编号为学习完成:省平台:{string.Join(",", nos.OrderBy(x => x))}" + $" ,已学习:{string.Join(",", teacherTrain.currency.teacherAilities.Select(x => x.no).OrderBy(x=>x))} "));
  940. t53113OK = 0;
  941. }
  942. else {
  943. string insql = "";
  944. if (teacherTrain.currency.teacherAilities.IsNotEmpty())
  945. {
  946. var abilites= teacherTrain.currency.teacherAilities.Where(c => !string.IsNullOrWhiteSpace(c.no) && nos.Contains(c.no));
  947. insql = $" where c.id in ({string.Join(",", abilites.Select(o => $"'{o.id}'"))})";
  948. }
  949. //认证材料
  950. await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer("TEAMModelOS", "Teacher")
  951. .GetItemQueryIterator<AbilitySub>(queryText: $"select value(c) from c {insql}", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"AbilitySub-{teacherTrain.school}-{teacherTrain.id}") }))
  952. {
  953. abilitySubs.Add(item);
  954. }
  955. teacherTrain.currency.teacherAilities.ForEach(x => {
  956. var abilitySub = abilitySubs.Find(z => z.id.Equals(x.id));
  957. if (abilitySub == null || !abilitySub.uploads.Any())
  958. {
  959. t53113OK = 0;
  960. msgs.Add(new CodeValue("uploads", $"未上传认证材料:{x.no},{x.name}"));
  961. }
  962. if (x.zpscore <= 0)
  963. {
  964. t53113OK = 0;
  965. msgs.Add(new CodeValue("zpscore", $"认证材料,没有完成自评:{x.no},{x.name},{x.zpscore}"));
  966. }
  967. if (x.hpscore <= 0)
  968. {
  969. t53113OK = 0;
  970. msgs.Add(new CodeValue("hpscore", $"认证材料,没有完成互评:{x.no},{x.name},{x.hpscore}"));
  971. }
  972. if (x.xzscore <= 0)
  973. {
  974. t53113OK = 0;
  975. msgs.Add(new CodeValue("xzscore", $"认证材料,没有完成小组评:{x.no},{x.name},{x.xzscore}"));
  976. }
  977. });
  978. if (t53113OK != 1) {
  979. msgs.Add(new CodeValue("diagnosisNos", $"省平台勾选的能力点编号为学习完成:省平台:{string.Join(",", nos.OrderBy(x=>x))}" + $" ,已学习:{string.Join(",", teacherTrain.currency.teacherAilities.Select(x => x.no).OrderBy(x => x))} "));
  980. }
  981. }
  982. }
  983. else {
  984. msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
  985. t53113OK = 0;
  986. }
  987. }
  988. else {
  989. msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
  990. t53113OK = 0;
  991. }
  992. }
  993. else {
  994. msgs.Add(new CodeValue("teacherAilities", $"未同步省平台挑选的能力点"));
  995. t53113OK = 0;
  996. }
  997. return (t53113OK, msgs, abilitySubs);
  998. }
  999. }
  1000. }