|
@@ -67,23 +67,43 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
+
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
|
request.TryGetProperty("periodId", out JsonElement periodId);
|
|
|
request.TryGetProperty("schoolCode", out JsonElement schoolCode);
|
|
|
request.TryGetProperty("tmdid", out JsonElement tmdid);
|
|
|
if (!string.IsNullOrEmpty($"{periodId}") && !string.IsNullOrEmpty($"{schoolCode}"))
|
|
|
{
|
|
|
+ School school = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{schoolCode}", new PartitionKey("Base"));
|
|
|
+ var period= school.period.Find(x => x.id.Equals($"{periodId}"));
|
|
|
var value = await _azureRedis.GetRedisClient(8).HashGetAsync($"ItemCond:{schoolCode}", $"{periodId}");
|
|
|
ItemCond itemCond = null;
|
|
|
if (value != default && !value.IsNullOrEmpty)
|
|
|
{
|
|
|
-
|
|
|
itemCond = value.ToString().ToObject<ItemCond>();
|
|
|
+ var csid = itemCond.subjects.ExceptBy(period.subjects.Select(x=>x.id),x=>x.id);
|
|
|
+ if (csid.IsNotEmpty())
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{_option.Location},学校科目缺失,重新统计题目", GroupNames.成都开发測試群組);
|
|
|
+ List<ItemCondDto> itemCondDtos = new List<ItemCondDto>() { new ItemCondDto() { scope="school", filed=period.id, key= school.id } };
|
|
|
+ var ItemCondQueue = _configuration.GetValue<string>("Azure:ServiceBus:ItemCondQueue");
|
|
|
+ var str = itemCondDtos.ToJsonString();
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(str);
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(ItemCondQueue, messageBlobItemCond);
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
List<ItemInfo> items = new List<ItemInfo>();
|
|
|
- var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.periodId='{periodId}' and c.pid= null ";
|
|
|
+
|
|
|
+
|
|
|
+ string subjectIn = string.Empty;
|
|
|
+ if (period!=null && period.subjects.IsNotEmpty())
|
|
|
+ {
|
|
|
+ subjectIn =$" and c.subjectId in({string.Join(",", period.subjects.Select(x => $"'{x.id}'"))})";
|
|
|
+ }
|
|
|
+ var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.periodId='{periodId}' and c.pid= null {subjectIn} ";
|
|
|
+ //var queryslt = $"SELECT c.gradeIds,c.subjectId,c.periodId,c.type,c.level,c.field ,c.scope FROM c where c.periodId='{periodId}' and c.pid= null ";
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIteratorSql<ItemInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Item-{schoolCode}") }))
|
|
|
{
|
|
|
items.Add(item);
|
|
@@ -122,6 +142,16 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
|
|
|
itemCond = value.ToString().ToObject<ItemCond>();
|
|
|
+ var csid = itemCond.subjects.ExceptBy(period.subjects.Select(x => x.id), x => x.id);
|
|
|
+ if (csid.IsNotEmpty())
|
|
|
+ {
|
|
|
+ await _dingDing.SendBotMsg($"{_option.Location},学校科目缺失,重新统计题目", GroupNames.成都开发測試群組);
|
|
|
+ List<ItemCondDto> itemCondDtos = new List<ItemCondDto>() { new ItemCondDto() { scope="school", filed=period.id, key= school.id } };
|
|
|
+ var ItemCondQueue = _configuration.GetValue<string>("Azure:ServiceBus:ItemCondQueue");
|
|
|
+ var str = itemCondDtos.ToJsonString();
|
|
|
+ var messageBlobItemCond = new ServiceBusMessage(str);
|
|
|
+ await _serviceBus.GetServiceBusClient().SendMessageAsync(ItemCondQueue, messageBlobItemCond);
|
|
|
+ }
|
|
|
itemConds.Add(itemCond);
|
|
|
}
|
|
|
else
|