|
@@ -1,12 +1,261 @@
|
|
|
-using System;
|
|
|
+using HTEXLib.COMM.Helpers;
|
|
|
+using Microsoft.Azure.Functions.Worker;
|
|
|
+using Microsoft.Azure.Functions.Worker.Http;
|
|
|
+using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO;
|
|
|
using System.Linq;
|
|
|
+using System.Net;
|
|
|
using System.Text;
|
|
|
+using System.Text.Json;
|
|
|
using System.Threading.Tasks;
|
|
|
+using TEAMModelOS.SDK;
|
|
|
+using TEAMModelOS.SDK.DI;
|
|
|
+using TEAMModelOS.SDK.Extension;
|
|
|
+using TEAMModelOS.SDK.Models;
|
|
|
|
|
|
namespace TEAMModelOS.FunctionV4.HttpTrigger
|
|
|
{
|
|
|
- internal class ScsYxptApis
|
|
|
+ public class ScsYxptApis
|
|
|
{
|
|
|
+ private readonly AzureCosmosFactory _azureCosmos;
|
|
|
+ private readonly DingDing _dingDing;
|
|
|
+ private readonly AzureStorageFactory _azureStorage;
|
|
|
+ private readonly AzureRedisFactory _azureRedis;
|
|
|
+ private readonly ThirdApisService _thirdApisService;
|
|
|
+ public static string Code { get; set; }
|
|
|
+ public static Dictionary<string, object> parameterMap = null;
|
|
|
+ public ScsYxptApis(AzureCosmosFactory azureCosmos, DingDing dingDing, AzureStorageFactory azureStorage, ThirdApisService thirdApisService
|
|
|
+ , AzureRedisFactory azureRedis)
|
|
|
+ {
|
|
|
+ _azureCosmos = azureCosmos;
|
|
|
+ _dingDing = dingDing;
|
|
|
+ _azureStorage = azureStorage;
|
|
|
+ _azureRedis = azureRedis;
|
|
|
+ _thirdApisService = thirdApisService;
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 5.3.1.19获取项目设置的可选能力点
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="req"></param>
|
|
|
+ /// <param name="log"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Function("GetProjectDiagnosis")]
|
|
|
+ public async Task<HttpResponseData> GetProjectDiagnosis([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
|
|
|
+ {
|
|
|
+ var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
+ List<ScsProjectDiagnosis> projects = new List<ScsProjectDiagnosis>();
|
|
|
+ string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
+ JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
|
|
|
+ ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
|
|
|
+ Code = "GetProjectDiagnosis";
|
|
|
+ parameterMap = new Dictionary<string, object>();
|
|
|
+ parameterMap.Add("TrainComID", config.trainComID);
|
|
|
+ List<ScsResult> results = new List<ScsResult>();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ if (config.p.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var ps in config.p)
|
|
|
+ {
|
|
|
+ parameterMap["ProjectID"] = ps.pd;
|
|
|
+ parameterMap["ProjectItemID"] = ps.pid;
|
|
|
+ ScsResult result = new ScsResult { code = Code, title = "5.3.1.19获取项目设置的可选能力点" };
|
|
|
+ result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
|
|
|
+ if (result.result)
|
|
|
+ {
|
|
|
+ List<ScPDiagnosis> diagnoses = result.content.ToObject<List<ScPDiagnosis>>();
|
|
|
+ if (diagnoses.IsNotEmpty())
|
|
|
+ {
|
|
|
+ projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = diagnoses });
|
|
|
+ await _azureStorage.SaveOrUpdate<ScProjectDiagnosis>(new ScProjectDiagnosis { RowKey = $"{ps.pid}", PartitionKey = "ScProjectDiagnosis", abilityNos = diagnoses.ToJsonString() });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ List<ScProjectDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScProjectDiagnosis" }, { "RowKey", $"{ps.pid}" } });
|
|
|
+ if (teacherDiagnoses.IsNotEmpty())
|
|
|
+ {
|
|
|
+ projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ results.Add(result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ if (config.p.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (var ps in config.p)
|
|
|
+ {
|
|
|
+ //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetProjectDiagnosis\n{ex.Message}{ex.StackTrace}\n{results.ToJsonString()}\n{data}", GroupNames.成都开发測試群組);
|
|
|
+ List<ScProjectDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScProjectDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScProjectDiagnosis" }, { "RowKey", $"{ps.pid}" } });
|
|
|
+ if (teacherDiagnoses.IsNotEmpty())
|
|
|
+ {
|
|
|
+ projects.Add(new ScsProjectDiagnosis { project = ps, diagnoses = teacherDiagnoses[0].abilityNos.ToObject<List<ScPDiagnosis>>() });
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await response.WriteAsJsonAsync(new { data = projects.ToJsonString() });
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 5.3.1.3通过项目编号获取学员测评能力项V2
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="req"></param>
|
|
|
+ /// <param name="log"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Function("GetDiagnosisListByProject_V2")]
|
|
|
+ public async Task<HttpResponseData> GetDiagnosisListByProject_V2([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
|
|
|
+ {
|
|
|
+ var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
+ List<string> abilityNos = new List<string>();
|
|
|
+ string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
+ JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
|
|
|
+ JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
|
|
|
+ ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
|
|
|
+ Code = "GetDiagnosisListByProject_V2";
|
|
|
+ parameterMap = new Dictionary<string, object>();
|
|
|
+ parameterMap.Add("TrainComID", config.trainComID);
|
|
|
+ parameterMap.Add("PXID", pxid);
|
|
|
+ ScsResult result = new ScsResult { code = Code, title = "5.3.1.3通过项目编号获取学员测评能力项V2" };
|
|
|
+ try
|
|
|
+ {
|
|
|
+ result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
|
|
|
+ if (result.result)
|
|
|
+ {
|
|
|
+ List<ScDiagnosis> diagnoses = result.content.ToObject<List<ScDiagnosis>>();
|
|
|
+ if (diagnoses != null)
|
|
|
+ {
|
|
|
+ abilityNos = diagnoses.Select(x => x.DiagnosisDicNum).ToList();
|
|
|
+ }
|
|
|
+ if (abilityNos.IsNotEmpty())
|
|
|
+ {
|
|
|
+ await _azureStorage.SaveOrUpdate<ScTeacherDiagnosis>(new ScTeacherDiagnosis { RowKey = $"{pxid}", PartitionKey = "ScTeacherDiagnosis", abilityNos = abilityNos.ToJsonString() });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ List<ScTeacherDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "RowKey", $"{pxid}" } });
|
|
|
+ if (teacherDiagnoses.IsNotEmpty())
|
|
|
+ {
|
|
|
+ abilityNos = teacherDiagnoses[0].abilityNos.ToObject<List<string>>();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ await response.WriteAsJsonAsync(new { data = abilityNos.ToJsonString() });
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:getDiagnosisListByProject_V2\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}\n{data}", GroupNames.成都开发測試群組);
|
|
|
+
|
|
|
+ List<ScTeacherDiagnosis> teacherDiagnoses = await _azureStorage.FindListByDict<ScTeacherDiagnosis>(new Dictionary<string, object> { { "PartitionKey", "ScTeacherDiagnosis" }, { "RowKey", $"{pxid}" } });
|
|
|
+ if (teacherDiagnoses.IsNotEmpty())
|
|
|
+ {
|
|
|
+ abilityNos = teacherDiagnoses[0].abilityNos.ToObject<List<string>>();
|
|
|
+ }
|
|
|
+ await response.WriteAsJsonAsync(new { data = abilityNos.ToJsonString() });
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 5.3.1.11获取跳转学员信息,用于sso单点,后端验证。
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="req"></param>
|
|
|
+ /// <param name="log"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [Function("GetSingleTeacherByProject")]
|
|
|
+ public async Task<HttpResponseData> GetSingleTeacherByProject([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestData req)
|
|
|
+ {
|
|
|
+ var response = req.CreateResponse(HttpStatusCode.OK);
|
|
|
+ string teacher = null;
|
|
|
+ string data = await new StreamReader(req.Body).ReadToEndAsync();
|
|
|
+ JsonElement accessConfig = data.ToObject<JsonElement>().GetProperty("accessConfig");
|
|
|
+ JsonElement pxid = data.ToObject<JsonElement>().GetProperty("pxid");
|
|
|
+ JsonElement tid = data.ToObject<JsonElement>().GetProperty("tid");
|
|
|
+ ScAccessConfig config = $"{accessConfig}".ToObject<ScAccessConfig>();
|
|
|
+ Code = "GetSingleTeacherByProject";
|
|
|
+ parameterMap = new Dictionary<string, object>();
|
|
|
+ parameterMap.Add("TrainComID", config.trainComID);
|
|
|
+ parameterMap.Add("Pxid", $"{pxid}");
|
|
|
+ parameterMap.Add("Tid", $"{tid}");
|
|
|
+ ScsResult result = new ScsResult { code = Code, title = "5.3.1.11获取跳转学员信息,用于sso单点,后端验证。" };
|
|
|
+ try
|
|
|
+ {
|
|
|
+ ///{“result”:true,”reason”:null,”content”:”{“PXID”:””,”TID”:””,”TeacherName”:””,”ProjectTitle”:””,”ProjectItemTitle”:””,”CityName”:””,
|
|
|
+ ///”DisName”:””,”SchoolName”:””,”Sex”:””,”PXXK”:””,”PXXD”:””,”TeacherXK”:””,”TeacherXD”:””,”Email”:””}”,”pagecount”:1}
|
|
|
+ result = await _thirdApisService.Post(config.url, Code, config.passKey, config.privateKey, parameterMap);
|
|
|
+ if (result.result)
|
|
|
+ {
|
|
|
+ teacher = result.content;
|
|
|
+ }
|
|
|
+ await response.WriteAsJsonAsync(new { data = teacher });
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ //await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")},IES5.ScApisService:GetSingleTeacherByProject\n{ex.Message}{ex.StackTrace}\n{result.ToJsonString()}\n{data}", GroupNames.成都开发測試群組);
|
|
|
+ await response.WriteAsJsonAsync(new { data = teacher });
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public (int t53112OK, List<KeyValuePair<string, string>> msgs) check53112(TeacherTrain teacherTrain, List<KeyValuePair<string, string>> msgs)
|
|
|
+ {
|
|
|
+ //校验 基本情况是否满足
|
|
|
+ int t53112OK = 1;
|
|
|
+ if (teacherTrain.finalScore < 0)
|
|
|
+ {
|
|
|
+ msgs.Add(new KeyValuePair<string, string>("finalScore", $"最终评定结果参数:{teacherTrain.finalScore}"));
|
|
|
+ t53112OK = 0;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(teacherTrain.summary) || teacherTrain.summary.Length > 300)
|
|
|
+ {
|
|
|
+ string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
|
|
|
+ msgs.Add(new KeyValuePair<string, string>("summary", $"教师培训总结:{msg}"));
|
|
|
+ t53112OK = 0;
|
|
|
+ }
|
|
|
+ if (teacherTrain.totalTime <= 0)
|
|
|
+ {
|
|
|
+ msgs.Add(new KeyValuePair<string, string>("totalTime", $"未获得学时:{teacherTrain.totalTime}"));
|
|
|
+ t53112OK = 0;
|
|
|
+ }
|
|
|
+ return (t53112OK, msgs);
|
|
|
+ }
|
|
|
+
|
|
|
+ public (int t53112OK, List<KeyValuePair<string, string>> msgs) check53113(TeacherTrain teacherTrain, List<KeyValuePair<string, string>> msgs)
|
|
|
+ {
|
|
|
+ //校验 基本情况是否满足
|
|
|
+ int t53112OK = 1;
|
|
|
+ if (teacherTrain.finalScore < 0)
|
|
|
+ {
|
|
|
+ msgs.Add(new KeyValuePair<string, string>("finalScore", $"最终评定结果参数:{teacherTrain.finalScore}"));
|
|
|
+ t53112OK = 0;
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(teacherTrain.summary) || teacherTrain.summary.Length > 300)
|
|
|
+ {
|
|
|
+ string msg = string.IsNullOrEmpty(teacherTrain.summary) ? "未填写" : teacherTrain.summary.Length > 300 ? "字数超过300." : "";
|
|
|
+ msgs.Add(new KeyValuePair<string, string>("summary", $"教师培训总结:{msg}"));
|
|
|
+ t53112OK = 0;
|
|
|
+ }
|
|
|
+ if (teacherTrain.totalTime <= 0)
|
|
|
+ {
|
|
|
+ msgs.Add(new KeyValuePair<string, string>("totalTime", $"未获得学时:{teacherTrain.totalTime}"));
|
|
|
+ t53112OK = 0;
|
|
|
+ }
|
|
|
+ return (t53112OK, msgs);
|
|
|
+ }
|
|
|
}
|
|
|
}
|