2 コミット 2a68cf8440 ... 7c9fc75a3b

作者 SHA1 メッセージ 日付
  baowei 7c9fc75a3b 202502211136 4 日 前
  baowei bc343856d7 202410111324 4 ヶ月 前

+ 187 - 4
EInk.Lot3/Controllers/Lot3Controller.cs

@@ -13,6 +13,10 @@ using EInk.Dtos;
 using System.Reflection.Metadata;
 using Microsoft.AspNetCore.Mvc.Rendering;
 using EInk.Tools;
+using EInk.Lot2Lot3.Models;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
+using System.Reflection;
 
 namespace EInk.Controllers
 {
@@ -21,17 +25,25 @@ namespace EInk.Controllers
     public class Lot3Controller : ControllerBase
     {
         private readonly ISqlSugarClient _db;
+        private readonly IConfiguration _configuration;
+        private readonly AppearancePixelEquivalent _appearancepixelequivalent;
+        private readonly List<string> _Lot3AppearancePatternList;
+
         public Lot3Controller(ISqlSugarClient db)
         {
             _db = db;
+            _configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
+            _appearancepixelequivalent = _configuration.GetSection("AppearancePixelEquivalent").Get<AppearancePixelEquivalent>();
+            _Lot3AppearancePatternList = _configuration.GetValue<string>("Lot3AppearancePatternList").Split(",").ToList();
         }
 
         [HttpPost("UploadLot3")]
-        public IActionResult Lot3Data([FromBody] Lot2Lot3Dto lot3Data)
+        public IActionResult Lot3Data([FromBody] Lot3Dto lot3Data)
         {
             string jsonStr = JsonConvert.SerializeObject(lot3Data);
             try
             {
+                LogerHelper.RecordLogTxt($"UploadLot3, Data:{jsonStr}");
                 try
                 {
                     lot3Data.Valid();
@@ -41,16 +53,76 @@ namespace EInk.Controllers
                     LogerHelper.RecordLogTxt($"UploadLot3, Valid Fail, Data:{jsonStr}, Message:{ex.Message}");
                     return Ok(ResultDto.Fail(ex.Message));
                 }
+                //外观检像素当量
+                if (_appearancepixelequivalent.enable && lot3Data.result == "NG")
+                {
+                    foreach (var item in lot3Data.itemCheckDatas)
+                    {
+                        //像素 = 实际长度 / 像素当量
+                        switch (item.pattern)
+                        {
+                            case "PositiveAppearance":
+                                foreach (var detail_item in item.details)
+                                {
+                                    var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                    if (flag)
+                                    {
+                                        detail_item.height = (Math.Round(height / _appearancepixelequivalent.PositiveAppearance, 2)).ToString();
+                                        detail_item.width = (Math.Round(width / _appearancepixelequivalent.PositiveAppearance, 2)).ToString();
+                                    }
+                                }
+                                break;
+                            case "BackAppearance":
+                                foreach (var detail_item in item.details)
+                                {
+                                    var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                    if (flag)
+                                    {
+                                        detail_item.height = (Math.Round(height / _appearancepixelequivalent.BackAppearance, 2)).ToString();
+                                        detail_item.width = (Math.Round(width / _appearancepixelequivalent.BackAppearance, 2)).ToString();
+                                    }
+                                }
+                                break;
+                            case "BackFPC":
+                                foreach (var detail_item in item.details)
+                                {
+                                    var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                    if (flag)
+                                    {
+                                        detail_item.height = (Math.Round(height / _appearancepixelequivalent.BackFPC, 2)).ToString();
+                                        detail_item.width = (Math.Round(width / _appearancepixelequivalent.BackFPC, 2)).ToString();
+                                    }
+                                }
+                                break;
+                            case "PositiveFPC":
+                                foreach (var detail_item in item.details)
+                                {
+                                    var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                    if (flag)
+                                    {
+                                        detail_item.height = (Math.Round(height / _appearancepixelequivalent.PositiveFPC, 2)).ToString();
+                                        detail_item.width = (Math.Round(width / _appearancepixelequivalent.PositiveFPC, 2)).ToString();
+                                    }
+                                }
+                                break;
+                            default:
+                                break;
+                        }
+                    }
+                }
                 Lot2Lot3Model lot3model = new()
                 {
                     lot_id = lot3Data.id,
                     is_send = 0,
                     product_no = lot3Data.slidesNumber,
-                    content = jsonStr,
-                    create_time = DateTime.Now
+                    create_time = DateTime.Now,
+                    is_repeatupload = Convert.ToInt32(lot3Data.isrepeatupload),
+                    operation_time = Convert.ToDateTime(lot3Data.createTime),
+                    content = JsonConvert.SerializeObject(new Lot2Lot3Dto(lot3Data))
                 };
+
                 //根据guid查看是否为重复插入
-                if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", lot3Data.id)) > 0)
+                if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", lot3Data.id)) > 0 || lot3Data.slidesNumber == "NA")
                 {
                     lot3model.is_send = 3;
                 }
@@ -64,6 +136,116 @@ namespace EInk.Controllers
             }
         }
 
+        [HttpPost("UploadLot3List")]
+        public IActionResult Lot3DataList([FromBody] List<Lot3Dto> lot3Datalist)
+        {
+            Lot3Dto Lot3tempData = new Lot3Dto();
+            try
+            {
+                foreach (var item in lot3Datalist)
+                {
+                    Lot3tempData = item;
+                    item.Valid();
+                }
+            }
+            catch (Exception ex)
+            {
+                LogerHelper.RecordLogTxt($"UploadLot3, Valid Fail, Data:{JsonConvert.SerializeObject(Lot3tempData)}, Message:{ex.Message}");
+                //return Ok(ResultDto.Fail(ex.Message));
+                return Ok(ResultDto.Fail($"Valid Fail, Data:{JsonConvert.SerializeObject(Lot3tempData)}, Message:{ex.Message}"));
+            }
+            try
+            {
+                _db.Ado.BeginTran();
+                foreach (var Lot3item in lot3Datalist)
+                {
+                    Lot3tempData = Lot3item;
+                    //外观检像素当量
+                    if (_appearancepixelequivalent.enable && Lot3item.result == "NG")
+                    {
+                        foreach (var item in Lot3item.itemCheckDatas)
+                        {
+                            //像素 = 实际长度 / 像素当量
+                            switch (item.pattern)
+                            {
+                                case "PositiveAppearance":
+                                    foreach (var detail_item in item.details)
+                                    {
+                                        var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                        if (flag)
+                                        {
+                                            detail_item.height = (Math.Round(height / _appearancepixelequivalent.PositiveAppearance, 2)).ToString();
+                                            detail_item.width = (Math.Round(width / _appearancepixelequivalent.PositiveAppearance, 2)).ToString();
+                                        }
+                                    }
+                                    break;
+                                case "BackAppearance":
+                                    foreach (var detail_item in item.details)
+                                    {
+                                        var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                        if (flag)
+                                        {
+                                            detail_item.height = (Math.Round(height / _appearancepixelequivalent.BackAppearance, 2)).ToString();
+                                            detail_item.width = (Math.Round(width / _appearancepixelequivalent.BackAppearance, 2)).ToString();
+                                        }
+                                    }
+                                    break;
+                                case "BackFPC":
+                                    foreach (var detail_item in item.details)
+                                    {
+                                        var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                        if (flag)
+                                        {
+                                            detail_item.height = (Math.Round(height / _appearancepixelequivalent.BackFPC, 2)).ToString();
+                                            detail_item.width = (Math.Round(width / _appearancepixelequivalent.BackFPC, 2)).ToString();
+                                        }
+                                    }
+                                    break;
+                                case "PositiveFPC":
+                                    foreach (var detail_item in item.details)
+                                    {
+                                        var (flag, height, width) = detail_item.Valid_HeightWidth();
+                                        if (flag)
+                                        {
+                                            detail_item.height = (Math.Round(height / _appearancepixelequivalent.PositiveFPC, 2)).ToString();
+                                            detail_item.width = (Math.Round(width / _appearancepixelequivalent.PositiveFPC, 2)).ToString();
+                                        }
+                                    }
+                                    break;
+                                default:
+                                    break;
+                            }
+                        }
+                    }
+                    Lot2Lot3Model lot3model = new()
+                    {
+                        lot_id = Lot3item.id,
+                        is_send = 0,
+                        product_no = Lot3item.slidesNumber,
+                        create_time = DateTime.Now,
+                        is_repeatupload = Convert.ToInt32(Lot3item.isrepeatupload),
+                        operation_time = Convert.ToDateTime(Lot3item.createTime),
+                        content = JsonConvert.SerializeObject(new Lot2Lot3Dto(Lot3item))
+                    };
+
+                    //根据guid查看是否为重复插入
+                    if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", Lot3item.id)) > 0 || Lot3item.slidesNumber == "NA")
+                    {
+                        lot3model.is_send = 3;
+                    }
+                    _db.Insertable(lot3model).ExecuteCommand();
+                }
+                _db.Ado.CommitTran();
+                return Ok(ResultDto.Success());
+            }
+            catch (Exception ex)
+            {
+                _db.Ado.RollbackTran(); ;
+                LogerHelper.RecordLogTxt($"UploadLot3, Data:{JsonConvert.SerializeObject(Lot3tempData)}, StackTrace:{ex.StackTrace}, Message:{ex.Message}");
+                return Ok(ResultDto.Fail("error:" + ex.Message));
+            }
+        }
+
 
         [HttpPost("UploadColourCast")]
         public IActionResult ColourCastData([FromBody] ColourCastDto ColourCastData)
@@ -142,5 +324,6 @@ namespace EInk.Controllers
             }
             return Ok(ResultDto.Success());
         }
+
     }
 }

+ 36 - 4
EInk.Lot3/Dtos/Lot2Lot3Dto.cs

@@ -7,6 +7,16 @@ namespace EInk.Dtos
 {
     public class Lot2Lot3Dto
     {
+        public Lot2Lot3Dto() { }
+        public Lot2Lot3Dto(Lot3Dto lot3Data)
+        {
+            id = lot3Data.id;
+            slidesNumber = lot3Data.slidesNumber;
+            topic= lot3Data.topic;
+            createTime = lot3Data.createTime;
+            result = lot3Data.result;
+            itemCheckDatas = lot3Data.itemCheckDatas;
+        }
         public string id { get; set; }
         public string slidesNumber { get; set; }
         public string topic { get; set; }
@@ -32,13 +42,13 @@ namespace EInk.Dtos
             {
                 throw new Exception("Empty result");
             }
-            if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
+            if (result != "NG" && result != "OK")
             {
-                throw new Exception("Empty createTime");
+                throw new Exception("Incorrect result");
             }
-            if (result!="NG"&&result!="OK")
+            if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
             {
-                throw new Exception("Incorrect result");
+                throw new Exception("Empty createTime");
             }
             try
             {
@@ -102,6 +112,7 @@ namespace EInk.Dtos
         public string? width { get; set; }
         public string? height { get; set; }
         public string? area { get; set; }
+        public string? rotation { get; set; } = "0";
         public void Valid()
         {
             if (String.IsNullOrEmpty(defectCode) || String.IsNullOrEmpty(defectCode.Trim()))
@@ -174,5 +185,26 @@ namespace EInk.Dtos
             //    throw new Exception("Incorrect area");
             //}
         }
+
+        public (bool,double,double) Valid_HeightWidth()
+        {
+            if (width == null || String.IsNullOrEmpty(width.Trim())|| height == null || String.IsNullOrEmpty(height.Trim()))
+            {
+                return (false, 0, 0);
+            }
+
+            double valid_width;
+            double valid_height;
+            try
+            {
+                valid_width = Convert.ToDouble(width);
+                valid_height = Convert.ToDouble(height);
+            }
+            catch
+            {
+                return (false, 0, 0);
+            }
+            return (true, valid_height, valid_width);
+        }
     }
 }

+ 72 - 0
EInk.Lot3/Dtos/Lot3Dto.cs

@@ -0,0 +1,72 @@
+using EInk.Models;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using System.ComponentModel;
+using static System.Collections.Specialized.BitVector32;
+
+namespace EInk.Dtos
+{
+    public class Lot3Dto
+    {
+        public string id { get; set; }
+        public string slidesNumber { get; set; }
+        public string topic { get; set; }
+        public string createTime { get; set; }
+        public string result { get; set; }
+        public string isrepeatupload { get; set; }
+        public List<itemCheckData>? itemCheckDatas { get; set; } = new List<itemCheckData>();
+
+        public void Valid()
+        {
+            if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
+            {
+                throw new Exception("Empty id");
+            }
+            if (String.IsNullOrEmpty(slidesNumber) || String.IsNullOrEmpty(slidesNumber.Trim()))
+            {
+                throw new Exception("Empty slidesNumber");
+            }
+            if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim()))
+            {
+                throw new Exception("Empty topic");
+            }
+            if (String.IsNullOrEmpty(result) || String.IsNullOrEmpty(result.Trim()))
+            {
+                throw new Exception("Empty result");
+            }
+            if (result != "NG" && result != "OK")
+            {
+                throw new Exception("Incorrect result");
+            }
+            if (String.IsNullOrEmpty(isrepeatupload) || String.IsNullOrEmpty(isrepeatupload.Trim()))
+            {
+                throw new Exception("Empty isrepeatupload");
+            }
+            //0、正常数据
+            //1、上抛失败重抛数据
+            //2、不完整数据
+            //3、数据不完整,后补充重复上报数据
+            if (isrepeatupload != "0" && isrepeatupload != "1" && isrepeatupload != "2" && isrepeatupload != "3")
+            {
+                throw new Exception("Incorrect isrepeatupload");
+            }
+            if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
+            {
+                throw new Exception("Empty createTime");
+            }
+            try
+            {
+                DateTime valid = Convert.ToDateTime(createTime);
+            }
+            catch
+            {
+                throw new Exception("Incorrect createTime");
+            }
+            foreach (var itemCheckData in itemCheckDatas)
+            {
+                itemCheckData.Valid();
+            }
+        }
+    }
+
+    
+}

+ 31 - 0
EInk.Lot3/Models/AppearancePixelEquivalent.cs

@@ -0,0 +1,31 @@
+namespace EInk.Lot2Lot3.Models
+{
+    public class AppearancePixelEquivalent
+    {
+
+        /// <summary>
+        /// 是否启用
+        /// </summary>
+        public bool enable { get; set; }
+
+        /// <summary>
+        /// 正面外观检像素当量,像素=实际长度/像素当量
+        /// </summary>
+        public double PositiveAppearance { get; set; }
+
+        /// <summary>
+        /// 背面外观检像素当量
+        /// </summary>
+        public double BackAppearance { get; set; }
+
+        /// <summary>
+        /// 背面FPC检像素当量
+        /// </summary>
+        public double BackFPC { get; set; }
+
+        /// <summary>
+        /// 正面FPC检像素当量
+        /// </summary>
+        public double PositiveFPC { get; set; }
+    }
+}

+ 7 - 0
EInk.Lot3/Models/Lot2Lot3Model.cs

@@ -20,13 +20,20 @@ namespace EInk.Models
         [SugarColumn(ColumnName = "is_send")]
         public int is_send { get; set; }
 
+        [SugarColumn(ColumnName = "is_repeatupload")]
+        public int is_repeatupload { get; set; }
+
         [SugarColumn(ColumnName = "create_time")]
         public DateTime create_time { get; set; }
 
         [SugarColumn(ColumnName = "send_time")]
         public DateTime send_time { get; set; }
 
+        [SugarColumn(ColumnName = "operation_time")]
+        public DateTime operation_time { get; set; }
+
         [SugarColumn(ColumnName = "content", ColumnDataType = StaticConfig.CodeFirst_BigString)]
         public string content { get; set; }
+
     }
 }

+ 4 - 10
EInk.Lot3/Startup.cs

@@ -12,12 +12,6 @@ namespace EInk.Lot2Lot3
     {
         private static IConfigurationRoot config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
 
-        private readonly ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
-        {
-            DbType = DbType.PostgreSQL,
-            ConnectionString = config.GetValue<string>("TargetDbConnectionString"),
-            IsAutoCloseConnection = true
-        });
 
         private readonly ISqlSugarClient _local_db = new SqlSugarClient(new ConnectionConfig()
         {
@@ -36,28 +30,28 @@ namespace EInk.Lot2Lot3
             if (config.GetValue<bool>("ReadLot2Thread") ==true)
             {
                 LogerHelper.RecordLogTxt("Start ReadLot2Thread");
-                ReadLot2Thread readLot2 = new ReadLot2Thread(_db, _local_db);
+                ReadLot2Thread readLot2 = new ReadLot2Thread();
                 readLot2.ReadThreadStart(); 
             }
 
             if (config.GetValue<bool>("SendLot2Lot3Thread") == true)
             {
                 LogerHelper.RecordLogTxt("Start SendLot2Lot3Thread");
-                SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread(_local_db);
+                SendLot2Lot3Thread sendLot2Lot3 = new SendLot2Lot3Thread();
                 sendLot2Lot3.SendThreadStart();
             }
 
             if (config.GetValue<bool>("SendColourCastThread") == true)
             {
                 LogerHelper.RecordLogTxt("Start SendColourCastThread");
-                SendColourCastThread sendcolourcast = new SendColourCastThread(_local_db);
+                SendColourCastThread sendcolourcast = new SendColourCastThread();
                 sendcolourcast.SendThreadStart();
             }
 
             if (config.GetValue<bool>("DeleteDBRecordThread") == true)
             {
                 LogerHelper.RecordLogTxt("Start DeleteDBRecordThread");
-                DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(_local_db, config.GetValue<int>("DaysAgo"));
+                DeleteDBRecordThread deleterecord = new DeleteDBRecordThread(config.GetValue<int>("DaysAgo"));
                 deleterecord.DeleteThreadStart();
             }
 

+ 10 - 7
EInk.Lot3/TaskThread/DeleteDBRecordThread.cs

@@ -8,24 +8,28 @@ namespace EInk.TaskThread
 {
     public class DeleteDBRecordThread
     {
-        private readonly ISqlSugarClient _db;
         public static int daysago;
 
-        public DeleteDBRecordThread(ISqlSugarClient db, int daysago)
+        public DeleteDBRecordThread(int daysago)
         {
-            _db = db;
             DeleteDBRecordThread.daysago = daysago;
         }
 
         public void DeleteThreadStart()
         {
             Thread t = new Thread(DeleteTask);
-            t.Start(_db);
+            t.Start();
         }
 
-        static void DeleteTask(object db)
+        static void DeleteTask()
         {
-            ISqlSugarClient _db = (ISqlSugarClient)db;
+            IConfiguration _configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
+            ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
+            {
+                DbType = DbType.PostgreSQL,
+                ConnectionString = _configuration.GetValue<string>("LocalDbConnectionString"),
+                IsAutoCloseConnection = true
+            });
             while (true)
             {
                 try
@@ -37,7 +41,6 @@ namespace EInk.TaskThread
                         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()}");
                     }
-
                 }
                 catch (Exception ex)
                 {

+ 35 - 24
EInk.Lot3/TaskThread/ReadLot2Thread.cs

@@ -12,27 +12,32 @@ namespace EInk.TaskThread
 {
     public class ReadLot2Thread
     {
-        private readonly ISqlSugarClient _db;
-        private readonly ISqlSugarClient _local_db;
-
-        public ReadLot2Thread(ISqlSugarClient db, ISqlSugarClient local_db)
-        {
-            _db = db;
-            _local_db = local_db;
-        }
-
         public void ReadThreadStart()
         {
             Thread t = new Thread(ReadTask);
-            t.Start((_db, _local_db));
+            t.Start();
         }
 
         static void ReadTask(Object dblist)
         {
-            var (db, local_db) = ((ISqlSugarClient, ISqlSugarClient))dblist;
             IConfiguration _configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
+
+
+            var db = new SqlSugarClient(new ConnectionConfig()
+            {
+                DbType = DbType.PostgreSQL,
+                ConnectionString = _configuration.GetValue<string>("TargetDbConnectionString"),
+                IsAutoCloseConnection = true
+            });
+            var local_db = new SqlSugarClient(new ConnectionConfig()
+            {
+                DbType = DbType.PostgreSQL,
+                ConnectionString = _configuration.GetValue<string>("LocalDbConnectionString"),
+                IsAutoCloseConnection = true
+            });
+
             string topic = _configuration.GetValue<string>("Topic");
-            List<string> patternlist = _configuration.GetValue<string>("PatternList").Split(",").ToList();
+            List<string> patternlist = _configuration.GetValue<string>("Lot2PatternList").Split(",").ToList();
             int product_startid = _configuration.GetValue<int>("ProductStartID");
             ISqlSugarClient _db = (ISqlSugarClient)db;
             ISqlSugarClient _local_db = (ISqlSugarClient)local_db;
@@ -40,16 +45,17 @@ namespace EInk.TaskThread
             {
                 try
                 {
-                    int max_productid = _local_db.Ado.GetInt("select max(product_id) from lot2lot3_info");
+                    //int max_productid = _local_db.Ado.GetInt("select max(product_id) from lot2lot3_info");
                     List<InitLot2Model> read_list = new List<InitLot2Model>();
-                    if (product_startid == 0)
-                    {
-                        read_list = _db.Queryable<InitLot2Model>().Where(x => x.id > max_productid).Where(x => (x.productno != null && x.station != null && x.pattern != null) && (x.result == "enOK" || x.result == "enNG")).OrderBy(x => x.id).Take(30).ToList();
-                    }
-                    else
-                    {
-                        read_list = _db.Queryable<InitLot2Model>().Where(x => x.id >= product_startid).Where(x => x.id > max_productid).Where(x => (x.productno != null && x.station != null && x.pattern != null) && (x.result == "enOK" || x.result == "enNG")).Take(60).OrderBy(x => x.id).Take(30).ToList();
-                    }
+                    read_list = _db.Queryable<InitLot2Model>().Where(x => x.id > product_startid).Where(x => (x.productno != null && x.station != null && x.pattern != null) && (x.result == "enOK" || x.result == "enNG")).OrderBy(x => x.id).Take(120).ToList();
+                    //if (product_startid == 0)
+                    //{
+                    //    read_list = _db.Queryable<InitLot2Model>().Where(x => x.id > max_productid).Where(x => (x.productno != null && x.station != null && x.pattern != null) && (x.result == "enOK" || x.result == "enNG")).OrderBy(x => x.id).Take(120).ToList();
+                    //}
+                    //else
+                    //{
+                    //    read_list = _db.Queryable<InitLot2Model>().Where(x => x.id >= product_startid).Where(x => x.id > max_productid).Where(x => (x.productno != null && x.station != null && x.pattern != null) && (x.result == "enOK" || x.result == "enNG")).Take(60).OrderBy(x => x.id).Take(120).ToList();
+                    //}
                     if (read_list != null && read_list.Count > 0)
                     {
                         try
@@ -57,6 +63,7 @@ namespace EInk.TaskThread
                             _local_db.Ado.BeginTran();
                             foreach (var read_lot2 in read_list)
                             {
+                                product_startid=read_lot2.id;
                                 if (string.IsNullOrEmpty(read_lot2.productno) || string.IsNullOrEmpty(read_lot2.station) || string.IsNullOrEmpty(read_lot2.result))
                                 {
                                     continue;
@@ -137,7 +144,8 @@ namespace EInk.TaskThread
                                         content = JsonConvert.SerializeObject(lot2Detail),
                                         create_time = DateTime.Now,
                                         product_no = read_lot2.productno,
-                                        product_id = read_lot2.id
+                                        product_id = read_lot2.id,
+                                        operation_time = read_lot2.created_at
                                     };
                                     _local_db.Insertable(lot2model).ExecuteCommand();
                                 }
@@ -180,6 +188,7 @@ namespace EInk.TaskThread
                                         }
                                         Lot2ModelList[0].is_send = send_flag ? 0 : 2;
                                         Lot2ModelList[0].product_id = read_lot2.id;
+                                        Lot2ModelList[0].operation_time = read_lot2.created_at;
                                         if (Lot2ModelList[0].is_send == 0)
                                         {
                                             if (string.IsNullOrEmpty(lot2Detail.slidesNumber))
@@ -306,14 +315,16 @@ namespace EInk.TaskThread
                                             content = JsonConvert.SerializeObject(lot2Detail),
                                             create_time = DateTime.Now,
                                             product_no = read_lot2.productno,
-                                            product_id = read_lot2.id
+                                            product_id = read_lot2.id,
+                                            operation_time = read_lot2.created_at
                                         };
                                         _local_db.Insertable(lot2model).ExecuteCommand();
                                     }
                                 }
-                                Thread.Sleep(1000);
+                                Thread.Sleep(200);
                             }
                             _local_db.Ado.CommitTran();
+                            _configuration.GetValue<int>("ProductStartID");
                         }
                         catch (Exception ex)
                         {

+ 10 - 12
EInk.Lot3/TaskThread/SendColourCastThread.cs

@@ -8,23 +8,21 @@ namespace EInk.TaskThread
 {
     public class SendColourCastThread
     {
-        private readonly ISqlSugarClient _db;
-
-        public SendColourCastThread(ISqlSugarClient db)
-        {
-            _db = db;
-        }
-
         public void SendThreadStart()
         {
             Thread t = new Thread(SendTask);
-            t.Start(_db);
+            t.Start();
         }
 
-        static void SendTask(Object db)
+        static void SendTask()
         {
-            ISqlSugarClient _db = (ISqlSugarClient)db;
             IConfiguration _configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
+            ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
+            {
+                DbType = DbType.PostgreSQL,
+                ConnectionString = _configuration.GetValue<string>("LocalDbConnectionString"),
+                IsAutoCloseConnection = true
+            });
             while (true)
             {
                 try
@@ -53,7 +51,7 @@ namespace EInk.TaskThread
                             {
                                 LogerHelper.RecordLogTxt("SendColourCastTask, MesApi2, " + rt_bl+ "," + rt_str + "," + unsend.content);
                             }
-                            Thread.Sleep(1000);
+                            Thread.Sleep(200);
                         }
                     }
                 }
@@ -63,7 +61,7 @@ namespace EInk.TaskThread
                 }
                 finally
                 {
-                    Thread.Sleep(10000);
+                    Thread.Sleep(5000);
                 }
             }
 

+ 11 - 13
EInk.Lot3/TaskThread/SendLot2Lot3Thread.cs

@@ -8,28 +8,26 @@ namespace EInk.TaskThread
 {
     public class SendLot2Lot3Thread
     {
-        private readonly ISqlSugarClient _db;
-
-        public SendLot2Lot3Thread(ISqlSugarClient db)
-        {
-            _db = db;
-        }
-
         public void SendThreadStart()
         {
             Thread t = new Thread(SendTask);
-            t.Start(_db);
+            t.Start();
         }
 
-        static void SendTask(Object db)
+        static void SendTask()
         {
-            ISqlSugarClient _db = (ISqlSugarClient)db;
             IConfiguration _configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json", optional: true, reloadOnChange: true).Build();
+            ISqlSugarClient _db = new SqlSugarClient(new ConnectionConfig()
+            {
+                DbType = DbType.PostgreSQL,
+                ConnectionString = _configuration.GetValue<string>("LocalDbConnectionString"),
+                IsAutoCloseConnection = true
+            });
             while (true)
             {
                 try
                 {
-                    List<Lot2Lot3Model> unsend_list = _db.Queryable<Lot2Lot3Model>().Where(x => x.is_send == 0).OrderBy(x => x.id).Take(60).ToList();
+                    List<Lot2Lot3Model> unsend_list = _db.Queryable<Lot2Lot3Model>().Where(x => x.is_send == 0).OrderBy(x => x.id).Take(120).ToList();
                     if (unsend_list != null && unsend_list.Count > 0)
                     {
                         foreach (var unsend in unsend_list)
@@ -53,7 +51,7 @@ namespace EInk.TaskThread
                             {
                                 LogerHelper.RecordLogTxt("SendLotTask, MesApi2, " + rt_bl+ "," + rt_str + "," + unsend.content);
                             }
-                            Thread.Sleep(1000);
+                            Thread.Sleep(200);
                         }
                     }
                 }
@@ -63,7 +61,7 @@ namespace EInk.TaskThread
                 }
                 finally
                 {
-                    Thread.Sleep(10000);
+                    Thread.Sleep(millisecondsTimeout: 10000);
                 }
             }
 

+ 17 - 0
EInk.Lot3/Tools/ConfigurationController.cs

@@ -0,0 +1,17 @@
+using EInk.Lot2Lot3.Models;
+using Microsoft.Extensions.Options;
+
+namespace EInk.Lot2Lot3.Tools
+{
+    public class ConfigurationController
+    {
+        private readonly IConfiguration Configuration;
+        private readonly AppearancePixelEquivalent appearancepixelequivalent;
+
+        public ConfigurationController(IConfiguration configuration, IOptions<AppearancePixelEquivalent> options)
+        {
+            Configuration = configuration;
+            appearancepixelequivalent = options.Value;
+        }
+    }
+}

+ 11 - 2
EInk.Lot3/appsettings.json

@@ -24,10 +24,19 @@
   "MesUrl": "http://eyzms.toc.eink.com:8088",
   "MesUrlTime": 30,
   "DaysAgo": 60,
-  "PatternList": "wht,dot",
   "Topic": "LOT2AOIData#04#04-2AOI01",
   "ReadLot2Thread": false,
   "SendLot2Lot3Thread": false,
   "SendColourCastThread": false,
-  "DeleteDBRecordThread": true
+  "DeleteDBRecordThread": true,
+  "Lot2PatternList": "wht,dot",
+  "Lot3AppearancePatternList": "PositiveAppearance,BackAppearance,BackFPC,PositiveFPC",
+  "Lot3ScreenPatternList": "F_Gray_PL1,F_Red_PL1,F_White_PL1,M_Gray_PL1,M_Red_PL1,M_White_PL1",
+  "AppearancePixelEquivalent": {
+    "enable": true,
+    "PositiveAppearance": 0.0332,
+    "BackAppearance": 0.0332,
+    "BackFPC": 0.02,
+    "PositiveFPC": 0.02
+  }
 }