baowei 5 mesi fa
parent
commit
d454d4398d

+ 14 - 75
EInk.Lot3/Controllers/Lot3Controller.cs

@@ -11,6 +11,7 @@ using System.Threading;
 using System.Text;
 using EInk.Dtos;
 using System.Reflection.Metadata;
+using Microsoft.AspNetCore.Mvc.Rendering;
 
 namespace EInk.Controllers
 {
@@ -25,26 +26,13 @@ namespace EInk.Controllers
         }
 
         [HttpPost("UploadLot3")]
-        public IActionResult Lot3Data(string Lot3Data)
+        public IActionResult Lot3Data([FromBody] Lot2Lot3Dto lot3Data)
         {
             try
             {
-                if (String.IsNullOrEmpty(Lot3Data))
-                {
-                    return Ok(ResultDto.Fail("Components is null"));
-                }
-                Lot2Lot3Dto lot3Dto = new Lot2Lot3Dto();
-                try
-                {
-                    lot3Dto = JsonConvert.DeserializeObject<Lot2Lot3Dto>(Lot3Data);
-                }
-                catch (Exception)
-                {
-                    return Ok(ResultDto.Fail("Incorrect Json format"));
-                }
                 try
                 {
-                    lot3Dto.Valid();
+                    lot3Data.Valid();
                 }
                 catch (Exception ex)
                 {
@@ -52,40 +40,17 @@ namespace EInk.Controllers
                 }
                 Lot2Lot3Model lot3model = new()
                 {
-                    lot_id = lot3Dto.id,
+                    lot_id = lot3Data.id,
                     is_send = 0,
-                    product_no = lot3Dto.slidesNumber,
-                    content = Lot3Data,
+                    product_no = lot3Data.slidesNumber,
+                    content = JsonConvert.SerializeObject(lot3Data),
                     create_time = DateTime.Now
                 };
                 //根据guid查看是否为重复插入
-                if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", lot3Dto.id)) > 0)
+                if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", lot3Data.id)) > 0)
                 {
                     lot3model.is_send = 3;
                 }
-                //else
-                //{
-                //    //校验是否有片号重复的数据
-                //    List<Lot2Lot3Model> lot_list = _db.Queryable<Lot2Lot3Model>().Where(x => x.product_no == lot3Dto.slidesNumber).OrderByDescending(x => x.id).ToList();
-                //    if (lot_list.Count > 0)
-                //    {
-                //        Lot2Lot3Dto lot3Dto_db = JsonConvert.DeserializeObject<Lot2Lot3Dto>(lot_list[0].content);
-                //        if (Convert.ToDateTime(lot3Dto.createTime) > Convert.ToDateTime(lot3Dto_db.createTime))
-                //        {
-                //            if (lot3Dto_db.result == "NG") lot3Dto.result = "NG";
-                //            foreach (var item in lot3Dto.itemCheckDatas)
-                //            {
-                //                lot3Dto_db.itemCheckDatas.Add(item);
-                //            }
-                //            lot3Dto.itemCheckDatas = lot3Dto_db.itemCheckDatas;
-                //            lot3model.content = JsonConvert.SerializeObject(lot3Dto);
-                //        }
-                //        else
-                //        {
-                //            lot3model.is_send = 3;
-                //        }
-                //    }
-                //}
                 _db.Insertable(lot3model).ExecuteCommand();
                 return Ok(ResultDto.Success());
             }
@@ -97,26 +62,13 @@ namespace EInk.Controllers
 
 
         [HttpPost("UploadColourCast")]
-        public IActionResult ColourCastData(string ColourCastData)
+        public IActionResult ColourCastData([FromBody] ColourCastDto ColourCastData)
         {
             try
             {
-                if (String.IsNullOrEmpty(ColourCastData))
-                {
-                    return Ok(ResultDto.Fail("Components is null"));
-                }
-                ColourCastDto colourcastDto = new ColourCastDto();
-                try
-                {
-                    colourcastDto = JsonConvert.DeserializeObject<ColourCastDto>(ColourCastData);
-                }
-                catch (Exception)
-                {
-                    return Ok(ResultDto.Fail("Incorrect Json format"));
-                }
                 try
                 {
-                    colourcastDto.Valid();
+                    ColourCastData.Valid();
                 }
                 catch (Exception ex)
                 {
@@ -124,30 +76,17 @@ namespace EInk.Controllers
                 };
                 ColourCastModel colourcastmodel = new()
                 {
-                    gid = colourcastDto.id,
-                    slidesNumber = colourcastDto.slidesNumber,
+                    gid = ColourCastData.id,
+                    slidesNumber = ColourCastData.slidesNumber,
                     is_send = 0,
-                    content = ColourCastData,
+                    content = JsonConvert.SerializeObject(ColourCastData),
                     create_time = DateTime.Now
                 };
                 //根据guid查看是否为重复插入
-                if (_db.Ado.GetInt(string.Format("select count(*) from colourcast_info where gid='{0}'", colourcastDto.id)) > 0)
+                if (_db.Ado.GetInt(string.Format("select count(*) from colourcast_info where gid='{0}'", ColourCastData.id)) > 0)
                 {
                     colourcastmodel.is_send = 3;
                 }
-                //List<ColourCastModel> colourcast_list = _db.Queryable<ColourCastModel>().Where(x => x.slidesNumber == colourcastDto.slidesNumber).OrderByDescending(x => x.id).ToList();
-                //if (colourcast_list.Count > 0)
-                //{
-                //    ColourCastDto colourcastDto_db = JsonConvert.DeserializeObject<ColourCastDto>(colourcast_list[0].content);
-                //    if (Convert.ToDateTime(colourcastDto.createTime) > Convert.ToDateTime(colourcastDto_db.createTime))
-                //    {
-                //        colourcastmodel.is_send = 0;
-                //    }
-                //    else
-                //    {
-                //        colourcastmodel.is_send = 3;
-                //    }
-                //}
                 _db.Insertable(colourcastmodel).ExecuteCommand();
                 return Ok(ResultDto.Success());
             }
@@ -159,7 +98,7 @@ namespace EInk.Controllers
 
 
         [HttpPost("UpdateDefectInfo")]
-        public IActionResult UpdateDefectInfo(IFormFile file)
+        public IActionResult UpdateDefectInfo([FromBody] IFormFile file)
         {
             if (file == null || file.Length == 0)
             {

+ 4 - 1
EInk.Lot3/Dtos/ColourCastDto.cs

@@ -24,7 +24,10 @@ namespace EInk.Dtos
             {
                 throw new Exception("Empty slidesNumber");
             }
-
+            if (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
+            {
+                throw new Exception("Empty createTime");
+            }
             try
             {
                 DateTime valid = Convert.ToDateTime(createTime);

+ 20 - 12
EInk.Lot3/Dtos/Lot2Lot3Dto.cs

@@ -12,22 +12,30 @@ namespace EInk.Dtos
         public string topic { get; set; }
         public string createTime { get; set; }
         public string result { get; set; }
-        public List<itemCheckData> itemCheckDatas { get; set; } = new List<itemCheckData>();
+        public List<itemCheckData>? itemCheckDatas { get; set; } = new List<itemCheckData>();
 
         public void Valid()
         {
-            if (String.IsNullOrEmpty(id.Trim()))
+            if (String.IsNullOrEmpty(id) || String.IsNullOrEmpty(id.Trim()))
             {
                 throw new Exception("Empty id");
             }
-            if (String.IsNullOrEmpty(slidesNumber.Trim()))
+            if (String.IsNullOrEmpty(slidesNumber) || String.IsNullOrEmpty(slidesNumber.Trim()))
             {
                 throw new Exception("Empty slidesNumber");
             }
-            if (String.IsNullOrEmpty(result.Trim()))
+            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 (String.IsNullOrEmpty(createTime) || String.IsNullOrEmpty(createTime.Trim()))
+            {
+                throw new Exception("Empty createTime");
+            }
             if (result!="NG"&&result!="OK")
             {
                 throw new Exception("Incorrect result");
@@ -53,9 +61,9 @@ namespace EInk.Dtos
         public string method { get; set; }
         public string pattern { get; set; }
         public string result { get; set; }
-        public string imagePath { get; set; }
-        public string detailImagePath { get; set; }
-        public List<detail> details { get; set; } = new List<detail>();
+        public string? imagePath { get; set; }
+        public string? detailImagePath { get; set; }
+        public List<detail>? details { get; set; } = new List<detail>();
         public void Valid()
         {
             if (String.IsNullOrEmpty(station) || String.IsNullOrEmpty(station.Trim()))
@@ -89,11 +97,11 @@ namespace EInk.Dtos
     {
         public string defectCode { get; set; }
         public string defectName { get; set; }
-        public string x { get; set; }
-        public string y { get; set; }
-        public string width { get; set; }
-        public string height { get; set; }
-        public string area { get; set; }
+        public string? x { get; set; }
+        public string? y { get; set; }
+        public string? width { get; set; }
+        public string? height { get; set; }
+        public string? area { get; set; }
         public void Valid()
         {
             if (String.IsNullOrEmpty(defectCode) || String.IsNullOrEmpty(defectCode.Trim()))

+ 1 - 1
EInk.Lot3/Models/ColourCastModel.cs

@@ -23,7 +23,7 @@ namespace EInk.Models
         [SugarColumn(ColumnName = "send_time")]
         public DateTime send_time { get; set; }
 
-        [SugarColumn(ColumnName = "content")]
+        [SugarColumn(ColumnName = "content", ColumnDataType = StaticConfig.CodeFirst_BigString)]
         public string content { get; set; }
 
     }

+ 4 - 3
EInk.Lot3/appsettings.json

@@ -9,7 +9,7 @@
   "Kestrel": {
     "EndPoints": {
       "Http": {
-        "Url": "http://localhost:8080"
+        "Url": "http://*:8080"
       }
       //"Https": {
       //  "Url": "https://localhost:8082"
@@ -18,7 +18,8 @@
   },
   "LocalDbConnectionString": "Host=127.0.0.1;Port=5432;Database=Lot2Lot3;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": "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,
@@ -28,5 +29,5 @@
   "ReadLot2Thread": false,
   "SendLot2Lot3Thread": false,
   "SendColourCastThread": false,
-  "DeleteDBRecordThread": true
+  "DeleteDBRecordThread": false
 }