2 Commity 90699e76d8 ... e457a94305

Autor SHA1 Wiadomość Data
  baowei e457a94305 Merge branch 'master' of http://www.likeplc.com:6001/baowei/Lot2Lot3 6 miesięcy temu
  baowei 960137d96c update7/22 7 miesięcy temu

+ 41 - 35
EInk.Lot3/Controllers/Lot3Controller.cs

@@ -58,34 +58,34 @@ namespace EInk.Controllers
                     content = Lot3Data,
                     create_time = DateTime.Now
                 };
-                //校验是否有id重复的数据
+                //根据guid查看是否为重复插入
                 if (_db.Ado.GetInt(string.Format("select count(*) from lot2lot3_info where lot_id='{0}'", lot3Dto.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;
-                        }
-                    }
-                }
+                //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());
             }
@@ -124,24 +124,30 @@ namespace EInk.Controllers
                 };
                 ColourCastModel colourcastmodel = new()
                 {
+                    gid = colourcastDto.id,
                     slidesNumber = colourcastDto.slidesNumber,
                     is_send = 0,
                     content = ColourCastData,
                     create_time = DateTime.Now
                 };
-                List<ColourCastModel> colourcast_list = _db.Queryable<ColourCastModel>().Where(x => x.slidesNumber == colourcastDto.slidesNumber).OrderByDescending(x => x.id).ToList();
-                if (colourcast_list.Count > 0)
+                //根据guid查看是否为重复插入
+                if (_db.Ado.GetInt(string.Format("select count(*) from colourcast_info where gid='{0}'", colourcastDto.id)) > 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;
-                    }
+                    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());
             }

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

@@ -4,6 +4,7 @@ namespace EInk.Dtos
 {
     public class ColourCastDto
     {
+        public string id { get; set; }
         public string slidesNumber { get; set; }
         public string createTime { get; set; }
         public string topic { get; set; }
@@ -14,7 +15,12 @@ namespace EInk.Dtos
         public int threshold { get; set; }
         public void Valid()
         {
-            if (String.IsNullOrEmpty(slidesNumber.Trim()))
+            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");
             }
@@ -28,17 +34,17 @@ namespace EInk.Dtos
                 throw new Exception("Incorrect createTime");
             }
 
-            if (String.IsNullOrEmpty(topic.Trim()))
+            if (String.IsNullOrEmpty(topic) || String.IsNullOrEmpty(topic.Trim()))
             {
                 throw new Exception("Empty topic");
             }
 
-            if (String.IsNullOrEmpty(pattern.Trim()))
+            if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim()))
             {
                 throw new Exception("Empty pattern");
             }
 
-            if (result != "en" && result != "ok")
+            if (String.IsNullOrEmpty(result) || (result != "NG" && result != "OK"))
             {
                 throw new Exception("Incorrect result");
             }

+ 28 - 27
EInk.Lot3/Dtos/Lot2Lot3Dto.cs

@@ -1,4 +1,5 @@
-using Microsoft.Extensions.FileSystemGlobbing.Internal;
+using EInk.Models;
+using Microsoft.Extensions.FileSystemGlobbing.Internal;
 using System.ComponentModel;
 using static System.Collections.Specialized.BitVector32;
 
@@ -57,19 +58,19 @@ namespace EInk.Dtos
         public List<detail> details { get; set; } = new List<detail>();
         public void Valid()
         {
-            if (String.IsNullOrEmpty(station.Trim()))
+            if (String.IsNullOrEmpty(station) || String.IsNullOrEmpty(station.Trim()))
             {
                 throw new Exception("Empty station");
             }
-            if (String.IsNullOrEmpty(method.Trim()))
+            if (String.IsNullOrEmpty(method) || String.IsNullOrEmpty(method.Trim()))
             {
                 throw new Exception("Empty method");
             }
-            if (String.IsNullOrEmpty(pattern.Trim()))
+            if (String.IsNullOrEmpty(pattern) || String.IsNullOrEmpty(pattern.Trim()))
             {
                 throw new Exception("Empty pattern");
             }
-            if (String.IsNullOrEmpty(result.Trim()))
+            if (String.IsNullOrEmpty(result) || String.IsNullOrEmpty(result.Trim()))
             {
                 throw new Exception("Empty result");
             }
@@ -95,34 +96,34 @@ namespace EInk.Dtos
         public string area { get; set; }
         public void Valid()
         {
-            if (String.IsNullOrEmpty(defectCode.Trim()))
+            if (String.IsNullOrEmpty(defectCode) || String.IsNullOrEmpty(defectCode.Trim()))
             {
                 throw new Exception("Empty defectCode");
             }
-            if (String.IsNullOrEmpty(defectName.Trim()))
+            if (String.IsNullOrEmpty(defectName) || String.IsNullOrEmpty(defectName.Trim()))
             {
                 throw new Exception("Empty defectName");
             }
-            if (String.IsNullOrEmpty(x.Trim()))
-            {
-                throw new Exception("Empty x");
-            }
-            if (String.IsNullOrEmpty(y.Trim()))
-            {
-                throw new Exception("Empty y");
-            }
-            if (String.IsNullOrEmpty(width.Trim()))
-            {
-                throw new Exception("Empty width");
-            }
-            if (String.IsNullOrEmpty(height.Trim()))
-            {
-                throw new Exception("Empty height");
-            }
-            if (String.IsNullOrEmpty(area.Trim()))
-            {
-                throw new Exception("Empty area");
-            }
+            //if (x == null || String.IsNullOrEmpty(x.Trim()))
+            //{
+            //    throw new Exception("Empty x");
+            //}
+            //if (y == null || String.IsNullOrEmpty(y.Trim()))
+            //{
+            //    throw new Exception("Empty y");
+            //}
+            //if (width == null || String.IsNullOrEmpty(width.Trim()))
+            //{
+            //    throw new Exception("Empty width");
+            //}
+            //if (height == null || String.IsNullOrEmpty(height.Trim()))
+            //{
+            //    throw new Exception("Empty height");
+            //}
+            //if (area == null || String.IsNullOrEmpty(area.Trim()))
+            //{
+            //    throw new Exception("Empty area");
+            //}
 
             //try
             //{

+ 3 - 0
EInk.Lot3/Models/ColourCastModel.cs

@@ -11,6 +11,9 @@ namespace EInk.Models
         [SugarColumn(ColumnName = "slidesNumber", ColumnDataType = StaticConfig.CodeFirst_BigString)]
         public string slidesNumber { get; set; }
 
+        [SugarColumn(ColumnName = "gid", ColumnDataType = StaticConfig.CodeFirst_BigString)]
+        public string gid { get; set; }
+
         [SugarColumn(ColumnName = "is_send")]
         public int is_send { get; set; }
 

+ 1 - 0
EInk.Lot3/Startup.cs

@@ -2,6 +2,7 @@
 using Microsoft.AspNetCore.Builder;
 using SqlSugar;
 using EInk.Models;
+using EInk.Tools;
 
 namespace EInk.Lot2Lot3
 {

+ 11 - 0
EInk.Lot3/appsettings.json

@@ -6,6 +6,17 @@
     }
   },
   "AllowedHosts": "*",
+  "Kestrel": {
+    "EndPoints": {
+      "Http": {
+        "Url": "http://localhost:8081"
+      }
+
+      //"Https": {
+      //  "Url": "https://localhost:8082"
+      //}
+    }
+  },
   "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;",

+ 18 - 0
EInk.Lot3/web.config

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <location path="." inheritInChildApplications="false">
+    <system.webServer>
+      <!--允许上传文件长度,单位字节-->
+      <handlers>
+        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
+      </handlers>
+      <aspNetCore processPath="dotnet" arguments=".\EInk.Lot2Lot3.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
+      <security>
+         <requestFiltering>
+           <requestLimits maxQueryString ="20971520"/>
+         </requestFiltering>
+      </security>
+    </system.webServer>
+  </location>
+</configuration>
+<!--ProjectGuid: 0c0961a1-494f-4ffc-82b9-1623aa58f174-->