Procházet zdrojové kódy

团组报表
客户相关代码调整(针对老数据)

leiy před 1 rokem
rodič
revize
6dd68e6e10

+ 42 - 12
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -677,11 +677,24 @@ namespace OASystem.API.Controllers
 
                         if (clientIds.Length > 0)
                         {
-                            int[] output = Array.ConvertAll<string, int>(clientIds, delegate (string s) { return int.Parse(s); });
-                            var clients = _clientDatas.Where(it => output.Contains(it.Id)).ToList();
-                            foreach (var client in clients)
+                            List<int> clientIds1 = new List<int>() { };
+                            foreach (var clientIdStr in clientIds)
                             {
-                                itemClientName += $"{client.LastName + client.FirstName},";
+                                if (clientIdStr.IsNumeric())
+                                {
+                                    clientIds1.Add(int.Parse(clientIdStr));
+                                }
+                            }
+                            if (clientIds1.Count > 0)
+                            {
+                                var clients = _clientDatas.Where(it => clientIds1.Contains(it.Id)).ToList();
+                                foreach (var client in clients)
+                                {
+                                    itemClientName += $"{client.LastName + client.FirstName},";
+                                }
+                            }
+                            else {
+                                itemClientName = visaClients;
                             }
                         }
                     }
@@ -841,18 +854,35 @@ namespace OASystem.API.Controllers
 
                         if (clientIds.Length > 0)
                         {
-                            int[] output = Array.ConvertAll<string, int>(clientIds, delegate (string s) { return int.Parse(s); });
-                            var clients = _clientDatas.Where(it => output.Contains(it.Id)).ToList();
-                            foreach (var client in clients)
+                            List<int> output = new List<int>();
+                            foreach (var clientId in clientIds)
+                            {
+                                if (clientId.IsNumeric())
+                                {
+                                    output.Add(int.Parse(clientId));
+                                }
+
+                            }
+
+                            if (output.Count > 0)
                             {
-                                itemClientName += $"{client.LastName + client.FirstName},";
+                                var clients = _clientDatas.Where(it => output.Contains(it.Id)).ToList();
+                                foreach (var client in clients)
+                                {
+                                    itemClientName += $"{client.LastName + client.FirstName},";
+                                }
+                                if (itemClientName.Length > 0)
+                                {
+                                    itemClientName = itemClientName.Substring(0, itemClientName.Length - 1);
+                                }
+                            }
+                            else
+                            {
+                                itemClientName = insClients;
                             }
                         }
                     }
-                    if (itemClientName.Length > 0)
-                    {
-                        itemClientName = itemClientName.Substring(0, itemClientName.Length - 1);
-                    }
+                    
                     item.ClientName = itemClientName;
 
                     if (!string.IsNullOrEmpty(item.AuditGMDate))

+ 20 - 0
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1215,5 +1215,25 @@ namespace OASystem.API.OAMethodLib
 
         #endregion
 
+
+        #region 数字验证
+        /// <summary>
+        /// 验证数字字符串
+        /// </summary>
+        /// <param name="num"></param>
+        /// <returns></returns>
+        public static bool IsNumeric(this string numStr)
+        {
+            bool isNumeric = Regex.IsMatch(numStr, @"^\d+$");
+
+            if (isNumeric)
+            {
+                return true;
+            }
+            return false;
+        }
+
+
+        #endregion
     }
 }