|
@@ -173,16 +173,62 @@ namespace TEAMModelOS.FunctionV4.TimeTrigger
|
|
|
int field = 1;
|
|
|
foreach (var item in counts)
|
|
|
{
|
|
|
- bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"LessonRecord:Unused:Lock:{location}", field, new { status = 0, item }.ToJsonString());
|
|
|
- field += 1;
|
|
|
+ if (item.Any())
|
|
|
+ {
|
|
|
+ bool stuallstatus = await _azureRedis.GetRedisClient(8).HashSetAsync($"LessonRecord:Unused:Lock:{location}", field,
|
|
|
+ new UnusedLock { field= field, status = 0, item= item }.ToJsonString());
|
|
|
+ field += 1;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
await _dingDing.SendBotMsg($"{location},获取到:{schoolKeys.Count} 个学校和个人的容器\n" +
|
|
|
$"大概要处理:{schoolKeys.Sum(x => x.count) + schoolKeys.Where(x => x.count >= 0).Count()} 条数据\n" +
|
|
|
$"将数据分为:{field - 1} 次处理,每次处理500-1000条数据。", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
+ //key存在的时候 开始进行数据处理
|
|
|
+ var records = await _azureRedis.GetRedisClient(8).HashGetAllAsync($"LessonRecord:Unused:Lock:{location}");
|
|
|
+ List<UnusedLock> unuseds = new List<UnusedLock>();
|
|
|
+ foreach (var rcd in records)
|
|
|
+ {
|
|
|
+ var value = rcd.Value.ToString().ToObject<UnusedLock>();
|
|
|
+ unuseds.Add(value);
|
|
|
+ }
|
|
|
+ var unused = unuseds.Where(s => s.status == 0).OrderBy(x => x.field).Take(1);
|
|
|
+ if (unused.Any()) {
|
|
|
+ var stime = DateTimeOffset.UtcNow;
|
|
|
+ long s = stime.ToUnixTimeMilliseconds();
|
|
|
+ string sdata = stime.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
+ UnusedLock unusedLock= unused.First();
|
|
|
+ foreach (IdCodeCount idCode in unusedLock.item) {
|
|
|
+ try {
|
|
|
+ var ContainerClient = _azureStorage.GetBlobContainerClient($"{idCode.id}");
|
|
|
+ List<string> items = await ContainerClient.List("records");
|
|
|
+ if (items.IsNotEmpty()) {
|
|
|
+ HashSet<string> set = new HashSet<string>();
|
|
|
+ items.ForEach(z => {
|
|
|
+ var uri = z.Split("/");
|
|
|
+ if (uri.Length > 1)
|
|
|
+ {
|
|
|
+ set.Add(uri[1]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public class UnusedLock {
|
|
|
+ public int field { get; set; }
|
|
|
+ /// <summary>
|
|
|
+ /// 0默认未被执行,1 正在执行中
|
|
|
+ /// </summary>
|
|
|
+ public int status { get; set; }
|
|
|
+ public IEnumerable<IdCodeCount> item { get; set; } = new List<IdCodeCount>();
|
|
|
+ }
|
|
|
public class IdCodeCount {
|
|
|
public string id { get; set; }
|
|
|
public string code { get; set; }
|