tangjiang 4 giorni fa
parent
commit
c1193e085d
1 ha cambiato i file con 32 aggiunte e 26 eliminazioni
  1. 32 26
      src/DataSharing/Province/ProvinceService.cs

+ 32 - 26
src/DataSharing/Province/ProvinceService.cs

@@ -2232,7 +2232,7 @@ namespace DataSharing.Province
                 missedCallCount = configurationInformation.MissedCallCount;
 
             //如果配置为空或者配置的数量为0
-            if (configurationInformation == null && missedCallCount <= 0)
+            if (configurationInformation == null || missedCallCount <= 0)
                 return false;
 
             _logger.LogInformation("获取到的不上传的值:------------------------" + missedCallCount);
@@ -2268,35 +2268,41 @@ namespace DataSharing.Province
             }
             else
             {
-                #region 生成时间
-                //生成时间
-                List<DateTime> timeLists = new();
-                Random random = new((int)(DateTime.Now.Ticks));
-                for (int i = 0; i < missedCallCount; i++)
+                if (missedCallCount > 0)
                 {
-                    int hour = random.Next(2, 23);
-                    int minute = random.Next(0, 60);
-                    int second = random.Next(0, 60);
-                    string tempStr = string.Format("{0} {1}:{2}:{3}", DateTime.Now.ToString("yyyy-MM-dd"), hour, minute, second);
-                    DateTime rTime = Convert.ToDateTime(tempStr);
-                    timeLists.Add(rTime);
-                }
-                timeLists.Sort();
-                #endregion
+                    #region 生成时间
+                    //生成时间
+                    List<DateTime> timeLists = new();
+                    Random random = new((int)(DateTime.Now.Ticks));
+                    for (int i = 0; i < missedCallCount; i++)
+                    {
+                        int hour = random.Next(2, 23);
+                        int minute = random.Next(0, 60);
+                        int second = random.Next(0, 60);
+                        string tempStr = string.Format("{0} {1}:{2}:{3}", DateTime.Now.ToString("yyyy-MM-dd"), hour, minute, second);
+                        DateTime rTime = Convert.ToDateTime(tempStr);
+                        timeLists.Add(rTime);
+                    }
+                    #endregion
+                    if (timeLists != null && timeLists.Count > 0)
+                    {
+                        timeLists.Sort();
 
-                if (timeLists[0] < endTime)
-                    //处理数据
-                    timeLists.RemoveAt(0);
+                        if (timeLists[0] < endTime)
+                            //处理数据
+                            timeLists.RemoveAt(0);
 
-                MissedCallModelDto missedCall = new()
-                {
-                    DateTimeList = timeLists
-                };
-                if (timeLists == null || timeLists.Count == 0)
-                    missedCall.IsMax = true;
+                        MissedCallModelDto missedCall = new()
+                        {
+                            DateTimeList = timeLists
+                        };
+                        if (timeLists == null || timeLists.Count == 0)
+                            missedCall.IsMax = true;
 
-                await _missedCallModelCache.SetAsync(key, missedCall, TimeSpan.FromDays(1), cancellationToken);
-                return true;
+                        await _missedCallModelCache.SetAsync(key, missedCall, TimeSpan.FromDays(1), cancellationToken);
+                        return true;
+                    }
+                }
             }
             return false;
         }