林豪 左 1 年間 前
コミット
d6880fe134

+ 27 - 19
ServiceCenter/Logs/LogHub.cs

@@ -153,6 +153,7 @@ namespace ServiceCenter.Logs
             {
                 var sw = new Stopwatch();
                 sw.Start();
+                int index = 0;
                 List<LogModel> logs = new List<LogModel>();
                 try
                 {
@@ -165,35 +166,43 @@ namespace ServiceCenter.Logs
                         logs = ret.Select(JsonConvert.DeserializeObject<LogModel>).ToList();
                     }
 
-                    Parallel.ForEach(logs.Where(log => log != null).GroupBy(x => x.path), paths =>
+                    foreach (var paths in logs.Where(log => log != null).GroupBy(x => x.path))
                     {
-                        Parallel.ForEach(paths.GroupBy(x => x.Title), title =>
+                        foreach (var title in paths.GroupBy(x => x.Title))
                         {
                             var log = title.First();
                             var cons = title.OrderBy(x => x.Time).Select(x => x.Con);
                             if (!Directory.Exists(log.path)) Directory.CreateDirectory(log.path);/*.txt*/
-
                             var path = Path.Combine(log.path, log.Title);
-                            var fileInfo = new FileInfo(path);
-                            var fileMb = fileInfo.Length / 1024 / 1024;
-                            if (fileMb > 20) //如果当前文件大小超过20MB 开始封存此文件,
+                            if (!File.Exists(path))
+                            {
+                                File.AppendAllLines(path, cons);
+                            }
+                            else
                             {
-                                var fileIndex = 1; //文件索引
-                                var isSave = false;
-                                while (!isSave) //未保存成功
+                                var fileInfo = new FileInfo(path);
+                                var fileMb = fileInfo.Length / 1024 / 1024;
+                                if (fileMb > 20) //如果当前文件大小超过20MB 开始封存此文件,
                                 {
-                                    var newPath = Path.Combine(log.path, log.Title.Replace(".txt", $"{fileIndex}.txt"));//使用文件索引头来判断当前索引对应的标题文件是否存在
-                                    if (!File.Exists(newPath))//不存在,将现有文件更名成新的文件名
+                                    var fileIndex = 1; //文件索引
+                                    var isSave = false;
+                                    while (!isSave) //未保存成功
                                     {
-                                        File.Move(path, newPath);
-                                        isSave = true;
+                                        var newPath = Path.Combine(log.path, log.Title.Replace(".txt", $"{fileIndex}.txt"));//使用文件索引头来判断当前索引对应的标题文件是否存在
+                                        if (!File.Exists(newPath))//不存在,将现有文件更名成新的文件名
+                                        {
+                                            File.Move(path, newPath);
+                                            isSave = true;
+                                        }
+                                        fileIndex++;
                                     }
-                                    fileIndex++;
                                 }
+                                File.AppendAllLines(path, cons);
                             }
-                            File.AppendAllLines(path, cons);
-                        });
-                    });
+
+                            index++;
+                        }
+                    }
                 }
                 catch (Exception ex)
                 {
@@ -203,8 +212,7 @@ namespace ServiceCenter.Logs
                 sw.Stop();
                 var path1 = $"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\日志处理进程";
                 if (!Directory.Exists(path1)) Directory.CreateDirectory(path1);
-                var count = logs.Where(log => log != null).GroupBy(x => x.path).SelectMany(x => x.GroupBy(t => t.Title)).Count();
-                File.AppendAllText(Path.Combine(path1, "耗时.txt"), $"{DateTime.Now.yyyyMMddhhmmssf()}耗时:{sw.ElapsedMilliseconds}--{logs.Count}--{count}\n");
+                File.AppendAllText(Path.Combine(path1, "耗时.txt"), $"{DateTime.Now.yyyyMMddhhmmssf()}耗时:{sw.ElapsedMilliseconds}--{logs.Count}--{index}\n");
                 if (sw.ElapsedMilliseconds >= toao) continue;
                 var time = toao - sw.ElapsedMilliseconds.ToInt();
                 Thread.Sleep(time);

+ 5 - 0
业务工程/分拣库/WCS.WorkEngineering/Systems/RGVSystems.cs

@@ -325,6 +325,11 @@ namespace WCS.WorkEngineering.Systems
                     .Select(x => x.Entity.Code.ToShort());
                 var devList = devs.OrderBy(x => x.Entity.Code).Where(x => putDev.Contains(x.Data.GoodsEnd));
 
+                if (!devList.Any())
+                {
+                    World.Log($"无可用任务");
+                }
+
                 foreach (var dev in devList)
                 {
                     //区分任务是拆盘机到码垛工位,还是码垛工位到拆盘机