|
@@ -37,6 +37,7 @@ using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using DocumentFormat.OpenXml.Bibliography;
|
|
|
using HTEXLib;
|
|
|
using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
+using static TEAMModelBI.Controllers.BISchool.BatchSchoolController;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
@@ -1223,6 +1224,104 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
return Ok(new { state = RespondCode.Ok , createScInfo });
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 批量创校前检查数据
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [ProducesDefaultResponseType]
|
|
|
+ [HttpPost("get-checkexists")]
|
|
|
+ public async Task<IActionResult> GetCheckExists(JsonElement jsonElement)
|
|
|
+ {
|
|
|
+ if (!jsonElement.TryGetProperty("checkScs", out JsonElement checkScs)) return BadRequest();
|
|
|
+ List<BISchool> bISchools = checkScs.ToObject<List<BISchool>>();
|
|
|
+
|
|
|
+ var cosmosClient = _azureCosmos.GetCosmosClient();
|
|
|
+ List<BISchool> existScNames = new(); //存在的学校
|
|
|
+ List<BISchool> noAccounts = new(); // 不存在的账户
|
|
|
+ List<BISchool> noAreaIds = new(); //不存在的学区
|
|
|
+ List<BISchool> synPro = new(); //已同步省平台
|
|
|
+ List<BISchool> createScInfo = new(); //学校简码信息
|
|
|
+
|
|
|
+ foreach (BISchool bISchool in bISchools)
|
|
|
+ {
|
|
|
+ //查询学校名称是否全字段匹配
|
|
|
+ await foreach (var sc in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<string>(queryText: $"select value(c.name) from c where c.name='{bISchool.name}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
+ existScNames.Add(bISchool);
|
|
|
+ }
|
|
|
+
|
|
|
+ var content = new StringContent(bISchool.admin.ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
+ List<TmdUserinfo> tmdInfos = json.ToObject<List<TmdUserinfo>>();
|
|
|
+
|
|
|
+ bISchool.admin.ForEach(ac =>
|
|
|
+ {
|
|
|
+ TmdUserinfo noTmdInfo = null;
|
|
|
+ tmdInfos.ForEach(tmd =>
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(tmd.id))
|
|
|
+ if (tmd.id.Equals($"{ac}"))
|
|
|
+ noTmdInfo = tmd;
|
|
|
+ if (!string.IsNullOrEmpty(tmd.mobile))
|
|
|
+ if (tmd.mobile.Equals($"{ac}"))
|
|
|
+ noTmdInfo = tmd;
|
|
|
+ if (!string.IsNullOrEmpty(tmd.mail))
|
|
|
+ if (tmd.mail.Equals($"{ac}"))
|
|
|
+ noTmdInfo = tmd;
|
|
|
+ });
|
|
|
+ //noTmdInfo = tmdInfos.Find(f => f.id.Equals($"{ac}") || f.mail.Equals($"{ac}") || f.mobile.Equals($"{ac}"));
|
|
|
+ if (noTmdInfo == null)
|
|
|
+ noAccounts.Add(bISchool);
|
|
|
+ });
|
|
|
+
|
|
|
+ //查询区是否存在
|
|
|
+ var respAreaId = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bISchool.areaId}", new PartitionKey("Base-Area"));
|
|
|
+ if (respAreaId.Status != 200)
|
|
|
+ {
|
|
|
+ noAreaIds.Add(bISchool);
|
|
|
+ }
|
|
|
+
|
|
|
+ //查询去是否同步省平台
|
|
|
+ var responseSet = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Normal").ReadItemStreamAsync($"{bISchool.areaId}", new PartitionKey("AreaSetting"));
|
|
|
+ if (responseSet.Status == 200)
|
|
|
+ {
|
|
|
+ using var fileJson = await JsonDocument.ParseAsync(responseSet.ContentStream);
|
|
|
+ AreaSetting delSet = fileJson.ToObject<AreaSetting>();
|
|
|
+ if (!string.IsNullOrEmpty(delSet.accessConfig))
|
|
|
+ synPro.Add(bISchool);
|
|
|
+ }
|
|
|
+
|
|
|
+ CreateSchoolInfo createSchoolInfo = new CreateSchoolInfo()
|
|
|
+ {
|
|
|
+ province = bISchool.province,
|
|
|
+ id = "",
|
|
|
+ name = bISchool.name,
|
|
|
+ city = bISchool.city,
|
|
|
+ aname = "",
|
|
|
+ createCount = 0,
|
|
|
+ };
|
|
|
+
|
|
|
+ //生成学校ID
|
|
|
+ bool tempStaus = true;
|
|
|
+ do
|
|
|
+ {
|
|
|
+ createSchoolInfo = await SchoolCode.GenerateSchoolCode(createSchoolInfo, _dingDing, _environment);
|
|
|
+ var schoolStatu = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{createSchoolInfo.id}", new PartitionKey($"Base"));
|
|
|
+ if (schoolStatu.Status != 200) tempStaus = false;
|
|
|
+ else createSchoolInfo.createCount = createSchoolInfo.createCount >= 3 ? createSchoolInfo.createCount = 3 : createSchoolInfo.createCount += 1;
|
|
|
+ } while (tempStaus);
|
|
|
+ bISchool.id = createSchoolInfo.id;
|
|
|
+ createScInfo.Add(bISchool);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (existScNames.Count > 0 || noAccounts.Count > 0 || noAreaIds.Count > 0 || synPro.Count > 0)
|
|
|
+ return Ok(new { state = RespondCode.Created, existScNames, noAccounts, noAreaIds, synPro, createScInfo });
|
|
|
+ else
|
|
|
+ return Ok(new { state = RespondCode.Ok, createScInfo });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 添加多个学校添加多个管理员
|
|
|
/// </summary>
|
|
@@ -1610,6 +1709,7 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
/// </summary>
|
|
|
public record BISchool()
|
|
|
{
|
|
|
+ public string id { get; set; }
|
|
|
/// <summary>
|
|
|
/// 学校名称
|
|
|
/// </summary>
|