baowei 4 tháng trước cách đây
mục cha
commit
2a68cf8440

+ 10 - 3
EInk.Lot3/Controllers/Lot3Controller.cs

@@ -12,6 +12,7 @@ using System.Text;
 using EInk.Dtos;
 using System.Reflection.Metadata;
 using Microsoft.AspNetCore.Mvc.Rendering;
+using EInk.Tools;
 
 namespace EInk.Controllers
 {
@@ -28,6 +29,7 @@ namespace EInk.Controllers
         [HttpPost("UploadLot3")]
         public IActionResult Lot3Data([FromBody] Lot2Lot3Dto lot3Data)
         {
+            string jsonStr = JsonConvert.SerializeObject(lot3Data);
             try
             {
                 try
@@ -36,6 +38,7 @@ namespace EInk.Controllers
                 }
                 catch (Exception ex)
                 {
+                    LogerHelper.RecordLogTxt($"UploadLot3, Valid Fail, Data:{jsonStr}, Message:{ex.Message}");
                     return Ok(ResultDto.Fail(ex.Message));
                 }
                 Lot2Lot3Model lot3model = new()
@@ -43,7 +46,7 @@ namespace EInk.Controllers
                     lot_id = lot3Data.id,
                     is_send = 0,
                     product_no = lot3Data.slidesNumber,
-                    content = JsonConvert.SerializeObject(lot3Data),
+                    content = jsonStr,
                     create_time = DateTime.Now
                 };
                 //根据guid查看是否为重复插入
@@ -56,6 +59,7 @@ namespace EInk.Controllers
             }
             catch (Exception ex)
             {
+                LogerHelper.RecordLogTxt($"UploadLot3, Data:{jsonStr}, StackTrace:{ex.StackTrace}, Message:{ex.Message}");
                 return Ok(ResultDto.Fail("error:" + ex.Message));
             }
         }
@@ -64,6 +68,7 @@ namespace EInk.Controllers
         [HttpPost("UploadColourCast")]
         public IActionResult ColourCastData([FromBody] ColourCastDto ColourCastData)
         {
+            string jsonStr = JsonConvert.SerializeObject(ColourCastData);
             try
             {
                 try
@@ -72,6 +77,7 @@ namespace EInk.Controllers
                 }
                 catch (Exception ex)
                 {
+                    LogerHelper.RecordLogTxt($"UploadColourCast, Valid Fail, Data:{jsonStr}, Message:{ex.Message}");
                     return Ok(ResultDto.Fail(ex.Message));
                 };
                 ColourCastModel colourcastmodel = new()
@@ -79,7 +85,7 @@ namespace EInk.Controllers
                     gid = ColourCastData.id,
                     slidesNumber = ColourCastData.slidesNumber,
                     is_send = 0,
-                    content = JsonConvert.SerializeObject(ColourCastData),
+                    content = jsonStr,
                     create_time = DateTime.Now
                 };
                 //根据guid查看是否为重复插入
@@ -92,13 +98,14 @@ namespace EInk.Controllers
             }
             catch (Exception ex)
             {
+                LogerHelper.RecordLogTxt($"UploadColourCast, Data:{jsonStr}, StackTrace:{ex.StackTrace}, Message:{ex.Message}");
                 return Ok(ResultDto.Fail("error:" + ex.Message));
             }
         }
 
 
         [HttpPost("UpdateDefectInfo")]
-        public IActionResult UpdateDefectInfo([FromBody] IFormFile file)
+        public IActionResult UpdateDefectInfo(IFormFile file)
         {
             if (file == null || file.Length == 0)
             {

+ 25 - 34
EInk.Lot3/Dtos/ColourCastDto.cs

@@ -11,8 +11,9 @@ namespace EInk.Dtos
         public string pattern { get; set; }
         public string result { get; set; }
         public List<double> values { get; set; } = new List<double>();
-        public List<int> alarmLocation { get; set; } = new List<int>();
-        public List<double> threshold { get; set; } = new List<double>();
+        public int NGCode { get; set; }
+        //public List<int> alarmLocation { get; set; } = new List<int>();
+        //public string threshold { get; set; } 
         public void Valid()
         {
             if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
@@ -68,42 +69,32 @@ namespace EInk.Dtos
                 throw new Exception("Incorrect values");
             }
 
-            if (alarmLocation.Count != 15)
+            if (NGCode < 0 || NGCode > 32767)
             {
-                throw new Exception("Incorrect alarmLocation length");
+                throw new Exception("Incorrect NGCode");
             }
-            try
-            {
-                foreach (var item in alarmLocation)
-                {
-                    int judge = Convert.ToInt32(item);
-                    if (judge != 0 && judge != 1)
-                    {
-                        throw new Exception("Incorrect alarmLocation");
-                    }
 
-                }
-            }
-            catch
-            {
-                throw new Exception("Incorrect alarmLocation");
-            }
+            //if (alarmLocation.Count != 15)
+            //{
+            //    throw new Exception("Incorrect alarmLocation length");
+            //}
+            //try
+            //{
+            //    foreach (var item in alarmLocation)
+            //    {
+            //        int judge = Convert.ToInt32(item);
+            //        if (judge != 0 && judge != 1)
+            //        {
+            //            throw new Exception("Incorrect alarmLocation");
+            //        }
+
+            //    }
+            //}
+            //catch
+            //{
+            //    throw new Exception("Incorrect alarmLocation");
+            //}
 
-            if (threshold.Count != 2)
-            {
-                throw new Exception("Incorrect threshold length");
-            }
-            try
-            {
-                foreach (var item in threshold)
-                {
-                    Convert.ToDouble(item);
-                }
-            }
-            catch
-            {
-                throw new Exception("Incorrect threshold");
-            }
 
         }
     }

+ 1 - 2
EInk.Lot3/Program.cs

@@ -16,7 +16,6 @@ builder.Services.AddSingleton<ISqlSugarClient>(s =>
     SqlSugarScope sqlSugar = new(new ConnectionConfig()
     {
         DbType = DbType.PostgreSQL,
-        //ConnectionString = "Host=127.0.0.1;Port=5432;Database=pg;Username=postgres;Password=eink;",
         ConnectionString = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build().GetValue<string>("LocalDbConnectionString"),
         IsAutoCloseConnection = true,
     },
@@ -35,7 +34,7 @@ builder.Services.AddSingleton<ISqlSugarClient>(s =>
 var app = builder.Build();
 app.UseSwagger();
 app.UseSwaggerUI();
-app.UseHttpsRedirection();
+//app.UseHttpsRedirection();
 app.UseAuthorization();
 app.MapControllers();
 app.Run();

+ 7 - 3
EInk.Lot3/Startup.cs

@@ -35,25 +35,29 @@ namespace EInk.Lot2Lot3
 
             if (config.GetValue<bool>("ReadLot2Thread") ==true)
             {
+                LogerHelper.RecordLogTxt("Start ReadLot2Thread");
                 ReadLot2Thread readLot2 = new ReadLot2Thread(_db, _local_db);
                 readLot2.ReadThreadStart(); 
             }
 
             if (config.GetValue<bool>("SendLot2Lot3Thread") == true)
             {
-                SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread(_db);
+                LogerHelper.RecordLogTxt("Start SendLot2Lot3Thread");
+                SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread(_local_db);
                 sendLot2Lot3.SendThreadStart();
             }
 
             if (config.GetValue<bool>("SendColourCastThread") == true)
             {
-                SendColourCastThread sendcolourcast = new SendColourCastThread(_db);
+                LogerHelper.RecordLogTxt("Start SendColourCastThread");
+                SendColourCastThread sendcolourcast = new SendColourCastThread(_local_db);
                 sendcolourcast.SendThreadStart();
             }
 
             if (config.GetValue<bool>("DeleteDBRecordThread") == true)
             {
-                DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(_db, config.GetValue<int>("DaysAgo"));
+                LogerHelper.RecordLogTxt("Start DeleteDBRecordThread");
+                DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(_local_db, config.GetValue<int>("DaysAgo"));
                 deleterecord.DeleteThreadStart();
             }
 

+ 3 - 4
EInk.Lot3/TaskThread/DeleteDBRecordThread.cs

@@ -9,7 +9,7 @@ namespace EInk.TaskThread
     public class DeleteDBRecordThread
     {
         private readonly ISqlSugarClient _db;
-        private static int daysago;
+        public static int daysago;
 
         public DeleteDBRecordThread(ISqlSugarClient db, int daysago)
         {
@@ -34,9 +34,8 @@ namespace EInk.TaskThread
                     DateTime now = DateTime.Now;
                     if (now.Hour==8 && now.Minute==0)
                     {
-                        _db.Deleteable<Lot2Lot3Model>().Where(x => x.create_time < now.AddDays(DeleteDBRecordThread.daysago)).ExecuteCommand();
-                        _db.Deleteable<ColourCastModel>().Where(x => x.create_time < now.AddDays(DeleteDBRecordThread.daysago)).ExecuteCommand();
-                        LogerHelper.RecordLogTxt("DeleteTask");
+                        LogerHelper.RecordLogTxt($"DeleteTask, DeleteLot2Lot3Data Before {now.AddDays(-DeleteDBRecordThread.daysago).ToString()}, {_db.Deleteable<Lot2Lot3Model>().Where(x => x.create_time < now.AddDays(-DeleteDBRecordThread.daysago)).ExecuteCommand()}");
+                        LogerHelper.RecordLogTxt($"DeleteTask, DeleteColourCastData Before {now.AddDays(-DeleteDBRecordThread.daysago).ToString()},  {_db.Deleteable<ColourCastModel>().Where(x => x.create_time < now.AddDays(-DeleteDBRecordThread.daysago)).ExecuteCommand()}");
                     }
 
                 }

+ 3 - 3
EInk.Lot3/TaskThread/ReadLot2Thread.cs

@@ -317,18 +317,18 @@ namespace EInk.TaskThread
                         }
                         catch (Exception ex)
                         {
-                            LogerHelper.RecordLogTxt("ReadLot2Task[1]," + ex.Message);
+                            LogerHelper.RecordLogTxt($"ReadLot2Task[1], StackTrace:{ex.StackTrace}, Message:{ex.Message}");
                             _local_db.Ado.RollbackTran();
                         }
                     }
                 }
                 catch (Exception ex)
                 {
-                    LogerHelper.RecordLogTxt("ReadLot2Task[2]," + ex.Message);
+                    LogerHelper.RecordLogTxt($"ReadLot2Task[2], StackTrace:{ex.StackTrace}, Message:{ex.Message}");
                 }
                 finally
                 {
-                    Thread.Sleep(5000);
+                    Thread.Sleep(10000);
                 }
             }
 

+ 4 - 4
EInk.Lot3/TaskThread/SendColourCastThread.cs

@@ -46,12 +46,12 @@ namespace EInk.TaskThread
                                 }
                                 else
                                 {
-                                    LogerHelper.RecordLogTxt("SendColourCastTask,MesApi1," + rt.Code + "," + rt.Message + "," + unsend.content);
+                                    LogerHelper.RecordLogTxt("SendColourCastTask, MesApi1, " + rt.Code + "," + rt.Message + "," + unsend.content);
                                 } 
                             }
                             else
                             {
-                                LogerHelper.RecordLogTxt("SendColourCastTask,MesApi2," + rt_bl+ "," + rt_str + "," + unsend.content);
+                                LogerHelper.RecordLogTxt("SendColourCastTask, MesApi2, " + rt_bl+ "," + rt_str + "," + unsend.content);
                             }
                             Thread.Sleep(1000);
                         }
@@ -59,11 +59,11 @@ namespace EInk.TaskThread
                 }
                 catch(Exception ex)
                 {
-                    LogerHelper.RecordLogTxt("SendLotTask," + ex.Message);
+                    LogerHelper.RecordLogTxt($"SendColourCastTask, StackTrace:{ex.StackTrace}, Message:{ex.Message}");
                 }
                 finally
                 {
-                    Thread.Sleep(5000);
+                    Thread.Sleep(10000);
                 }
             }
 

+ 5 - 5
EInk.Lot3/TaskThread/SendLot2Lot3Thread.cs

@@ -29,7 +29,7 @@ namespace EInk.TaskThread
             {
                 try
                 {
-                    List<Lot2Lot3Model> unsend_list = _db.Queryable<Lot2Lot3Model>().Where(x => x.is_send == 0).OrderBy(x => x.id).Take(120).ToList();
+                    List<Lot2Lot3Model> unsend_list = _db.Queryable<Lot2Lot3Model>().Where(x => x.is_send == 0).OrderBy(x => x.id).Take(60).ToList();
                     if (unsend_list != null && unsend_list.Count > 0)
                     {
                         foreach (var unsend in unsend_list)
@@ -46,12 +46,12 @@ namespace EInk.TaskThread
                                 }
                                 else
                                 {
-                                    LogerHelper.RecordLogTxt("SendLotTask,MesApi1," + rt.Code + "," + rt.Message + "," + unsend.content);
+                                    LogerHelper.RecordLogTxt("SendLotTask, MesApi1, " + rt.Code + "," + rt.Message + "," + unsend.content);
                                 } 
                             }
                             else
                             {
-                                LogerHelper.RecordLogTxt("SendLotTask,MesApi2," + rt_bl+ "," + rt_str + "," + unsend.content);
+                                LogerHelper.RecordLogTxt("SendLotTask, MesApi2, " + rt_bl+ "," + rt_str + "," + unsend.content);
                             }
                             Thread.Sleep(1000);
                         }
@@ -59,11 +59,11 @@ namespace EInk.TaskThread
                 }
                 catch(Exception ex)
                 {
-                    LogerHelper.RecordLogTxt("SendLotTask," + ex.Message);
+                    LogerHelper.RecordLogTxt($"SendLotTask, StackTrace:{ex.StackTrace}, Message:{ex.Message}");
                 }
                 finally
                 {
-                    Thread.Sleep(5000);
+                    Thread.Sleep(10000);
                 }
             }
 

+ 3 - 3
EInk.Lot3/appsettings.json

@@ -16,18 +16,18 @@
       //}
     }
   },
-  "LocalDbConnectionString": "Host=127.0.0.1;Port=5432;Database=Lot2Lot3;Username=postgres;Password=eink;",
+  "LocalDbConnectionString": "Host=127.0.0.1;Port=5432;Database=Eink;Username=postgres;Password=eink;",
   //"TargetDbConnectionString": "Host=127.0.0.1;Port=5432;Database=targetdb;Username=postgres;Password=eink;",
   //"TargetDbConnectionString": "Host=192.168.1.108;Port=5432;Database=eink;Username=postgres;Password=eink;",
   "TargetDbConnectionString": "",
   "ProductStartID": 0,
   "MesUrl": "http://eyzms.toc.eink.com:8088",
   "MesUrlTime": 30,
-  "DaysAgo": 100,
+  "DaysAgo": 60,
   "PatternList": "wht,dot",
   "Topic": "LOT2AOIData#04#04-2AOI01",
   "ReadLot2Thread": false,
   "SendLot2Lot3Thread": false,
   "SendColourCastThread": false,
-  "DeleteDBRecordThread": false
+  "DeleteDBRecordThread": true
 }