林豪 左 2 rokov pred
rodič
commit
376c44ed15
78 zmenil súbory, kde vykonal 692 pridanie a 381 odobranie
  1. 1 0
      ServiceCenter/ServiceCenter.csproj
  2. 1 1
      ServiceCenter/SqlSugars/SqlSugarHelper.cs
  3. 3 7
      SqlSugar.BzTDengineCore/STable.cs
  4. 1 2
      SqlSugar.BzTDengineCore/TDengine/CodeFirst/TDengineCodeFirst.cs
  5. 1 3
      SqlSugar.BzTDengineCore/TDengine/DbBind/TDengineDbBind.cs
  6. 1 1
      SqlSugar.BzTDengineCore/TDengine/DbFirst/TDengineDbFirst.cs
  7. 11 12
      SqlSugar.BzTDengineCore/TDengine/DbMaintenance/TDengineDbMaintenance.cs
  8. 2 4
      SqlSugar.BzTDengineCore/TDengine/Insertable/TDengineInserttable.cs
  9. 1 1
      SqlSugar.BzTDengineCore/TDengine/Queryable/TDengineSqlQueryable.cs
  10. 7 33
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineBuilder.cs
  11. 1 1
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineDeleteBuilder.cs
  12. 4 7
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineExpressionContext.cs
  13. 1 1
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineFastBuilder.cs
  14. 5 18
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineInsertBuilder.cs
  15. 1 2
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineQueryBuilder.cs
  16. 1 1
      SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineUpdateBuilder.cs
  17. 4 7
      SqlSugar.BzTDengineCore/TDengine/TDengineProvider.cs
  18. 3 6
      SqlSugar.BzTDengineCore/TDengineDataAdapter.cs
  19. 1 1
      SqlSugar.BzTDengineCore/Tools/DateTime16.cs
  20. 1 1
      SqlSugar.BzTDengineCore/Tools/DateTime19.cs
  21. 1 1
      SqlSugar.BzTDengineCore/Tools/ErrorMessage.cs
  22. 1 1
      SqlSugar.BzTDengineCore/Tools/FileHelper.cs
  23. 1 1
      SqlSugar.BzTDengineCore/Tools/UtilConstants.cs
  24. 6 6
      SqlSugar.BzTDengineCore/Tools/UtilExtensions.cs
  25. 16 9
      SqlSugar.BzTDengineCore/Tools/UtilMethods.cs
  26. 13 10
      SqlSugar.BzTDengineCore/Tools/ValidateExtensions.cs
  27. 2 1
      WCS.Core/DataBlock.cs
  28. 9 11
      WCS.Core/PLC.cs
  29. 3 0
      WCS.Core/ProtocolProxyBase.cs
  30. 2 3
      WCS.Core/System.cs
  31. 1 0
      WCS.Core/World.cs
  32. 9 0
      WCS.Service/Worker.cs
  33. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/BCR/WCS_BCR80.cs
  34. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/BCR/WCS_BCR81.cs
  35. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/BCR/WCS_BCR83.cs
  36. 16 16
      业务工程/分拣库/WCS.Entity.Protocol/DataStructure/StationData.cs
  37. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/RGV/WCS_RGV520.cs
  38. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/RGV/WCS_RGV521.cs
  39. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot520.cs
  40. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot521.cs
  41. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot522.cs
  42. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot530.cs
  43. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot531.cs
  44. 0 60
      业务工程/分拣库/WCS.Entity.Protocol/SRM/SRM520.cs
  45. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/SRM/WCS_SRM520.cs
  46. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/SRM/WCS_SRM521.cs
  47. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/SRM/WCS_SRM537.cs
  48. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station520.cs
  49. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station521.cs
  50. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station523.cs
  51. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station524.cs
  52. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station525.cs
  53. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station90.cs
  54. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station91.cs
  55. 20 0
      业务工程/分拣库/WCS.Entity.Protocol/TDengineBaseEntity.cs
  56. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss520.cs
  57. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss521.cs
  58. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss523.cs
  59. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss530.cs
  60. 4 2
      业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss531.cs
  61. 2 2
      业务工程/分拣库/WCS.WorkEngineering/Extensions/DeviceExtension.cs
  62. 172 13
      业务工程/分拣库/WCS.WorkEngineering/ProtocolProxy.cs
  63. 120 22
      业务工程/分拣库/WCS.WorkEngineering/Systems/DataCollectionSysyem.cs
  64. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/DeviceWriteSystem.cs
  65. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/GetDeviceSystem.cs
  66. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/NoInteractionSystems.cs
  67. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/SrmSystems.cs
  68. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/UpLoadSystems.cs
  69. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/一楼叠盘机入库.cs
  70. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/分拣支线/环形库分流点.cs
  71. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/机台叫料生成AGV任务.cs
  72. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架.cs
  73. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架缓存放行点.cs
  74. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/机械臂cs.cs
  75. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/环形库码垛区补空托盘任务生成.cs
  76. 1 1
      业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/环形库码垛结束.cs
  77. 40 53
      业务工程/分拣库/WCS.WorkEngineering/WorkStart.cs
  78. 94 0
      业务工程/分拣库/WCS.WorkEngineering/数据采集.cs

+ 1 - 0
ServiceCenter/ServiceCenter.csproj

@@ -24,6 +24,7 @@
   </ItemGroup>
   
   <ItemGroup>
+    <ProjectReference Include="..\SqlSugar.BzTDengineCore\SqlSugar.BzTDengineCore.csproj" />
     <ProjectReference Include="..\WCS.Core\WCS.Core.csproj" />
     <ProjectReference Include="..\WCS.Entity\WCS.Entity.csproj" />
   </ItemGroup>

+ 1 - 1
ServiceCenter/SqlSugars/SqlSugarHelper.cs

@@ -87,7 +87,7 @@ namespace ServiceCenter.SqlSugars
         {
             get
             {
-                if (_PLC == "") throw new Exception("请调用[SqlSugarHelper.SetDlog]方法设置默认数据库连接");
+                if (_PLC == "") throw new Exception("请调用[SqlSugarHelper.SetPLC]方法设置默认数据库连接");
                 if (_Db == null) throw new Exception("请调用[SqlSugarHelper.SetDb]方法设置设置数据库连接");
                 return _Db.GetConnectionScope(_PLC);
             }

+ 3 - 7
SqlSugar.BzTDengineCore/STable.cs

@@ -1,12 +1,8 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace SqlSugar.TDengine
+namespace SqlSugar.BzTDengineCore
 {
     public class STable
     {
-        [SugarColumn(IsOnlyIgnoreInsert =true ,IsOnlyIgnoreUpdate =true)]
-        public string TagsTypeId { get; set; } 
+        [SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)]
+        public string TagsTypeId { get; set; }
     }
 }

+ 1 - 2
SqlSugar.BzTDengineCore/TDengine/CodeFirst/TDengineCodeFirst.cs

@@ -1,11 +1,10 @@
 using SqlSugar;
-using SqlSugar.TDengine;
 using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
 
-namespace SqlSugar.BzTDengineCore.TDengine.CodeFirst
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineCodeFirst : CodeFirstProvider
     {

+ 1 - 3
SqlSugar.BzTDengineCore/TDengine/DbBind/TDengineDbBind.cs

@@ -1,11 +1,9 @@
 using SqlSugar;
-using SqlSugar.BzTDengineCore.Tools;
-using SqlSugar.TDengine;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 
-namespace SqlSugar.BzTDengineCore.TDengine.DbBind
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineDbBind : DbBindProvider
     {

+ 1 - 1
SqlSugar.BzTDengineCore/TDengine/DbFirst/TDengineDbFirst.cs

@@ -1,4 +1,4 @@
-namespace SqlSugar.BzTDengineCore.TDengine.DbFirst
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineDbFirst : DbFirstProvider
     {

+ 11 - 12
SqlSugar.BzTDengineCore/TDengine/DbMaintenance/TDengineDbMaintenance.cs

@@ -1,11 +1,10 @@
 using SqlSugar;
-using SqlSugar.TDengine;
 using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
 
-namespace SqlSugar.BzTDengineCore.TDengine.DbMaintenance
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineDbMaintenance : DbMaintenanceProvider
     {
@@ -315,9 +314,9 @@ namespace SqlSugar.BzTDengineCore.TDengine.DbMaintenance
         public override bool AddColumnRemark(string columnName, string tableName, string description)
         {
             tableName = SqlBuilder.GetTranslationTableName(tableName);
-            string sql = string.Format(AddColumnRemarkSql, SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), tableName, description);
-            Context.Ado.ExecuteCommand(sql);
-            return true;
+            string sql = string.Format(AddColumnRemarkSql, SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), tableName, "");
+            //Context.Ado.ExecuteCommand(sql);
+            return false;
         }
 
         public override bool AddTableRemark(string tableName, string description)
@@ -380,7 +379,7 @@ namespace SqlSugar.BzTDengineCore.TDengine.DbMaintenance
             {
                 foreach (var item in columns)
                 {
-                    if (item.DbColumnName.Equals("GUID", StringComparison.CurrentCultureIgnoreCase) && item.Length == 0)
+                    if (item.DbColumnName != null && item.DbColumnName.Equals("GUID", StringComparison.CurrentCultureIgnoreCase) && item.Length == 0)
                     {
                         item.Length = 10;
                     }
@@ -401,7 +400,7 @@ namespace SqlSugar.BzTDengineCore.TDengine.DbMaintenance
         {
             List<string> columnArray = new List<string>();
             Check.Exception(columns.IsNullOrEmpty(), "No columns found ");
-            foreach (var item in columns)
+            foreach (var item in columns.Where(x => x.DbColumnName != null))
             {
                 string columnName = item.DbColumnName;
                 string dataType = item.DataType;
@@ -448,12 +447,12 @@ namespace SqlSugar.BzTDengineCore.TDengine.DbMaintenance
                 string addItem = string.Format(CreateTableColumn, SqlBuilder.GetTranslationColumnName(columnName.ToLower(isAutoToLowerCodeFirst)), dataType, dataSize, null, primaryKey, "");
                 columnArray.Add(addItem);
             }
-            string tableString = string.Format(CreateTableSql, SqlBuilder.GetTranslationTableName("STable_" + tableName.ToLower(isAutoToLowerCodeFirst)), string.Join(",\r\n", columnArray));
+            string tableString = string.Format(CreateTableSql, SqlBuilder.GetTranslationTableName(tableName.ToLower(isAutoToLowerCodeFirst)), string.Join(",\r\n", columnArray));
             var childTableName = SqlBuilder.GetTranslationTableName(tableName.ToLower(isAutoToLowerCodeFirst));
-            var stableName = SqlBuilder.GetTranslationTableName("STable_" + tableName.ToLower(isAutoToLowerCodeFirst));
-            Context.Ado.ExecuteCommand(tableString);
-            var createChildSql = $"CREATE TABLE IF NOT EXISTS     {childTableName} USING {stableName} TAGS('default')";
-            Context.Ado.ExecuteCommand(createChildSql);
+            var stableName = SqlBuilder.GetTranslationTableName(tableName.ToLower(isAutoToLowerCodeFirst));
+            //Context.Ado.ExecuteCommand(tableString);
+            //var createChildSql = $"CREATE TABLE IF NOT EXISTS     {childTableName} USING {stableName} TAGS('default')";
+            //Context.Ado.ExecuteCommand(createChildSql);
             return tableString;
         }
 

+ 2 - 4
SqlSugar.BzTDengineCore/TDengine/Insertable/TDengineInserttable.cs

@@ -1,11 +1,9 @@
-using SqlSugar;
-using SqlSugar.TDengine;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 
-namespace SqlSugar.BzTDengineCore.TDengine.Insertable
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineInsertable<T> : InsertableProvider<T> where T : class, new()
     {

+ 1 - 1
SqlSugar.BzTDengineCore/TDengine/Queryable/TDengineSqlQueryable.cs

@@ -1,4 +1,4 @@
-namespace SqlSugar.BzTDengineCore.TDengine.Queryable
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineQueryable<T> : QueryableProvider<T>
     {

+ 7 - 33
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineBuilder.cs

@@ -1,43 +1,17 @@
-using SqlSugar.BzTDengineCore.Tools;
-using SqlSugar.TDengine;
-using System;
+using System;
 using System.Linq;
 
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineBuilder : SqlBuilderProvider
     {
-        public override string SqlTranslationLeft
-        {
-            get
-            {
-                return "`";
-            }
-        }
+        public override string SqlTranslationLeft => "`";
 
-        public override string SqlTranslationRight
-        {
-            get
-            {
-                return "`";
-            }
-        }
+        public override string SqlTranslationRight => "`";
 
-        public override string SqlDateNow
-        {
-            get
-            {
-                return "current_date";
-            }
-        }
+        public override string SqlDateNow => "current_date";
 
-        public override string FullSqlDateNow
-        {
-            get
-            {
-                return " now() ";
-            }
-        }
+        public override string FullSqlDateNow => " now() ";
 
         public bool isAutoToLower
         {
@@ -130,7 +104,7 @@ namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
             if (columnInfo != null)
             {
                 var cTypeName = Context.Ado.DbBind.GetCsharpTypeNameByDbTypeName(columnInfo.DataType);
-                var value = UtilMethods.GetTypeByTypeName(cTypeName);
+                var value = SqlSugar.UtilMethods.GetTypeByTypeName(cTypeName);
                 if (value != null)
                 {
                     var key = "GetNullType_" + tableName + columnName;

+ 1 - 1
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineDeleteBuilder.cs

@@ -1,4 +1,4 @@
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineDeleteBuilder : DeleteBuilder
     {

+ 4 - 7
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineExpressionContext.cs

@@ -1,10 +1,7 @@
-using SqlSugar;
-using SqlSugar.BzTDengineCore.Tools;
-using SqlSugar.TDengine;
-using System;
+using System;
 using System.Linq;
 
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineExpressionContext : ExpressionContext, ILambdaExpressions
     {
@@ -434,7 +431,7 @@ namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
 
         public override string JsonArrayAny(MethodCallExpressionModel model)
         {
-            if (UtilMethods.IsNumber(model.Args[1].MemberValue.GetType().Name))
+            if (SqlSugar.UtilMethods.IsNumber(model.Args[1].MemberValue.GetType().Name))
             {
                 return $" {model.Args[0].MemberName}::jsonb @> '[{model.Args[1].MemberValue.ObjToStringNoTrim().ToSqlFilter()}]'::jsonb";
             }
@@ -446,7 +443,7 @@ namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
 
         public override string JsonListObjectAny(MethodCallExpressionModel model)
         {
-            if (UtilMethods.IsNumber(model.Args[2].MemberValue.GetType().Name))
+            if (SqlSugar.UtilMethods.IsNumber(model.Args[2].MemberValue.GetType().Name))
             {
                 return $" {model.Args[0].MemberName}::jsonb @> '[{{\"{model.Args[1].MemberValue}\":{model.Args[2].MemberValue}}}]'::jsonb";
             }

+ 1 - 1
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineFastBuilder.cs

@@ -4,7 +4,7 @@ using System.Collections.Generic;
 using System.Data;
 using System.Threading.Tasks;
 
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineFastBuilder : FastBuilder, IFastBuilder
     {

+ 5 - 18
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineInsertBuilder.cs

@@ -1,11 +1,9 @@
 using SqlSugar;
-using SqlSugar.BzTDengineCore.Tools;
-using SqlSugar.TDengine;
 using System;
 using System.Linq;
 using System.Text;
 
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineInsertBuilder : InsertBuilder
     {
@@ -13,20 +11,8 @@ namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
         {
             get
             {
-                if (IsReturnIdentity)
-                {
-                    return @"INSERT INTO {0}
-           ({1})
-     VALUES
-           ({2}) ";
-                }
-                else
-                {
-                    return @"INSERT INTO {0}
-           ({1})
-     VALUES
-           ({2})";
-                }
+                if (IsReturnIdentity) return @"INSERT INTO {0} USING {1} TAGS ('1') ({2}) VALUES ({3})";
+                else return @"INSERT INTO {0} USING {1} TAGS ('1') ({2}) VALUES ({3})";
             }
         }
 
@@ -53,7 +39,8 @@ namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
             {
                 string columnParametersString = string.Join(",", DbColumnInfoList.Select(it => base.GetDbColumn(it, Builder.SqlParameterKeyWord + it.DbColumnName)));
                 ActionMinDate();
-                return string.Format(SqlTemplate, GetTableNameString, columnsString, columnParametersString);
+                var tName = EntityInfo.EntityName.ToLower() + "_" + DbColumnInfoList.First(it => it.DbColumnName == "Code").Value;
+                return string.Format(SqlTemplate, tName, EntityInfo.EntityName.ToLower(), columnsString, columnParametersString);
             }
             else
             {

+ 1 - 2
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineQueryBuilder.cs

@@ -1,10 +1,9 @@
 using SqlSugar;
-using SqlSugar.TDengine;
 using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
 
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public partial class TDengineQueryBuilder : QueryBuilder
     {

+ 1 - 1
SqlSugar.BzTDengineCore/TDengine/SqlBuilder/TDengineUpdateBuilder.cs

@@ -2,7 +2,7 @@
 using System.Collections.Generic;
 using System.Linq;
 
-namespace SqlSugar.BzTDengineCore.TDengine.SqlBuilder
+namespace SqlSugar.BzTDengineCore
 {
     public class TDengineUpdateBuilder : UpdateBuilder
     {

+ 4 - 7
SqlSugar.BzTDengineCore/TDengine/TDengineProvider.cs

@@ -1,12 +1,9 @@
-using SqlSugar;
-using SqlSugar.BzTDengineCore.Tools;
-using SqlSugar.TDengine;
-using SqlSugar.TDengineAdo;
+using SqlSugar.TDengineAdo;
 using System;
 using System.Data;
 using System.Data.Common;
 
-namespace SqlSugar.BzTDengineCore.TDengine
+namespace SqlSugar.BzTDengineCore
 {
     public partial class TDengineProvider : AdoProvider
     {
@@ -57,7 +54,7 @@ namespace SqlSugar.BzTDengineCore.TDengine
 
         public override IDataAdapter GetAdapter()
         {
-            return new TDengineCore.TDengineDataAdapter();
+            return new TDengineDataAdapter();
         }
 
         public override DbCommand GetCommand(string sql, SugarParameter[] parameters)
@@ -80,7 +77,7 @@ namespace SqlSugar.BzTDengineCore.TDengine
 
         public override void SetCommandToAdapter(IDataAdapter dataAdapter, DbCommand command)
         {
-            ((TDengineCore.TDengineDataAdapter)dataAdapter).SelectCommand = (TDengineCommand)command;
+            ((TDengineDataAdapter)dataAdapter).SelectCommand = (TDengineCommand)command;
         }
 
         public static bool _IsIsNanosecond { get; set; }

+ 3 - 6
SqlSugar.BzTDengineCore/TDengineDataAdapter.cs

@@ -1,9 +1,9 @@
 using SqlSugar.TDengineAdo;
 using System;
-using System.Data.Common;
 using System.Data;
+using System.Data.Common;
 
-namespace SqlSugar.TDengineCore
+namespace SqlSugar.BzTDengineCore
 {
     /// <summary>
     /// 数据填充器
@@ -25,7 +25,6 @@ namespace SqlSugar.TDengineCore
 
         public TDengineDataAdapter()
         {
-
         }
 
         /// <summary>
@@ -128,7 +127,6 @@ namespace SqlSugar.TDengineCore
                         {
                             columns.Add(new DataColumn(name + i, dr.GetFieldType(i)));
                         }
-
                     }
 
                     while (dr.Read())
@@ -144,12 +142,11 @@ namespace SqlSugar.TDengineCore
                     ds.Tables.Add(dt);
                 } while (dr.NextResult());
             }
-        } 
+        }
 
         public DataTable[] FillSchema(DataSet dataSet, SchemaType schemaType)
         {
             throw new NotImplementedException();
         }
-         
     }
 }

+ 1 - 1
SqlSugar.BzTDengineCore/Tools/DateTime16.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Data;
 
-namespace SqlSugar.BzTDengineCore.Tools
+namespace SqlSugar.BzTDengineCore
 {
     public class DateTime16 : ISugarDataConverter
     {

+ 1 - 1
SqlSugar.BzTDengineCore/Tools/DateTime19.cs

@@ -1,7 +1,7 @@
 using System;
 using System.Data;
 
-namespace SqlSugar.BzTDengineCore.Tools
+namespace SqlSugar.BzTDengineCore
 {
     internal enum Date19
     {

+ 1 - 1
SqlSugar.BzTDengineCore/Tools/ErrorMessage.cs

@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 
-namespace SqlSugar.BzTDengineCore.Tools
+namespace SqlSugar.BzTDengineCore
 {
     internal static partial class ErrorMessage
     {

+ 1 - 1
SqlSugar.BzTDengineCore/Tools/FileHelper.cs

@@ -2,7 +2,7 @@
 using System.IO;
 using System.Text;
 
-namespace SqlSugar.BzTDengineCore.Tools
+namespace SqlSugar.BzTDengineCore
 {
     internal class FileHelper
     {

+ 1 - 1
SqlSugar.BzTDengineCore/Tools/UtilConstants.cs

@@ -2,7 +2,7 @@
 using System.Collections.Generic;
 using System.Dynamic;
 
-namespace SqlSugar.BzTDengineCore.Tools
+namespace SqlSugar.BzTDengineCore
 {
     internal static class UtilConstants
     {

+ 6 - 6
SqlSugar.BzTDengineCore/Tools/UtilExtensions.cs

@@ -1,8 +1,6 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-namespace SqlSugar.TDengine
+
+namespace SqlSugar.BzTDengineCore
 {
     /// <summary>
     ///Common Extensions for external users
@@ -14,14 +12,16 @@ namespace SqlSugar.TDengine
             if (thisValue != null) return thisValue.ToString();
             return "";
         }
-        public static string ToLower(this string value, bool isLower) 
+
+        public static string ToLower(this string value, bool isLower)
         {
-            if (isLower) 
+            if (isLower)
             {
                 return value.ObjToString().ToLower();
             }
             return value.ObjToString();
         }
+
         public static int ObjToInt(this object thisValue)
         {
             int reval = 0;

+ 16 - 9
SqlSugar.BzTDengineCore/Tools/UtilMethods.cs

@@ -1,8 +1,6 @@
-using SqlSugar.BzTDengineCore.Tools;
-using System;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel;
-using System.Data;
 using System.Diagnostics;
 using System.Globalization;
 using System.Linq;
@@ -13,7 +11,7 @@ using System.Security.Cryptography;
 using System.Text;
 using System.Text.RegularExpressions;
 
-namespace SqlSugar.TDengine
+namespace SqlSugar.BzTDengineCore
 {
     public class UtilMethods
     {
@@ -30,6 +28,7 @@ namespace SqlSugar.TDengine
                 return new DateTimeOffset(dateTime.ToUniversalTime()).ToUnixTimeMilliseconds();
             }
         }
+
         internal static DateTime GetMinDate(ConnectionConfig currentConnectionConfig)
         {
             if (currentConnectionConfig.MoreSettings == null)
@@ -45,6 +44,7 @@ namespace SqlSugar.TDengine
                 return currentConnectionConfig.MoreSettings.DbMinDate.Value;
             }
         }
+
         internal static DateTime ConvertFromDateTimeOffset(DateTimeOffset dateTime)
         {
             if (dateTime.Offset.Equals(TimeSpan.Zero))
@@ -83,6 +83,7 @@ namespace SqlSugar.TDengine
             }
             return value;
         }
+
         public static bool IsAnyAsyncMethod(StackFrame[] methods)
         {
             bool isAsync = false;
@@ -130,7 +131,6 @@ namespace SqlSugar.TDengine
 
         public static StackTraceInfo GetStackTrace()
         {
-
             StackTrace st = new StackTrace(true);
             StackTraceInfo info = new StackTraceInfo();
             info.MyStackTraceList = new List<StackTraceInfoItem>();
@@ -164,11 +164,13 @@ namespace SqlSugar.TDengine
         {
             return (T)To(value, typeof(T));
         }
+
         internal static Type GetUnderType(Type oldType)
         {
             Type type = Nullable.GetUnderlyingType(oldType);
             return type == null ? oldType : type;
         }
+
         public static string ReplaceSqlParameter(string itemSql, SugarParameter itemParameter, string newName)
         {
             itemSql = Regex.Replace(itemSql, string.Format(@"{0} ", "\\" + itemParameter.ParameterName), newName + " ", RegexOptions.IgnoreCase);
@@ -183,6 +185,7 @@ namespace SqlSugar.TDengine
             itemSql = Regex.Replace(itemSql, string.Format(@"{0}\|\|", "\\" + itemParameter.ParameterName), newName + "||", RegexOptions.IgnoreCase);
             return itemSql;
         }
+
         internal static Type GetRootBaseType(Type entityType)
         {
             var baseType = entityType.BaseType;
@@ -193,7 +196,6 @@ namespace SqlSugar.TDengine
             return baseType;
         }
 
-
         internal static Type GetUnderType(PropertyInfo propertyInfo, ref bool isNullable)
         {
             Type unType = Nullable.GetUnderlyingType(propertyInfo.PropertyType);
@@ -220,6 +222,7 @@ namespace SqlSugar.TDengine
             Type unType = Nullable.GetUnderlyingType(type);
             return unType != null;
         }
+
         //internal static T IsNullReturnNew<T>(T returnObj) where T : new()
         //{
         //    if (returnObj.IsNullOrEmpty())
@@ -303,11 +306,11 @@ namespace SqlSugar.TDengine
             {
                 return x => Convert.ToInt64(x);
             }
-            else if (value is DateTime|| value is DateTime?)
+            else if (value is DateTime || value is DateTime?)
             {
                 return x => Convert.ToDateTime(x);
             }
-            else if (value is bool||value is bool?)
+            else if (value is bool || value is bool?)
             {
                 return x => Convert.ToBoolean(x);
             }
@@ -320,7 +323,7 @@ namespace SqlSugar.TDengine
             {
                 return null;
             }
-            else 
+            else
             {
                 return value.GetType().Name;
             }
@@ -351,10 +354,12 @@ namespace SqlSugar.TDengine
         {
             return Convert.ToInt64(string.Join("", bytes).PadRight(20, '0'));
         }
+
         public static object GetPropertyValue<T>(T t, string PropertyName)
         {
             return t.GetType().GetProperty(PropertyName).GetValue(t, null);
         }
+
         internal static string GetMD5(string myString)
         {
             MD5 md5 = new MD5CryptoServiceProvider();
@@ -395,6 +400,7 @@ namespace SqlSugar.TDengine
 
             return string.Join("", splitChars);
         }
+
         public static string ConvertStringToNumbers(string value)
         {
             StringBuilder sb = new StringBuilder();
@@ -478,6 +484,7 @@ namespace SqlSugar.TDengine
             }
             return dic;
         }
+
         //public static object ConvertDataByTypeName(string ctypename,string value)
         //{
         //    var item = new ConditionalModel() {

+ 13 - 10
SqlSugar.BzTDengineCore/Tools/ValidateExtensions.cs

@@ -1,10 +1,9 @@
-using SqlSugar.BzTDengineCore.Tools;
-using System;
+using System;
 using System.Collections.Generic;
 using System.Linq;
-using System.Text;
 using System.Text.RegularExpressions;
-namespace SqlSugar.TDengine
+
+namespace SqlSugar.BzTDengineCore
 {
     internal static class ValidateExtensions
     {
@@ -39,7 +38,7 @@ namespace SqlSugar.TDengine
             if (thisValue == null) return true;
             return thisValue == Guid.Empty;
         }
-  
+
         public static bool IsNullOrEmpty(this Guid thisValue)
         {
             if (thisValue == null) return true;
@@ -64,7 +63,7 @@ namespace SqlSugar.TDengine
             return true;
         }
 
-        public static bool IsValuable(this IEnumerable<KeyValuePair<string,string>> thisValue)
+        public static bool IsValuable(this IEnumerable<KeyValuePair<string, string>> thisValue)
         {
             if (thisValue == null || thisValue.Count() == 0) return false;
             return true;
@@ -94,6 +93,7 @@ namespace SqlSugar.TDengine
             double outValue = 0;
             return double.TryParse(thisValue.ToString(), out outValue);
         }
+
         public static bool IsGuid(this object thisValue)
         {
             if (thisValue == null) return false;
@@ -124,7 +124,6 @@ namespace SqlSugar.TDengine
         {
             if (thisValue == null) return false;
             return System.Text.RegularExpressions.Regex.IsMatch(thisValue.ToString(), @"^(\(\d{3,4}\)|\d{3,4}-|\s)?\d{8}$");
-
         }
 
         public static bool IsIDcard(this object thisValue)
@@ -145,29 +144,33 @@ namespace SqlSugar.TDengine
             Regex reg = new Regex(pattern);
             return reg.IsMatch(thisValue.ToString());
         }
+
         public static bool IsAnonymousType(this Type type)
         {
             string typeName = type.Name;
             return typeName.Contains("<>") && typeName.Contains("__") && typeName.Contains("AnonymousType");
         }
+
         public static bool IsCollectionsList(this string thisValue)
         {
-            return (thisValue + "").StartsWith("System.Collections.Generic.List")|| (thisValue + "").StartsWith("System.Collections.Generic.IEnumerable");
+            return (thisValue + "").StartsWith("System.Collections.Generic.List") || (thisValue + "").StartsWith("System.Collections.Generic.IEnumerable");
         }
+
         public static bool IsStringArray(this string thisValue)
         {
             return (thisValue + "").IsMatch(@"System\.[a-z,A-Z,0-9]+?\[\]");
         }
+
         public static bool IsEnumerable(this string thisValue)
         {
             return (thisValue + "").StartsWith("System.Linq.Enumerable");
         }
 
-        public static Type StringType = typeof (string);
+        public static Type StringType = typeof(string);
 
         public static bool IsClass(this Type thisValue)
         {
-            return thisValue != StringType && thisValue.IsEntity()&&thisValue!=UtilConstants.ByteArrayType;
+            return thisValue != StringType && thisValue.IsEntity() && thisValue != UtilConstants.ByteArrayType;
         }
     }
 }

+ 2 - 1
WCS.Core/DataBlock.cs

@@ -40,7 +40,8 @@ namespace WCS.Core
                 { 
                     if (!Entity.PLCInfo.Ex().Ping) 
                     {
-                        throw new Exception($"{Entity.PLCInfo.IP}无法访问");
+                        return;
+                        //throw new Exception($"{Entity.PLCInfo.IP}无法访问");
                     }
                 } 
                 Start = (ushort)ProxyList.Min(v => v.Info.Position);

+ 9 - 11
WCS.Core/PLC.cs

@@ -1,15 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Net.NetworkInformation;
-using System.Text;
-using System.Threading.Tasks; 
+using System.Net.NetworkInformation;
 
 namespace WCS.Core
 {
     public class PLC : EntityEx<PLCInfo>
     {
         public bool Ping { get; private set; }
+
         public PLC(PLCInfo ent) : base(ent)
         {
             if (Configs.PLCAccessorCreater != null)
@@ -23,29 +19,31 @@ namespace WCS.Core
             {
                 while (true)
                 {
-                    Ping=ping();
+                    Ping = ping();
                     Task.Delay(1000);
                 }
             });
-        }      
+        }
+
         public IPLCAccessor Accessor { get; private set; }
 
-        bool ping(int timeout = 100)
-        { 
+        private bool ping(int timeout = 100)
+        {
             var p = new Ping();
             var res = p.Send(Entity.IP, timeout);
             return res.Status == IPStatus.Success;
         }
-      
     }
 
     public interface IPLCAccessorCreater
     {
         IPLCAccessor Create(PLCInfo data);
     }
+
     public interface IPLCAccessor
     {
         void WriteBytes(ushort db, ushort address, byte[] data);
+
         byte[] ReadBytes(ushort db, ushort address, ushort length);
     }
 }

+ 3 - 0
WCS.Core/ProtocolProxyBase.cs

@@ -81,6 +81,9 @@ namespace WCS.Core
                 bitStart += item.DataSizeOfBits;
                 BytesCount += item.DataSize;
             }
+
+            var a = ProtocolType.Assembly.GetTypes().Where(v => v.IsClass);
+
             ProtocolDataType = ProtocolType.Assembly.GetTypes().Where(v => v.IsClass).First(v => v.GetInterface(ProtocolType.Name) != null && v != this.GetType());
         }
 

+ 2 - 3
WCS.Core/System.cs

@@ -118,9 +118,8 @@ namespace WCS.Core
             }
 
             var types = t.GetGenericArguments();
-            var list = Device.All.Where(v => types.All(v.HasProtocol))
-                .Where(Select)
-                .Select(v => Activator.CreateInstance(typeof(T), v, World)).OfType<T>().ToList();//此时才实例化Protocol
+            var list = Device.All.Where(v => types.All(v.HasProtocol)).Where(Select).Select(v => Activator.CreateInstance(typeof(T), v, World)).OfType<T>().ToList();//此时才实例化Protocol
+
             if (list.Count == 0)
             {
                 //throw new Exception($"{this.GetType().Name}未匹配到任何Device");

+ 1 - 0
WCS.Core/World.cs

@@ -254,6 +254,7 @@ namespace WCS.Core
 
         private void LoadPlcData(List<WorkTimes> list)
         {
+            var aa = this.GetDataBlocks();
             Parallel.ForEach(this.GetDataBlocks(), db =>
             {
                 var channel = new Channel

+ 9 - 0
WCS.Service/Worker.cs

@@ -103,6 +103,10 @@ namespace WCS.Service
 
             #region 初始化数据库连接
 
+            InstanceFactory.CustomDbName = "TDengine";
+            InstanceFactory.CustomDllName = "SqlSugar.BzTDengineCore";
+            InstanceFactory.CustomNamespace = "SqlSugar.BzTDengineCore";
+
             var dbConnectionStrings = RedisHub.Default.Check("DbConnectionStrings") ?? throw new Exception("请在Redis中配置数据库连接相关内容");
             ServiceHub.DbConnectionStrings = JsonConvert.DeserializeObject<List<DataBaseConnectionString>>(dbConnectionStrings);
             if (ServiceHub.DbConnectionStrings != null)
@@ -122,6 +126,11 @@ namespace WCS.Service
                     ConnectionString = connectionString.ConnectionString,//连接符字串
                     DbType = connectionString.DbType,//数据库类型
                     IsAutoCloseConnection = true,//不设成true要手动close
+                    LanguageType = LanguageType.Chinese,
+                    MoreSettings = new ConnMoreSettings()
+                    {
+                        IsNoReadXmlDescription = true
+                    }
                 });
             };
             SqlSugarHelper.SetDb(new SqlSugarScope(connectionConfigs));

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/BCR/WCS_BCR80.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.BCR
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.BCR
     /// 读码器读取协议
     /// </summary>
     [DataContract]
-    public class WCS_BCR80 : IBCR80
+    [SugarTable("BCR80")]
+    public class WCS_BCR80 : TDengineBaseEntity, IBCR80
     {
         /// <summary>
         /// 内容

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/BCR/WCS_BCR81.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.BCR
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.BCR
     /// 读码器写入协议81
     /// </summary>
     [DataContract]
-    public class WCS_BCR81 : IBCR81
+    [SugarTable("BCR81")]
+    public class WCS_BCR81 : TDengineBaseEntity, IBCR81
     {
         /// <summary>
         /// 内容

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/BCR/WCS_BCR83.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel.DataAnnotations;
+using SqlSugar;
+using System.ComponentModel.DataAnnotations;
 using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.BCR
@@ -7,7 +8,8 @@ namespace WCS.Entity.Protocol.BCR
     /// 读码器写入协议81
     /// </summary>
     [DataContract]
-    public class WCS_BCR83 : IBCR83
+    [SugarTable("BCR83")]
+    public class WCS_BCR83 : TDengineBaseEntity, IBCR83
     {
         [DataMember(Order = 0)]
         public short Index { get; set; }

+ 16 - 16
业务工程/分拣库/WCS.Entity.Protocol/DataStructure/StationData.cs

@@ -22,37 +22,37 @@ namespace WCS.Entity.Protocol.Protocol.DataStructure
         [DataMember(Order = 5)]
         public WCS_Station523 D523 { get; set; }
 
-        //[DataMember(Order = 6)]
-        //public WCS_Station90 D90 { get; set; }
-
         [DataMember(Order = 6)]
+        public WCS_Station90 D90 { get; set; }
+
+        [DataMember(Order = 7)]
         public WCS_Station91 D91 { get; set; }
 
-        //[DataMember(Order = 8)]
-        //public WCS_BCR80 D80 { get; set; }
+        [DataMember(Order = 8)]
+        public WCS_BCR80 D80 { get; set; }
 
-        //[DataMember(Order = 9)]
-        //public WCS_BCR81 D81 { get; set; }
+        [DataMember(Order = 9)]
+        public WCS_BCR81 D81 { get; set; }
 
-        //[DataMember(Order = 10)]
-        //public WCS_BCR83 D83 { get; set; }
+        [DataMember(Order = 10)]
+        public WCS_BCR83 D83 { get; set; }
 
-        [DataMember(Order = 7)]
+        [DataMember(Order = 11)]
         public WCS_Station524 D524 { get; set; }
 
-        //[DataMember(Order = 12)]
-        //public WCS_Station525 D525 { get; set; }
+        [DataMember(Order = 12)]
+        public WCS_Station525 D525 { get; set; }
 
-        [DataMember(Order = 8)]
+        [DataMember(Order = 13)]
         public WCS_Truss530 D530 { get; set; }
 
-        [DataMember(Order = 9)]
+        [DataMember(Order = 14)]
         public WCS_Truss531 D5531 { get; set; }
 
-        [DataMember(Order = 10)]
+        [DataMember(Order = 15)]
         public WCS_Robot530 DR530 { get; set; }
 
-        [DataMember(Order = 11)]
+        [DataMember(Order = 16)]
         public WCS_Robot531 DR531 { get; set; }
     }
 }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/RGV/WCS_RGV520.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.RGV
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.RGV
     ///  RGV
     /// </summary>
     [DataContract]
-    public class WCS_RGV520 : IRGV520
+    [SugarTable("RGV520")]
+    public class WCS_RGV520 : TDengineBaseEntity, IRGV520
     {
         [DataMember(Order = 0)]
         public int TaskNumber { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/RGV/WCS_RGV521.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.RGV
 {
     [DataContract]
-    public class WCS_RGV521 : IRGV521
+    [SugarTable("RGV521")]
+    public class WCS_RGV521 : TDengineBaseEntity, IRGV521
     {
         [DataMember(Order = 0)]
         public int TaskNumber { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot520.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Robot
 {
     [DataContract]
-    public class WCS_Robot520 : IRobot520
+    [SugarTable("Robot520")]
+    public class WCS_Robot520 : TDengineBaseEntity, IRobot520
     {
         [DataMember(Order = 0)]
         public int TaskNumber1 { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot521.cs

@@ -1,10 +1,12 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 using WCS.Entity.Protocol.Protocol.Robot;
 
 namespace WCS.Entity.Protocol.Robot
 {
     [DataContract]
-    public class WCS_Robot521 : IRobot521
+    [SugarTable("Robot521")]
+    public class WCS_Robot521 : TDengineBaseEntity, IRobot521
     {
         [DataMember(Order = 0)]
         public int TaskNumber1 { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot522.cs

@@ -1,10 +1,12 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 using WCS.Entity.Protocol.Protocol.Robot;
 
 namespace WCS.Entity.Protocol.Robot
 {
     [DataContract]
-    public class WCS_Robot522 : IRobot522
+    [SugarTable("Robot522")]
+    public class WCS_Robot522 : TDengineBaseEntity, IRobot522
     {
         [DataMember(Order = 0)]
         public RobotAlarm Alarm { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot530.cs

@@ -1,10 +1,12 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 using WCS.Entity.Protocol.Protocol.Robot;
 
 namespace WCS.Entity.Protocol.Robot
 {
     [DataContract]
-    public class WCS_Robot530 : IRobot530
+    [SugarTable("Robot530")]
+    public class WCS_Robot530 : TDengineBaseEntity, IRobot530
     {
         [DataMember(Order = 0)]
         public short Type { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Robot/WCS_Robot531.cs

@@ -1,10 +1,12 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 using WCS.Entity.Protocol.Protocol.Robot;
 
 namespace WCS.Entity.Protocol.Robot
 {
     [DataContract]
-    public class WCS_Robot531 : IRobot531
+    [SugarTable("Robot531")]
+    public class WCS_Robot531 : TDengineBaseEntity, IRobot531
     {
         [DataMember(Order = 0)]
         public int TaskNo1 { get; set; }

+ 0 - 60
业务工程/分拣库/WCS.Entity.Protocol/SRM/SRM520.cs

@@ -1,60 +0,0 @@
-using SqlSugar;
-using SqlSugar.DbConvert;
-using SqlSugar.TDengine;
-using System;
-
-namespace WCS.Entity.Protocol.SRM
-{
-    /// <summary>
-    ///  SRM520
-    /// </summary>
-    [SugarTable("stb_" + nameof(SRM520))]
-    public class SRM520 : STable
-    {
-        /// <summary>
-        /// 时间
-        /// </summary>
-        [SugarColumn(IsPrimaryKey = true)]
-        public DateTime Frame { get; set; }
-
-        public short Res1 { get; set; }
-
-        public short Res2 { get; set; }
-
-        public short Res3 { get; set; }
-
-        public short GoodsType { get; set; }
-
-        [SqlSugar.SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))]
-        public SrmRunSpeed RunSpeed { get; set; }
-
-        public short SLine { get; set; }
-
-        public short SCol { get; set; }
-
-        public short SLayer { get; set; }
-
-        [SqlSugar.SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))]
-        public SrmForkPosition SDepth { get; set; }
-
-        public short ELine { get; set; }
-
-        public short ECol { get; set; }
-
-        public short ELayer { get; set; }
-
-        [SqlSugar.SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))]
-        public SrmForkPosition EDepth { get; set; }
-
-        public int TaskNumber { get; set; }
-
-        public short VoucherNo { get; set; }
-
-        public short OkAck { get; set; }
-
-        [SqlSugar.SugarColumn(SqlParameterDbType = typeof(CommonPropertyConvert))]
-        public SrmTaskType TaskType { get; set; }
-
-        public short Cmd { get; set; }
-    }
-}

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/SRM/WCS_SRM520.cs

@@ -1,11 +1,13 @@
-using SqlSugar.TDengine;
+using SqlSugar;
+using SqlSugar.TDengine;
 using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.SRM
 {
 
     [DataContract]
-    public class WCS_SRM520 : SRM520
+    [SugarTable("SRM520")]
+    public class WCS_SRM520 : TDengineBaseEntity, ISRM520
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/SRM/WCS_SRM521.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.SRM
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.SRM
     ///  SRM521
     /// </summary>
     [DataContract]
-    public class WCS_SRM521 : ISRM521
+    [SugarTable("SRM521")]
+    public class WCS_SRM521 : TDengineBaseEntity, ISRM521
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/SRM/WCS_SRM537.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.SRM
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.SRM
     ///  SRM537
     /// </summary>
     [DataContract]
-    public class WCS_SRM537 : ISRM537
+    [SugarTable("SRM537")]
+    public class WCS_SRM537 : TDengineBaseEntity, ISRM537
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station520.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.Station
     ///  520
     /// </summary>
     [DataContract]
-    public class WCS_Station520 : IStation520
+    [SugarTable("Station520")]
+    public class WCS_Station520 : TDengineBaseEntity, IStation520
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station521.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.Station
     ///  521
     /// </summary>
     [DataContract]
-    public class WCS_Station521 : IStation521
+    [SugarTable("Station521")]
+    public class WCS_Station521 : TDengineBaseEntity, IStation521
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station523.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.Station
     ///  523
     /// </summary>
     [DataContract]
-    public class WCS_Station523 : IStation523
+    [SugarTable("Station523")]
+    public class WCS_Station523 : TDengineBaseEntity, IStation523
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station524.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
     [DataContract]
-    public class WCS_Station524 : IStation524
+    [SugarTable("Station524")]
+    public class WCS_Station524 : TDengineBaseEntity, IStation524
     {
         [DataMember(Order = 0)]
         public int TaskNumber { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station525.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
     [DataContract]
-    public class WCS_Station525 : IStation525
+    [SugarTable("Station525")]
+    public class WCS_Station525 : TDengineBaseEntity, IStation525
     {
         [DataMember(Order = 1)]
         public short NextIndex { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station90.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.Station
     ///  90
     /// </summary>
     [DataContract]
-    public class WCS_Station90 : IStation90
+    [SugarTable("Station90")]
+    public class WCS_Station90 : TDengineBaseEntity, IStation90
     {
     }
 }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Station/WCS_Station91.cs

@@ -1,4 +1,5 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Station
 {
@@ -6,7 +7,8 @@ namespace WCS.Entity.Protocol.Station
     ///  91
     /// </summary>
     [DataContract]
-    public class WCS_Station91 : IStation91
+    [SugarTable("Station91")]
+    public class WCS_Station91 : TDengineBaseEntity, IStation91
     {
         /// <inheritdoc/>
         [DataMember(Order = 0)]

+ 20 - 0
业务工程/分拣库/WCS.Entity.Protocol/TDengineBaseEntity.cs

@@ -0,0 +1,20 @@
+using SqlSugar;
+using SqlSugar.TDengine;
+using System;
+
+namespace WCS.Entity.Protocol
+{
+    /// <summary>
+    ///  时序数据库TDengine基础实体
+    /// </summary>
+    public class TDengineBaseEntity : STable
+    {
+        [SugarColumn(IsPrimaryKey = true, InsertServerTime = true)]
+        public DateTime ExTime { get; set; }
+
+        public string Code { get; set; }
+
+        [SugarColumn(IsIgnore = true)]
+        public string CreateSql { get; set; }
+    }
+}

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss520.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Truss
 {
     [DataContract]
-    public class WCS_Truss520 : ITruss520
+    [SugarTable("Truss520")]
+    public class WCS_Truss520 : TDengineBaseEntity, ITruss520
     {
         [DataMember(Order = 0)]
         public short DestPosition_1 { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss521.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Truss
 {
     [DataContract]
-    public class WCS_Truss521 : ITruss521
+    [SugarTable("Truss521")]
+    public class WCS_Truss521 : TDengineBaseEntity, ITruss521
     {
         [DataMember(Order = 0)]
         public short DestPosition_1 { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss523.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Truss
 {
     [DataContract]
-    public class WCS_Truss523 : ITruss523
+    [SugarTable("Truss523")]
+    public class WCS_Truss523 : TDengineBaseEntity, ITruss523
     {
         [DataMember(Order = 0)]
         public TrussAlarm Alarm { get; set; }

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss530.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Truss
 {
     [DataContract]
-    public class WCS_Truss530 : ITruss530
+    [SugarTable("Truss530")]
+    public class WCS_Truss530 : TDengineBaseEntity, ITruss530
     {
 
         [DataMember(Order = 0)]

+ 4 - 2
业务工程/分拣库/WCS.Entity.Protocol/Truss/WCS_Truss531.cs

@@ -1,9 +1,11 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.Truss
 {
     [DataContract]
-    public class WCS_Truss531 : ITruss531
+    [SugarTable("Truss531")]
+    public class WCS_Truss531 : TDengineBaseEntity, ITruss531
     {
         [DataMember(Order = 0)]
         public int TaskNo1 { get; set; }

+ 2 - 2
业务工程/分拣库/WCS.WorkEngineering/Extensions/DeviceExtension.cs

@@ -301,10 +301,10 @@ namespace WCS.WorkEngineering.Extensions
                 "1676" => "1SR",
                 "1681" => "1SR",
 
-
                 #endregion 库一
 
                 #region 库二
+
                 //北
                 "SRM3" => "2N",
                 "818" => "2N",
@@ -318,8 +318,8 @@ namespace WCS.WorkEngineering.Extensions
 
                 #endregion 库二
 
-
                 #region 库二
+
                 //北
                 "SRM5" => "3N",
                 "1218" => "3N",

+ 172 - 13
业务工程/分拣库/WCS.WorkEngineering/ProtocolProxy.cs

@@ -1,6 +1,14 @@
-using WCS.Core;
+using ServiceCenter.SqlSugars;
+using WCS.Core;
+using WCS.Entity.Protocol;
+using WCS.Entity.Protocol.BCR;
 using WCS.Entity.Protocol.DataStructure;
 using WCS.Entity.Protocol.Protocol.DataStructure;
+using WCS.Entity.Protocol.RGV;
+using WCS.Entity.Protocol.Robot;
+using WCS.Entity.Protocol.SRM;
+using WCS.Entity.Protocol.Station;
+using WCS.Entity.Protocol.Truss;
 using WCS.WorkEngineering.Systems;
 
 namespace WCS.WorkEngineering
@@ -33,10 +41,10 @@ namespace WCS.WorkEngineering
                 {
                     if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new SRMData { Code = Device.Code };
                 }
-                //else if (Device.Code.Contains("Truss"))
-                //{
-                //    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new TrussData() { Code = Device.Code };
-                //}
+                else if (Device.Code.Contains("Truss"))
+                {
+                    if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new TrussData() { Code = Device.Code };
+                }
                 else if (Device.Code.Contains("Robot"))
                 {
                     if (!datas.ContainsKey(Device.Code)) datas[Device.Code] = new RobotData() { Code = Device.Code };
@@ -54,7 +62,7 @@ namespace WCS.WorkEngineering
                 //{
                 //}
                 if (p == null) return;
-                p.SetValue(data, DictionaryToEntity(ProtocolDataType, Items));
+                p.SetValue(data, DictionaryToEntity(ProtocolDataType, Items, data));
             }
             catch (Exception ex)
             {
@@ -62,19 +70,170 @@ namespace WCS.WorkEngineering
             }
         }
 
-        public object DictionaryToEntity(Type type, Dictionary<string, PlcItem> items)
+        public object DictionaryToEntity(Type type, Dictionary<string, PlcItem> plcItems, DeviceData data)
         {
-            var a = Activator.CreateInstance(type);
-            foreach (var ty in type.GetProperties())
+            var entity = Activator.CreateInstance(type);
+            //采集量
+            Parallel.ForEach(type.GetProperties(), ty =>
+            {
+                if (plcItems.Any(x => x.Key == ty.Name))
+                {
+                    var item = plcItems.First(x => ty.Name == x.Key);
+                    ty.SetValue(entity, item.Value.Value);
+                }
+            });
+
+            Parallel.ForEach(type.GetProperties(), ty =>
             {
-                foreach (var item in items.Where(item => ty.Name == item.Key))
+                var items = data.GetType().GetProperties();
+                if (items.Any(x => x.Name == ty.Name))
                 {
-                    ty.SetValue(a, item.Value.Value);
-                    break;
+                    var item = items.First(x => ty.Name == x.Name);
+                    ty.SetValue(entity, item.GetValue(data));
+                }
+            });
+
+            foreach (var ty in type.GetProperties().Where(x => x.Name == nameof(TDengineBaseEntity.CreateSql)))
+            {
+                var db = new SqlSugarHelper().PLC;
+                switch (type.Name)
+                {
+                    case nameof(WCS_SRM520):
+                        var item = entity as WCS_SRM520;
+                        ty.SetValue(entity, GetString(db.Insertable(item).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_SRM521):
+                        var item1 = entity as WCS_SRM521;
+                        ty.SetValue(entity, GetString(db.Insertable(item1).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_SRM537):
+                        var item2 = entity as WCS_SRM537;
+                        ty.SetValue(entity, GetString(db.Insertable(item2).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_RGV520):
+                        var item3 = entity as WCS_RGV520;
+                        ty.SetValue(entity, GetString(db.Insertable(item3).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_RGV521):
+                        var item4 = entity as WCS_RGV521;
+                        ty.SetValue(entity, GetString(db.Insertable(item4).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_BCR80):
+                        var item5 = entity as WCS_BCR80;
+                        ty.SetValue(entity, GetString(db.Insertable(item5).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_BCR81):
+                        var item6 = entity as WCS_BCR81;
+                        ty.SetValue(entity, GetString(db.Insertable(item6).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_BCR83):
+                        var item7 = entity as WCS_BCR83;
+                        ty.SetValue(entity, GetString(db.Insertable(item7).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station520):
+                        var item8 = entity as WCS_Station520;
+                        ty.SetValue(entity, GetString(db.Insertable(item8).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station521):
+                        var item9 = entity as WCS_Station521;
+                        ty.SetValue(entity, GetString(db.Insertable(item9).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station523):
+                        var item10 = entity as WCS_Station523;
+                        ty.SetValue(entity, GetString(db.Insertable(item10).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station524):
+                        var item11 = entity as WCS_Station524;
+                        ty.SetValue(entity, GetString(db.Insertable(item11).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station525):
+                        var item12 = entity as WCS_Station525;
+                        ty.SetValue(entity, GetString(db.Insertable(item12).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station90):
+                        var item13 = entity as WCS_Station90;
+                        ty.SetValue(entity, GetString(db.Insertable(item13).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Station91):
+                        var item14 = entity as WCS_Station91;
+                        ty.SetValue(entity, GetString(db.Insertable(item14).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Truss520):
+                        var item15 = entity as WCS_Truss520;
+                        ty.SetValue(entity, GetString(db.Insertable(item15).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Truss521):
+                        var item16 = entity as WCS_Truss521;
+                        ty.SetValue(entity, GetString(db.Insertable(item16).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Truss523):
+                        var item17 = entity as WCS_Truss523;
+                        ty.SetValue(entity, GetString(db.Insertable(item17).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Truss530):
+                        var item18 = entity as WCS_Truss530;
+                        ty.SetValue(entity, GetString(db.Insertable(item18).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Truss531):
+                        var item19 = entity as WCS_Truss531;
+                        ty.SetValue(entity, GetString(db.Insertable(item19).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Robot520):
+                        var item20 = entity as WCS_Robot520;
+                        ty.SetValue(entity, GetString(db.Insertable(item20).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Robot521):
+                        var item21 = entity as WCS_Robot521;
+                        ty.SetValue(entity, GetString(db.Insertable(item21).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Robot522):
+                        var item22 = entity as WCS_Robot522;
+                        ty.SetValue(entity, GetString(db.Insertable(item22).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Robot530):
+                        var item23 = entity as WCS_Robot530;
+                        ty.SetValue(entity, GetString(db.Insertable(item23).ToSqlString()));
+                        break;
+
+                    case nameof(WCS_Robot531):
+                        var item24 = entity as WCS_Robot531;
+                        ty.SetValue(entity, GetString(db.Insertable(item24).ToSqlString()));
+                        break;
                 }
             }
+            return entity;
+        }
 
-            return a;
+        public string GetString(string value)
+        {
+            return value.Replace("INSERT INTO ", "")
+                .Replace(",N'", ",'")
+                .Replace("\0", "")
+                .Replace("wcs_", "")
+                .Replace("(N'", "('") + "\r";
         }
     }
 }

+ 120 - 22
业务工程/分拣库/WCS.WorkEngineering/Systems/DataCollectionSysyem.cs

@@ -1,11 +1,11 @@
 using PlcSiemens.Core.Extension;
-using ServiceCenter.Logs;
-using ServiceCenter.Redis;
+using ServiceCenter.SqlSugars;
 using System.Collections.Concurrent;
 using System.ComponentModel;
+using System.Diagnostics;
+using System.Text;
 using WCS.Core;
 using WCS.Entity.Protocol.DataStructure;
-using WCS.Entity.Protocol.SRM;
 using WCS.WorkEngineering.Extensions;
 using WCS.WorkEngineering.Worlds;
 
@@ -20,8 +20,20 @@ namespace WCS.WorkEngineering.Systems
     {
         public static DeviceDataPack pack = new DeviceDataPack();
 
+        private static object locker = new object();
+
         public DataCollectionSysyem()
         {
+            var gs = Device.All.SelectMany(v => v.Protocols.Select(d => new { DB = $"{d.Value.DBInfo.No}:{d.Value.DBInfo.PLCInfo.IP}", d.Value.Position, TypeStr = d.Key, Dev = v }))
+                .GroupBy(v => v.DB);
+            foreach (var g in gs)
+            {
+                var min = g.OrderBy(v => v.Position).First();
+                var max = g.OrderByDescending(v => v.Position).First();
+                var t = Type.GetType(min.TypeStr);
+                min.Dev.Protocol(t, this.World);
+                max.Dev.Protocol(t, this.World);
+            }
         }
 
         /// <summary>
@@ -42,10 +54,13 @@ namespace WCS.WorkEngineering.Systems
 
         public override void Do(SRM obj)
         {
+            var sw = new Stopwatch();
+            sw.Start();
             try
             {
+                var sw1 = new Stopwatch();
+                sw1.Start();
                 var gs = AllDatas.GroupBy(v => v.Value.GetType());
-
                 DeviceDataPack pack = new DeviceDataPack();
                 pack.Frame = DateTime.Now;
                 foreach (var g in gs)
@@ -57,29 +72,112 @@ namespace WCS.WorkEngineering.Systems
                     var p = pack.GetType().GetProperties().First(v => v.PropertyType == type);
                     p.SetValue(pack, coll);
                 }
+                sw1.Stop();
+                World.Log($"数据解析耗时:{sw1.ElapsedMilliseconds}");
 
-                RedisHub.Monitor.RPush("Packs", pack);
-                RedisHub.Monitor.Set(nameof(DeviceDataPack), pack);
-                if (RedisHub.Monitor.LLen("Packs") > 200000)
+                var sw2 = new Stopwatch();
+                sw2.Start();
+                SqlSugarHelper.Do(_db =>
                 {
-                    RedisHub.Monitor.LTrim("Packs", 50000, -1);
-                }
-
-
-                //开始只处理SRM520
-
-                //var sql = "INSERT INTO ";
-                //pack.SRMDatas.Datas.ForEach(x =>
-                //{
-                //    var srm520 = x.D520 as SRM520;
-                //});
-
-
-
+                    try
+                    {
+                        var sw3 = new Stopwatch();
+                        sw3.Start();
+                        var sql = new StringBuilder();
+                        sql.Append("INSERT INTO ");
+                        var db = _db.PLC;
+                        if (pack.SRMDatas != null && pack.SRMDatas.Datas.Any())
+                        {
+                            Parallel.ForEach(pack.SRMDatas.Datas, x =>
+                            {
+                                if (x.D520 != null) Set(sql, x.D520.CreateSql);
+                                if (x.D521 != null) Set(sql, x.D521.CreateSql);
+                                if (x.D537 != null) Set(sql, x.D537.CreateSql);
+                            });
+                        }
+
+                        if (pack.RGVDatas != null && pack.RGVDatas.Datas.Any())
+                        {
+                            Parallel.ForEach(pack.RGVDatas.Datas, x =>
+                            {
+                                if (x.D520 != null) Set(sql, x.D520.CreateSql);
+                                if (x.D521 != null) Set(sql, x.D521.CreateSql);
+                                if (x.D81 != null) Set(sql, x.D81.CreateSql);
+                            });
+                        }
+
+                        if (pack.StationDatas != null && pack.StationDatas.Datas.Any())
+                        {
+                            Parallel.ForEach(pack.StationDatas.Datas, x =>
+                            {
+                                if (x.D520 != null) Set(sql, x.D520.CreateSql);
+                                if (x.D521 != null) Set(sql, x.D521.CreateSql);
+                                if (x.D523 != null) Set(sql, x.D523.CreateSql);
+                                if (x.D90 != null) Set(sql, x.D90.CreateSql);
+                                if (x.D91 != null) Set(sql, x.D91.CreateSql);
+                                if (x.D80 != null) Set(sql, x.D80.CreateSql);
+                                if (x.D81 != null) Set(sql, x.D81.CreateSql);
+                                if (x.D83 != null) Set(sql, x.D83.CreateSql);
+                                if (x.D524 != null) Set(sql, x.D524.CreateSql);
+                                if (x.D525 != null) Set(sql, x.D525.CreateSql);
+                                if (x.D530 != null) Set(sql, x.D530.CreateSql);
+                                if (x.D5531 != null) Set(sql, x.D5531.CreateSql);
+                                if (x.DR530 != null) Set(sql, x.DR530.CreateSql);
+                                if (x.DR531 != null) Set(sql, x.DR531.CreateSql);
+                            });
+                        }
+
+                        if (pack.RobotData != null && pack.RobotData.Datas.Any())
+                        {
+                            Parallel.ForEach(pack.RobotData.Datas, x =>
+                            {
+                                if (x.D520 != null) Set(sql, x.D520.CreateSql);
+                                if (x.D521 != null) Set(sql, x.D521.CreateSql);
+                                if (x.D522 != null) Set(sql, x.D522.CreateSql);
+                            });
+                        }
+
+                        if (pack.TrussData != null && pack.TrussData.Datas.Any())
+                        {
+                            Parallel.ForEach(pack.TrussData.Datas, x =>
+                            {
+                                if (x.D520 != null) Set(sql, x.D520.CreateSql);
+                                if (x.D521 != null) Set(sql, x.D521.CreateSql);
+                                if (x.D523 != null) Set(sql, x.D523.CreateSql);
+                            });
+                        }
+
+                        sw3.Stop();
+                        World.Log($"转换SQL耗时:{sw3.ElapsedMilliseconds}");
+
+                        var sw4 = new Stopwatch();
+                        sw4.Start();
+                        var sqlText = sql.ToString();
+                        db.Ado.ExecuteCommand(sql.ToString());
+                        sw4.Stop();
+                        World.Log($"执行SQL耗时:{sw4.ElapsedMilliseconds}");
+                    }
+                    catch (Exception e)
+                    {
+                        World.Log($"数据采集错误1:{e.StackTrace}"); Console.WriteLine(e);
+                    }
+                });
+                sw2.Stop();
+                World.Log($"数据保存数据库总耗时间:{sw2.ElapsedMilliseconds}");
             }
             catch (Exception e)
             {
-                throw new KnownException($"数据采集错误:{e.StackTrace}", LogLevelEnum.Low);
+                World.Log($"数据采集错误:{e.StackTrace}");
+            }
+            sw.Stop();
+            World.Log($"数据采集总耗时:{sw.ElapsedMilliseconds}");
+        }
+
+        public void Set(StringBuilder sql, string cSql)
+        {
+            lock (locker)
+            {
+                sql.Append(cSql);
             }
         }
     }

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/DeviceWriteSystem.cs

@@ -9,7 +9,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  设备信息写入接口
     /// </summary>
-   // [BelongTo(typeof(MainWorld))]
+    //[BelongTo(typeof(MainWorld))]
     public class DeviceWriteSystem : ServiceSystem<DeviceWriteInfo>
     {
         /// <summary>

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/GetDeviceSystem.cs

@@ -10,7 +10,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  设备信息读取接口
     /// </summary>
-    [BelongTo(typeof(MainWorld))]
+    //[BelongTo(typeof(MainWorld))]
     public class GetDeviceSystem : ServiceSystem<Tuple<string, string>, object>
     {
         /// <summary>

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/NoInteractionSystems.cs

@@ -17,7 +17,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  无交互系统
     /// </summary>
-   // [BelongTo(typeof(NoInteractionWorld))]
+    //[BelongTo(typeof(NoInteractionWorld))]
     [Description("无交互系统")]
     public class NoInteractionSystems : DeviceSystem<Device<IStation520>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/SrmSystems.cs

@@ -19,7 +19,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     /// 堆垛机系统
     /// </summary>
-   // [BelongTo(typeof(SrmWorld))]
+    //[BelongTo(typeof(SrmWorld))]
     [Description("堆垛机系统")]
     public class SrmSystems : DeviceSystem<SRM>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/UpLoadSystems.cs

@@ -14,7 +14,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  UpLoadSystems
     /// </summary>
-   // [BelongTo(typeof(UpLoadWorld))]
+    //[BelongTo(typeof(UpLoadWorld))]
     [Description("UpLoadSystems")]
     public class UpLoadSystems : DeviceSystem<Device<IStation520>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/一楼叠盘机入库.cs

@@ -15,7 +15,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  一楼叠盘机入库
     /// </summary>
-   // [BelongTo(typeof(MainWorld))]
+   //[BelongTo(typeof(MainWorld))]
     [Description("一楼叠盘机入库")]
     public class 一楼叠盘机入库 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/分拣支线/环形库分流点.cs

@@ -18,7 +18,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  分流点
     /// </summary>
-   // [BelongTo(typeof(SortingBranchWorld))]
+    //[BelongTo(typeof(SortingBranchWorld))]
     [Description("环形库分流点")]
     public class 环形库分流点 : DeviceSystem<Device<IStation520, IStation521, IStation523, IStation91>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/机台叫料生成AGV任务.cs

@@ -12,7 +12,7 @@ using TaskStatus = WCS.Entity.TaskStatus;
 
 namespace WCS.WorkEngineering.Systems
 {
-   // [BelongTo(typeof(MainWorld))]
+    //[BelongTo(typeof(MainWorld))]
     [Description("机台叫料生成AGV任务")]
     public class 机台叫料生成AGV任务 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架.cs

@@ -15,7 +15,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  桁架
     /// </summary>
-   // [BelongTo(typeof(SortingPalletizingWorld))]
+    //[BelongTo(typeof(SortingPalletizingWorld))]
     [Description("桁架")]
     public class 桁架 : DeviceSystem<Truss>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/桁架码垛/桁架缓存放行点.cs

@@ -13,7 +13,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  桁架缓存放行点
     /// </summary>
-   // [BelongTo(typeof(SortingPalletizingWorld))]
+    //[BelongTo(typeof(SortingPalletizingWorld))]
     [Description("桁架缓存放行点")]
     public class 桁架缓存放行点 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/机械臂cs.cs

@@ -17,7 +17,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///   机械臂
     /// </summary>
-  //  [BelongTo(typeof(RingWorld))]
+  //[BelongTo(typeof(RingWorld))]
     [Description("机械臂")]
     public class 机械臂 : DeviceSystem<Device<IRobot520, IRobot521, IRobot522>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/环形库码垛区补空托盘任务生成.cs

@@ -15,7 +15,7 @@ namespace WCS.WorkEngineering.Systems
     /// <summary>
     ///  环形库码垛区补空托盘任务生成
     /// </summary>
-   // [BelongTo(typeof(RingWorld))]
+    //[BelongTo(typeof(RingWorld))]
     [Description("环形库码垛区补空托盘任务生成")]
     public class 环形库码垛区补空托盘任务生成 : DeviceSystem<Device<IStation520, IStation521, IStation523>>
     {

+ 1 - 1
业务工程/分拣库/WCS.WorkEngineering/Systems/环形库/环形库码垛结束.cs

@@ -19,7 +19,7 @@ namespace WCS.WorkEngineering.Systems.环形库
     /// <summary>
     ///  环形库码垛结束
     /// </summary>
-    //[BelongTo(typeof(RingWorld))]
+   // [BelongTo(typeof(RingWorld))]
     [Description("环形库码垛结束")]
     public class 环形库码垛结束 : DeviceSystem<Device<IStation520, IStation521, IStation523, IRobot530, IRobot531>>
     {

+ 40 - 53
业务工程/分拣库/WCS.WorkEngineering/WorkStart.cs

@@ -1,7 +1,6 @@
 using ServiceCenter;
 using ServiceCenter.SqlSugars;
 using WCS.Core;
-using WCS.Entity;
 using WCS.Entity.Protocol.BCR;
 using WCS.Entity.Protocol.RGV;
 using WCS.Entity.Protocol.Robot;
@@ -1109,17 +1108,17 @@ namespace WCS.WorkEngineering
                     {
                         case "WCSDB"://WCS基本数据库
                             SqlSugarHelper.SetDefault(connectionString.Key);
-                            _db.CodeFirst.InitTables(typeof(WCS_PlcData));
-                            _db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
-                            _db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
-                            _db.CodeFirst.InitTables(typeof(WCS_TaskOld));
-                            _db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
-                            _db.CodeFirst.InitTables(typeof(WCS_Palletizing));
-                            _db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
-                            _db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
-                            _db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
-                            _db.CodeFirst.InitTables(typeof(WCS_CacheLine));
-                            _db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PlcData));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskInfo));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskDtl));
+                            //_db.CodeFirst.InitTables(typeof(WCS_TaskOld));
+                            //_db.CodeFirst.InitTables(typeof(WCS_AgvTaskInfo));
+                            //_db.CodeFirst.InitTables(typeof(WCS_Palletizing));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLayer));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PalletizingRow));
+                            //_db.CodeFirst.InitTables(typeof(WCS_PalletizingLoc));
+                            //_db.CodeFirst.InitTables(typeof(WCS_CacheLine));
+                            //_db.CodeFirst.InitTables(typeof(WCS_CacheLineLoc));
 
                             break;
 
@@ -1129,16 +1128,35 @@ namespace WCS.WorkEngineering
 
                         case "PLC"://PLC
 
-                            //var comm = ((TDengineCommand)conn.CreateCommand());
-                            //comm.Connection = conn;
-                            //comm.CommandText = "CREATE DATABASE IF NOT EXISTS fj_plc WAL_RETENTION_PERIOD 3600";
-                            //var dr = comm.ExecuteNonQuery();
-
-                            //conn.Close();
-                            _db.DbMaintenance.CreateDatabase();
-
-                            //var sql = GetCreateTableSql(typeof(SRM520));
-                            _db.CodeFirst.InitTables<SRM520>();
+                            SqlSugarHelper.SetPLC(connectionString.Key);
+
+                            //_db.DbMaintenance.CreateDatabase();
+
+                            //_db.CodeFirst.InitTables<WCS_SRM520>();
+                            //_db.CodeFirst.InitTables<WCS_SRM521>();
+                            //_db.CodeFirst.InitTables<WCS_SRM537>();
+                            //_db.CodeFirst.InitTables<WCS_RGV520>();
+                            //_db.CodeFirst.InitTables<WCS_RGV521>();
+                            //_db.CodeFirst.InitTables<WCS_BCR80>();
+                            //_db.CodeFirst.InitTables<WCS_BCR81>();
+                            //_db.CodeFirst.InitTables<WCS_BCR83>();
+                            //_db.CodeFirst.InitTables<WCS_Station520>();
+                            //_db.CodeFirst.InitTables<WCS_Station521>();
+                            //_db.CodeFirst.InitTables<WCS_Station523>();
+                            //_db.CodeFirst.InitTables<WCS_Station524>();
+                            //_db.CodeFirst.InitTables<WCS_Station525>();
+                            //_db.CodeFirst.InitTables<WCS_Station90>();
+                            //_db.CodeFirst.InitTables<WCS_Station91>();
+                            //_db.CodeFirst.InitTables<WCS_Truss520>();
+                            //_db.CodeFirst.InitTables<WCS_Truss521>();
+                            //_db.CodeFirst.InitTables<WCS_Truss523>();
+                            //_db.CodeFirst.InitTables<WCS_Truss530>();
+                            //_db.CodeFirst.InitTables<WCS_Truss531>();
+                            //_db.CodeFirst.InitTables<WCS_Robot520>();
+                            //_db.CodeFirst.InitTables<WCS_Robot521>();
+                            //_db.CodeFirst.InitTables<WCS_Robot522>();
+                            //_db.CodeFirst.InitTables<WCS_Robot530>();
+                            //_db.CodeFirst.InitTables<WCS_Robot531>();
                             var a = false;
                             break;
 
@@ -1148,36 +1166,5 @@ namespace WCS.WorkEngineering
                 };
             });
         }
-
-        public static string GetCreateTableSql(Type type)
-        {
-            string sql = "CREATE STABLE IF NOT EXISTS " + $"stb_{type.Name} (";
-            var properties = type.GetProperties();
-
-            for (int i = 0; i < properties.Length; i++)
-            {
-                var propertie = properties[i];
-                if (i != 0) sql += ", ";
-                sql += $"{propertie.Name} {GetPropertyType(propertie.PropertyType)}";
-            }
-            sql += ") TAGS (DevName VARCHAR(124));";
-            return sql;
-        }
-
-        public static string GetPropertyType(Type type)
-        {
-            if (type.IsEnum) return GetPropertyType(Enum.GetUnderlyingType(type));
-            else if (type == typeof(DateTime)) return "TIMESTAMP";
-            else if (type == typeof(int)) return "INT";
-            else if (type == typeof(short)) return "SMALLINT";
-            else if (type == typeof(bool)) return "BOOL";
-            else if (type == typeof(uint)) return "INT UNSIGNED";
-            else if (type == typeof(ushort)) return "SMALLINT UNSIGNED";
-            else if (type == typeof(ulong)) return "BIGINT UNSIGNED";
-            else if (type == typeof(float)) return "FLOAT";
-            else if (type == typeof(decimal)) return "DOUBLE";
-            else if (type == typeof(long)) return "BIGINT";
-            else return "";
-        }
     }
 }

+ 94 - 0
业务工程/分拣库/WCS.WorkEngineering/数据采集.cs

@@ -0,0 +1,94 @@
+using FreeRedis;
+using PlcSiemens.Core.Extension;
+using System.ComponentModel;
+using System.Diagnostics;
+using WCS.Core;
+
+namespace WCS.WorkEngineering.Systems
+{
+    // [BelongTo(typeof(MainWorld))]
+    [Description("数据采集系统")]
+    public class 数据采集 : SystemBase
+    {
+        private RedisClient Redis = new RedisClient("");
+
+        public 数据采集()
+        {
+            var gs = Device.All.SelectMany(v => v.Protocols.Select(d => new { DB = $"{d.Value.DBInfo.No}:{d.Value.DBInfo.PLCInfo.IP}", d.Value.Position, TypeStr = d.Key, Dev = v }))
+                 .GroupBy(v => v.DB);
+            foreach (var g in gs)
+            {
+                var min = g.OrderBy(v => v.Position).First();
+                var max = g.OrderByDescending(v => v.Position).First();
+                var t = Type.GetType(min.TypeStr);
+                min.Dev.Protocol(t, this.World);
+                max.Dev.Protocol(t, this.World);
+            }
+        }
+
+        public override List<object> GetObjects()
+        {
+            return new List<object>();
+        }
+
+        public override void Update(List<WorkTimes> list)
+        {
+            //var sw = new Stopwatch();
+            //sw.Start();
+            //var pack = new DataPack();
+            //pack.Frame = DateTime.Now;
+            //var ps = pack.GetType().GetProperties();
+            //foreach (var p in ps)
+            //{
+            //    if (!p.PropertyType.IsArray)
+            //        continue;
+            //    var t = p.PropertyType.GetElementType();
+            //    if (t.IsGenericType)
+            //    {
+            //        var entType = t.GetGenericArguments()[0];
+            //        var protType = GetProtocolType(entType);
+            //        var arr = Device.All.Where(v => v.HasProtocol(protType))
+            //        .Select(v =>
+            //        {
+            //            try
+            //            {
+            //                var obj = Activator.CreateInstance(t);
+            //                t.GetProperty("Code").SetValue(obj, v.Code);
+            //                var value = v.Protocol(protType, World).Copy(entType);
+            //                t.GetProperty("Data").SetValue(obj, value);
+            //                return obj;
+            //            }
+            //            catch (Exception ex)
+            //            {
+            //                return null;
+            //            }
+            //        }).Where(v => v != null).ToArray();
+
+            //        var m = typeof(Enumerable).GetMethod("OfType", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //        m = m.MakeGenericMethod(t);
+            //        var arr2 = m.Invoke(null, new object[] { arr });
+
+            //        m = typeof(Enumerable).GetMethod("ToArray", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
+            //        m = m.MakeGenericMethod(t);
+            //        var arr3 = m.Invoke(null, new object[] { arr2 });
+            //        p.SetValue(pack, arr3);
+            //    }
+            //}
+
+            //Redis.RPush("Packs", pack);
+            //if (Redis.LLen("Packs") > 50000)
+            //{
+            //    Redis.LTrim("Packs", 5000, -1);
+            //}
+
+            //sw.Stop();
+            //list.Add(new WorkTimes { Total = sw.ElapsedMilliseconds, Key = "采集数据" });
+        }
+
+        private Type GetProtocolType(Type source)
+        {
+            var t = source.GetInterfaces().FirstOrDefault(v => v.GetInterfaces().Any(d => d.Name == "IProtocol"));
+            return t;
+        }
+    }
+}