|
@@ -50,7 +50,8 @@ namespace TEAMModelOS.Controllers
|
|
|
private readonly CoreAPIHttpService _coreAPIHttpService;
|
|
|
private readonly NotificationService _notificationService;
|
|
|
private readonly HttpClient _httpClient;
|
|
|
- public SchoolController(CoreAPIHttpService coreAPIHttpService, NotificationService notificationService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, HttpClient httpClient)
|
|
|
+ private readonly HttpTrigger _httpTrigger;
|
|
|
+ public SchoolController(HttpTrigger httpTrigger,CoreAPIHttpService coreAPIHttpService, NotificationService notificationService, AzureCosmosFactory azureCosmos, AzureStorageFactory azureStorage, AzureRedisFactory azureRedis, DingDing dingDing, IOptionsSnapshot<Option> option, IConfiguration configuration, HttpClient httpClient)
|
|
|
{
|
|
|
_azureCosmos = azureCosmos;
|
|
|
_azureStorage = azureStorage;
|
|
@@ -61,6 +62,7 @@ namespace TEAMModelOS.Controllers
|
|
|
_coreAPIHttpService = coreAPIHttpService;
|
|
|
_notificationService = notificationService;
|
|
|
_httpClient = httpClient;
|
|
|
+ _httpTrigger = httpTrigger;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 修改学校信息
|
|
@@ -139,6 +141,25 @@ namespace TEAMModelOS.Controllers
|
|
|
var response = await schoolContainer.ReadItemStreamAsync(school.id, new PartitionKey($"Base"));
|
|
|
if (response.Status == 200)
|
|
|
{
|
|
|
+ School db_school = JsonDocument.Parse(response.Content).RootElement.Deserialize<School>();
|
|
|
+ //计算 比较更改前后 学段的年级变化的学段,并重新处理行政班的毕业状态。
|
|
|
+ //变更后
|
|
|
+ List<KeyValuePair<string, int>> period_gradeCount = new List<KeyValuePair<string, int>>();
|
|
|
+ school.period.ForEach(z => { period_gradeCount.Add(new KeyValuePair<string, int>(z.id, z.grades.Count)); });
|
|
|
+ //变更前
|
|
|
+ List<KeyValuePair<string, int>> dbperiod_gradeCount = new List<KeyValuePair<string, int>>();
|
|
|
+ db_school.period.ForEach(z => { dbperiod_gradeCount.Add(new KeyValuePair<string, int>(z.id, z.grades.Count)); });
|
|
|
+ List<string> periodIds = new List<string>();
|
|
|
+ period_gradeCount.ForEach(x => {
|
|
|
+ var gradeCount = dbperiod_gradeCount.Find(y => x.Key.Equals(y.Key));
|
|
|
+ if (!string.IsNullOrWhiteSpace(gradeCount.Key)) {
|
|
|
+ if (gradeCount.Value != x.Value) {
|
|
|
+ periodIds.Add(x.Key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ await SchoolService.DoGraduateClasses(_httpTrigger, _azureCosmos, periodIds, school, _option);
|
|
|
+ //变更教师关联的学校基本信息
|
|
|
string sql = $"SELECT distinct value(c) FROM c join A1 in c.schools where A1.schoolId='{school.id}'";
|
|
|
List<Teacher> teachers = new List<Teacher>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<Teacher>(sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|