|
@@ -37,6 +37,8 @@ using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
using DocumentFormat.OpenXml.Bibliography;
|
|
|
using HTEXLib;
|
|
|
using TEAMModelOS.SDK.Models.Service.BI;
|
|
|
+using TEAMModelOS.SDK.Models.Cosmos.BI.BISchool;
|
|
|
+using DocumentFormat.OpenXml.Vml.Office;
|
|
|
|
|
|
namespace TEAMModelBI.Controllers.BISchool
|
|
|
{
|
|
@@ -1035,6 +1037,11 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
jsonElement.TryGetProperty("dist", out JsonElement dist);
|
|
|
jsonElement.TryGetProperty("address", out JsonElement address);
|
|
|
|
|
|
+
|
|
|
+ jsonElement.TryGetProperty("assist", out JsonElement assist);
|
|
|
+ List<IdInfo> idInfos = assist.ToObject<List<IdInfo>>();
|
|
|
+
|
|
|
+
|
|
|
//jsonElement.TryGetProperty("site", out JsonElement site);//分开部署,就不需要,一站多用时,取消注释
|
|
|
|
|
|
var (_tmdId, _tmdName, pic, did, dname, dpic) = HttpJwtAnalysis.JwtXAuthBI(HttpContext.GetXAuth("AuthToken"), _option);
|
|
@@ -1079,6 +1086,9 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
//修改学校
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<School>(tempShool, tempShool.id, new PartitionKey("Base"));
|
|
|
|
|
|
+ //创建学校信息中间件
|
|
|
+ _ = _httpTrigger.RequestHttpTrigger(new { school = $"{tempShool}" }, _option.Location, "set-sc-birelation");
|
|
|
+
|
|
|
//修改学校教师关联的信息
|
|
|
string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{tempShool.id}'";
|
|
|
List<Teacher> teachers = new();
|
|
@@ -1098,110 +1108,156 @@ namespace TEAMModelBI.Controllers.BISchool
|
|
|
await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync(item, item.id, new PartitionKey($"Base"));
|
|
|
}
|
|
|
|
|
|
- if (assistId.Count > 0)
|
|
|
+ ////需要重大修改后保留
|
|
|
+ if (idInfos.Count > 0)
|
|
|
{
|
|
|
- //修改学校顾问
|
|
|
- string sqlTxt = $"SELECT value(c) From c WHERE ARRAY_CONTAINS(c.roles,'assist',true)";
|
|
|
- List<SchoolTeacher> schoolTeachers = new();
|
|
|
- await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempShool.id}") }))
|
|
|
+ BIRelation biRel = new();
|
|
|
+ var respRel = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync(tempShool.id,new PartitionKey("BIRel"));
|
|
|
+ if (respRel.Status == 200)
|
|
|
{
|
|
|
- if (!assistId.Contains(item.id))
|
|
|
- {
|
|
|
- if (item.roles.Contains("assist"))
|
|
|
- {
|
|
|
- item.roles.Remove("assist");
|
|
|
- if (item.roles.Count > 0)
|
|
|
- {
|
|
|
- await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(item, item.id, new PartitionKey(item.code));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>(item.id, new PartitionKey(item.code));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ using var fileJson = await JsonDocument.ParseAsync(respRel.ContentStream);
|
|
|
+ biRel = fileJson.ToObject<BIRelation>();
|
|
|
}
|
|
|
-
|
|
|
- foreach (var itemTeacher in assistId)
|
|
|
+ else
|
|
|
+ biRel.id = tempShool.id;
|
|
|
+
|
|
|
+ string aName = null;
|
|
|
+ if (!string.IsNullOrEmpty($"{tempShool.areaId}"))
|
|
|
+ aName = await CosmosQueryHelper.GetStr(cosmosClient, "Normal", $"select value(c.name) from c where c.id='{tempShool.areaId}'", "Base-Area");
|
|
|
+
|
|
|
+ biRel.name = tempShool.name;
|
|
|
+ biRel.picture = tempShool.picture;
|
|
|
+ biRel.region = tempShool.region;
|
|
|
+ biRel.province = tempShool.province;
|
|
|
+ biRel.city = tempShool.city;
|
|
|
+ biRel.dist = tempShool.dist;
|
|
|
+ biRel.address = tempShool.address;
|
|
|
+ biRel.areaId = tempShool.areaId;
|
|
|
+ biRel.size = tempShool.size;
|
|
|
+ biRel.scale = tempShool.scale;
|
|
|
+ biRel.upDate = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
|
+ biRel.areaName = aName;
|
|
|
+ foreach (var item in idInfos)
|
|
|
{
|
|
|
- Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{itemTeacher}", new PartitionKey("Base"));
|
|
|
- if (tempTeacher != null)
|
|
|
+ var ser = biRel.assists.Find(f => f.Equals(item.id));
|
|
|
+ if (string.IsNullOrEmpty(ser.id))
|
|
|
{
|
|
|
- var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{_schoolId}"));
|
|
|
- if (haveTeacher == null)
|
|
|
- {
|
|
|
- Teacher.TeacherSchool teacherSchool = new()
|
|
|
- {
|
|
|
- schoolId = tempShool.id,
|
|
|
- name = tempShool.name,
|
|
|
- status = "join",
|
|
|
- time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
- picture = tempShool.picture,
|
|
|
- areaId = tempShool.areaId
|
|
|
- };
|
|
|
- tempTeacher.schools.Add(teacherSchool);
|
|
|
- //给醍摩豆顾问添加学校
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, tempTeacher.id, new PartitionKey($"Base"));
|
|
|
-
|
|
|
- ////不存在则在原来的基础上添加顾问角色
|
|
|
- //SchoolTeacher addSchoolTeacher = new()
|
|
|
- //{
|
|
|
- // id = itemTeacher,
|
|
|
- // code = $"Teacher-{tempShool.id}",
|
|
|
- // pk = "Teacher",
|
|
|
- // status = "join",
|
|
|
- // roles = new List<string>() { "assist" },
|
|
|
- // name = tempTeacher.name,
|
|
|
- // job = $"{tempShool.name}-顾问",
|
|
|
- // size = 0,
|
|
|
- // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
- //};
|
|
|
-
|
|
|
- //var resScTch = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
- //if(resScTch.)
|
|
|
-
|
|
|
- ////添加学校学校顾问
|
|
|
- //await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
- }
|
|
|
-
|
|
|
- //查询该教师是否存在该校
|
|
|
- SchoolTeacher schoolTeacher = null;
|
|
|
- var resScTch = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
- if (resScTch.Status == 200)
|
|
|
- {
|
|
|
- using var tchJson = await JsonDocument.ParseAsync(resScTch.ContentStream);
|
|
|
- schoolTeacher = tchJson.ToObject<SchoolTeacher>();
|
|
|
- }
|
|
|
-
|
|
|
- if (schoolTeacher != null)
|
|
|
- {
|
|
|
- if (!schoolTeacher.roles.Contains("assist"))
|
|
|
- {
|
|
|
- schoolTeacher.roles.Add("assist");
|
|
|
- //添加顾问权限
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SchoolTeacher addSchoolTeacher = new()
|
|
|
- {
|
|
|
- id = itemTeacher,
|
|
|
- code = $"Teacher-{tempShool.id}",
|
|
|
- pk = "Teacher",
|
|
|
- status = "join",
|
|
|
- roles = new List<string>() { "assist" },
|
|
|
- name = tempTeacher.name,
|
|
|
- job = $"{tempShool.name}-顾问",
|
|
|
- size = 0,
|
|
|
- createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
- };
|
|
|
- //添加学校顾问
|
|
|
- await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
- }
|
|
|
+ biRel.assists.Add(item);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (respRel.Status == 200)
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<BIRelation>(biRel, biRel.id, new PartitionKey("BIRel"));
|
|
|
+ else
|
|
|
+ await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<BIRelation>(biRel, new PartitionKey("BIRel"));
|
|
|
}
|
|
|
+
|
|
|
+ ////需要重大修改后移除
|
|
|
+ //if (assistId.Count > 0)
|
|
|
+ //{
|
|
|
+ // //修改学校顾问
|
|
|
+ // string sqlTxt = $"SELECT value(c) From c WHERE ARRAY_CONTAINS(c.roles,'assist',true)";
|
|
|
+ // List<SchoolTeacher> schoolTeachers = new();
|
|
|
+ // await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<SchoolTeacher>(queryText: sqlTxt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{tempShool.id}") }))
|
|
|
+ // {
|
|
|
+ // if (!assistId.Contains(item.id))
|
|
|
+ // {
|
|
|
+ // if (item.roles.Contains("assist"))
|
|
|
+ // {
|
|
|
+ // item.roles.Remove("assist");
|
|
|
+ // if (item.roles.Count > 0)
|
|
|
+ // {
|
|
|
+ // await cosmosClient.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<SchoolTeacher>(item, item.id, new PartitionKey(item.code));
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // await cosmosClient.GetContainer("TEAMModelOS", "School").DeleteItemAsync<SchoolTeacher>(item.id, new PartitionKey(item.code));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ // foreach (var itemTeacher in assistId)
|
|
|
+ // {
|
|
|
+ // Teacher tempTeacher = await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReadItemAsync<Teacher>($"{itemTeacher}", new PartitionKey("Base"));
|
|
|
+ // if (tempTeacher != null)
|
|
|
+ // {
|
|
|
+ // var haveTeacher = tempTeacher.schools.Find(x => x.schoolId.Equals($"{_schoolId}"));
|
|
|
+ // if (haveTeacher == null)
|
|
|
+ // {
|
|
|
+ // Teacher.TeacherSchool teacherSchool = new()
|
|
|
+ // {
|
|
|
+ // schoolId = tempShool.id,
|
|
|
+ // name = tempShool.name,
|
|
|
+ // status = "join",
|
|
|
+ // time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
|
|
+ // picture = tempShool.picture,
|
|
|
+ // areaId = tempShool.areaId
|
|
|
+ // };
|
|
|
+ // tempTeacher.schools.Add(teacherSchool);
|
|
|
+ // //给醍摩豆顾问添加学校
|
|
|
+ // await cosmosClient.GetContainer(Constant.TEAMModelOS, "Teacher").ReplaceItemAsync<Teacher>(tempTeacher, tempTeacher.id, new PartitionKey($"Base"));
|
|
|
+
|
|
|
+ // ////不存在则在原来的基础上添加顾问角色
|
|
|
+ // //SchoolTeacher addSchoolTeacher = new()
|
|
|
+ // //{
|
|
|
+ // // id = itemTeacher,
|
|
|
+ // // code = $"Teacher-{tempShool.id}",
|
|
|
+ // // pk = "Teacher",
|
|
|
+ // // status = "join",
|
|
|
+ // // roles = new List<string>() { "assist" },
|
|
|
+ // // name = tempTeacher.name,
|
|
|
+ // // job = $"{tempShool.name}-顾问",
|
|
|
+ // // size = 0,
|
|
|
+ // // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
+ // //};
|
|
|
+
|
|
|
+ // //var resScTch = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
+ // //if(resScTch.)
|
|
|
+
|
|
|
+ // ////添加学校学校顾问
|
|
|
+ // //await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
+ // }
|
|
|
+
|
|
|
+ // //查询该教师是否存在该校
|
|
|
+ // SchoolTeacher schoolTeacher = null;
|
|
|
+ // var resScTch = await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{itemTeacher}", new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
+ // if (resScTch.Status == 200)
|
|
|
+ // {
|
|
|
+ // using var tchJson = await JsonDocument.ParseAsync(resScTch.ContentStream);
|
|
|
+ // schoolTeacher = tchJson.ToObject<SchoolTeacher>();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (schoolTeacher != null)
|
|
|
+ // {
|
|
|
+ // if (!schoolTeacher.roles.Contains("assist"))
|
|
|
+ // {
|
|
|
+ // schoolTeacher.roles.Add("assist");
|
|
|
+ // //添加顾问权限
|
|
|
+ // await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").ReplaceItemAsync<SchoolTeacher>(schoolTeacher, schoolTeacher.id, new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // SchoolTeacher addSchoolTeacher = new()
|
|
|
+ // {
|
|
|
+ // id = itemTeacher,
|
|
|
+ // code = $"Teacher-{tempShool.id}",
|
|
|
+ // pk = "Teacher",
|
|
|
+ // status = "join",
|
|
|
+ // roles = new List<string>() { "assist" },
|
|
|
+ // name = tempTeacher.name,
|
|
|
+ // job = $"{tempShool.name}-顾问",
|
|
|
+ // size = 0,
|
|
|
+ // createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
|
|
|
+ // };
|
|
|
+ // //添加学校顾问
|
|
|
+ // await cosmosClient.GetContainer(Constant.TEAMModelOS, "School").CreateItemAsync<SchoolTeacher>(addSchoolTeacher, new PartitionKey($"Teacher-{tempShool.id}"));
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//保存操作记录
|