林豪 左 před 2 roky
rodič
revize
f43836ee31

+ 2 - 2
ServiceCenter/ServiceCenter.csproj

@@ -10,8 +10,8 @@
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
     <PackageReference Include="PlcSiemens" Version="1.0.0.2" />
-    <PackageReference Include="WCS.Core" Version="1.0.0.6" />
-    <PackageReference Include="WCS.Entity" Version="1.0.1" />
+    <PackageReference Include="WCS.Core" Version="1.0.0.7" />
+    <PackageReference Include="WCS.Entity" Version="1.0.1.1" />
   </ItemGroup>
 
 </Project>

+ 14 - 20
WCS.Core/ProtocolProxyBase.cs

@@ -1,29 +1,21 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
-using System.Linq;
-using System.Net.Sockets;
+using System.ComponentModel.DataAnnotations;
 using System.Reflection;
 using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Channels;
-using System.Threading.Tasks;
 
 namespace WCS.Core
 {
     public abstract class ProtocolProxyBase : IProtocolProxy
     {
-        string Id = Guid.NewGuid().ToString();
+        private string Id = Guid.NewGuid().ToString();
         public ProtocolInfo Info { get; private set; }
         public ushort BytesCount { get; private set; }
-        Dictionary<string, PlcItem> Items = new Dictionary<string, PlcItem>();
-        Type ProtocolType, ProtocolDataType;
+        private Dictionary<string, PlcItem> Items = new Dictionary<string, PlcItem>();
+        private Type ProtocolType, ProtocolDataType;
         public Device Device { get; private set; }
 
-        DataBlock Db;
+        private DataBlock Db;
 
-        public ProtocolProxyBase(Device dev, ProtocolInfo info,Type protocolType)
+        public ProtocolProxyBase(Device dev, ProtocolInfo info, Type protocolType)
         {
             this.Device = dev;
             this.Info = info;
@@ -31,7 +23,6 @@ namespace WCS.Core
             Db.DbChanged += Db_DbChanged;
             ProtocolType = protocolType;
 
-
             var bitStart = info.Position * 8;//偏移量,按位算
 
             //this.Start = start;
@@ -71,7 +62,7 @@ namespace WCS.Core
                     bitStart += modeNum - mod;
                 }
 
-                #endregion
+                #endregion 计算偏移量
 
                 byte arrlen = 0;
                 byte strLen = 0;
@@ -97,7 +88,8 @@ namespace WCS.Core
             ProtocolDataType = ProtocolType.Assembly.GetTypes().Where(v => v.IsClass).Where(v => v.GetInterface(ProtocolType.Name) != null && v != this.GetType()).First();
         }
 
-        byte[] Data = new byte[0];
+        private byte[] Data = new byte[0];
+
         private void Db_DbChanged(byte[] data)
         {
             var pos = Info.Position - Db.Start;
@@ -112,10 +104,12 @@ namespace WCS.Core
         protected abstract void DataChanged();
 
         #region
+
         public void AddEvent(string eventName, Delegate delgate)
         {
             throw new NotImplementedException();
         }
+
         public void RemoveEvent(string eventName, Delegate delgate)
         {
             throw new NotImplementedException();
@@ -131,13 +125,12 @@ namespace WCS.Core
             throw new NotImplementedException();
         }
 
-
         public T Get<T>(string propertyName)
         {
             var item = Items[propertyName] as PlcItem<T>;
             var res = item.Value;
             var channel = Ltc.GetChannel();
-            Device.World.OnInternalLog(channel, $"{propertyName}:{res}");
+            Device.World.OnInternalLog(channel, $"{Device.Code}:{propertyName}:{res}");
             return res;
         }
 
@@ -146,8 +139,9 @@ namespace WCS.Core
             var item = Items[propertyName] as PlcItem<T>;
             item.Value = value;
             var channel = Ltc.GetChannel();
-            Device.World.OnInternalLog(channel, $"{propertyName}={value}");
+            Device.World.OnInternalLog(channel, $"{Device.Code}:{propertyName}={value}");
         }
+
         #endregion
     }
 }

+ 1 - 1
WCS.Entity.Protocol/Station/IStation522.cs → WCS.Entity.Protocol/Station/IStation523.cs

@@ -5,7 +5,7 @@ namespace WCS.Entity.Protocol.Station
     /// <summary>
     /// 输送机状态读取协议
     /// </summary>
-    public interface IStation522 : IProtocol
+    public interface IStation523 : IProtocol
     {
         /// <summary>
         /// 警报

+ 1 - 1
WCS.Entity.Protocol/Station/WCS_Station523.cs

@@ -8,7 +8,7 @@ namespace WCS.Entity.Protocol.Station
     /// </summary>
     [SugarTable(nameof(WCS_Station523), "站台状态读取记录表")]
     [DataContract]
-    public class WCS_Station523 : WCS_PROTOCOLDATA, IStation522
+    public class WCS_Station523 : WCS_PROTOCOLDATA, IStation523
     {
         /// <summary>
         /// 警报

+ 1 - 1
WCS.Entity.Protocol/WCS.Entity.Protocol.csproj

@@ -7,7 +7,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="WCS.Entity" Version="1.0.1" />
+    <PackageReference Include="WCS.Entity" Version="1.0.1.1" />
   </ItemGroup>
 
 </Project>

+ 2 - 2
WCS.Entity/OBJ.cs

@@ -41,14 +41,14 @@ namespace WCS.Entity
         /// 更新用户
         /// 仅记录用户ID
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新用户", Length = 50)]
+        [SugarColumn(ColumnDescription = "更新用户", Length = 50, IsNullable = true)]
         public string EditWho { get; set; }
 
         /// <summary>
         /// 更新时间
         /// 更新数据时自动获取服务器时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新时间", UpdateServerTime = true)]
+        [SugarColumn(ColumnDescription = "更新时间", UpdateServerTime = true, IsNullable = true)]
         public DateTime EditTime { get; set; }
 
         /// <summary>

+ 5 - 5
WCS.Entity/WCS_AgvTaskInfo.cs

@@ -21,7 +21,7 @@ namespace WCS.Entity
         /// <summary>
         /// AGVID
         /// </summary>
-        [SugarColumn(ColumnDescription = "AGVID", Length = 20), DataMember(Order = 1)]
+        [SugarColumn(ColumnDescription = "AGVID", Length = 20, IsNullable = true), DataMember(Order = 1)]
         public string AgvID { get; set; }
 
         /// <summary>
@@ -55,14 +55,14 @@ namespace WCS.Entity
         /// <summary>
         /// 站台
         /// </summary>
-        [SugarColumn(ColumnDescription = "站台", Length = 20)]
+        [SugarColumn(ColumnDescription = "站台", Length = 20, IsNullable = true)]
         [DataMember(Order = 6)]
         public string Station { get; set; }
 
         /// <summary>
         /// 位置
         /// </summary>
-        [SugarColumn(ColumnDescription = "位置", Length = 20)]
+        [SugarColumn(ColumnDescription = "位置", Length = 20, IsNullable = true)]
         [DataMember(Order = 7)]
         public string Position { get; set; }
 
@@ -98,13 +98,13 @@ namespace WCS.Entity
         /// 更新用户
         /// 仅记录用户ID
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新用户", Length = 50)]
+        [SugarColumn(ColumnDescription = "更新用户", Length = 50, IsNullable = true)]
         public string EditWho { get; set; }
 
         /// <summary>
         /// 更新时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新时间")]
+        [SugarColumn(ColumnDescription = "更新时间", IsNullable = true)]
         public DateTime EditTime { get; set; }
     }
 

+ 4 - 3
WCS.Entity/WCS_PlcData.cs

@@ -9,9 +9,10 @@ namespace WCS.Entity
     /// </summary>
     [SugarTable(nameof(WCS_PlcData), "路径")]
     public class WCS_PlcData
-    { /// <summary>
-      /// ID
-      /// </summary>
+    {
+        /// <summary>
+        /// ID
+        /// </summary>
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "ID")]
         [Column(Order = 0)]
         public virtual int ID { get; set; }

+ 1 - 1
WCS.Entity/WCS_TaskDtl.cs

@@ -33,7 +33,7 @@ namespace WCS.Entity
         /// <summary>
         /// 下一个地址
         /// </summary>
-        [SugarColumn(ColumnDescription = "下一个地址")]
+        [SugarColumn(ColumnDescription = "下一个地址", IsNullable = true)]
         public string NextPoint { get; set; }
 
         /// <summary>

+ 6 - 6
WCS.Entity/WCS_TaskInfo.cs

@@ -48,13 +48,13 @@ namespace WCS.Entity
         /// <summary>
         /// 最后一个交互点
         /// </summary>
-        [SugarColumn(ColumnDescription = "最后一个交互点", Length = 20)]
+        [SugarColumn(ColumnDescription = "最后一个交互点", Length = 20, IsNullable = true)]
         public string LastInteractionPoint { get; set; }
 
         /// <summary>
         /// 下一个地址
         /// </summary>
-        [SugarColumn(ColumnDescription = "下一个地址", Length = 20)]
+        [SugarColumn(ColumnDescription = "下一个地址", Length = 20, IsNullable = true)]
         public string AddrNext { get; set; }
 
         /// <summary>
@@ -66,7 +66,7 @@ namespace WCS.Entity
         /// <summary>
         /// 楼层
         /// </summary>
-        [SugarColumn(ColumnDescription = "楼层")]
+        [SugarColumn(ColumnDescription = "楼层", IsNullable = true)]
         public int Floor { get; set; }
 
         /// <summary>
@@ -91,7 +91,7 @@ namespace WCS.Entity
         /// <summary>
         /// 开始时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "开始时间")]
+        [SugarColumn(ColumnDescription = "开始时间", IsNullable = true)]
         public DateTime? StartTime { get; set; }
 
         /// <summary>
@@ -201,14 +201,14 @@ namespace WCS.Entity
         /// 更新用户
         /// 仅记录用户ID
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新用户", Length = 50)]
+        [SugarColumn(ColumnDescription = "更新用户", Length = 50, IsNullable = true)]
         public string EditWho { get; set; }
 
         /// <summary>
         /// 更新时间
         /// 更新数据时自动获取服务器时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新时间", UpdateServerTime = true)]
+        [SugarColumn(ColumnDescription = "更新时间", UpdateServerTime = true, IsNullable = true)]
         public DateTime EditTime { get; set; }
 
         /// <summary>

+ 10 - 10
WCS.Entity/WCS_TaskOld.cs

@@ -24,43 +24,43 @@ namespace WCS.Entity
         /// <summary>
         /// 生产编码
         /// </summary>
-        [SugarColumn(ColumnDescription = "生产编码", Length = 50)]
+        [SugarColumn(ColumnDescription = "生产编码", Length = 50, IsNullable = true)]
         public string BarCode { get; set; }
 
         /// <summary>
         /// 任务类型
         /// </summary>
-        [SugarColumn(ColumnDescription = "任务类型")]
+        [SugarColumn(ColumnDescription = "任务类型", IsNullable = true)]
         public TaskType Type { get; set; }
 
         /// <summary>
         /// 任务状态
         /// </summary>
-        [SugarColumn(ColumnDescription = "任务状态")]
+        [SugarColumn(ColumnDescription = "任务状态", IsNullable = true)]
         public TaskStatus Status { get; set; }
 
         /// <summary>
         /// 起始地址
         /// </summary>
-        [SugarColumn(ColumnDescription = "起始地址", Length = 20)]
+        [SugarColumn(ColumnDescription = "起始地址", Length = 20, IsNullable = true)]
         public string AddrFrom { get; set; }
 
         /// <summary>
         /// 目标地址
         /// </summary>
-        [SugarColumn(ColumnDescription = "目标地址", Length = 20)]
+        [SugarColumn(ColumnDescription = "目标地址", Length = 20, IsNullable = true)]
         public string AddrTo { get; set; }
 
         /// <summary>
         /// 最后一个交互点
         /// </summary>
-        [SugarColumn(ColumnDescription = "最后一个交互点", Length = 20)]
+        [SugarColumn(ColumnDescription = "最后一个交互点", Length = 20, IsNullable = true)]
         public string LastInteractionPoint { get; set; }
 
         /// <summary>
         /// 下一个地址
         /// </summary>
-        [SugarColumn(ColumnDescription = "下一个地址", Length = 20)]
+        [SugarColumn(ColumnDescription = "下一个地址", Length = 20, IsNullable = true)]
         public string AddrNext { get; set; }
 
         /// <summary>
@@ -96,7 +96,7 @@ namespace WCS.Entity
         /// <summary>
         /// 开始时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "开始时间")]
+        [SugarColumn(ColumnDescription = "开始时间", IsNullable = true)]
         public DateTime? StartTime { get; set; }
 
         /// <summary>
@@ -200,13 +200,13 @@ namespace WCS.Entity
         /// 更新用户
         /// 仅记录用户ID
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新用户", Length = 50)]
+        [SugarColumn(ColumnDescription = "更新用户", Length = 50, IsNullable = true)]
         public string EditWho { get; set; }
 
         /// <summary>
         /// 更新时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "更新时间")]
+        [SugarColumn(ColumnDescription = "更新时间", IsNullable = true)]
         public DateTime EditTime { get; set; }
     }
 }

+ 1 - 0
WCS.Service/Systems/DataCollectionSysyem.cs

@@ -33,6 +33,7 @@ namespace WCS.Service.Systems
 
                 var plcData = new WCS_PlcData()
                 {
+                    AddWho = "WCS",
                     WAREHOUSE = ServiceHub.WarehouseName,
                     CONTENT = JsonConvert.SerializeObject(ConvList, null, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }),
                 };

+ 0 - 15
WCS.Service/Worker.cs

@@ -85,21 +85,6 @@ namespace WCS.Service
                 });
             };
             SqlSugarHelper.SetDb(new SqlSugarScope(connectionConfigs));
-            //SqlSugarHelper.SetDb(new SqlSugarScope(connectionConfigs, db =>
-            //{
-            //    db.GetConnectionScope(Wcsdb).Aop.OnLogExecuting = (sql, pars) =>
-            //    {
-            //        Console.WriteLine(db.GetConnectionScope(Wcsdb).Ado.Connection.ConnectionString + "\r\n " + sql);
-            //        Console.WriteLine();
-            //        Console.WriteLine();
-            //    };
-            //    db.GetConnectionScope(WcsDlog).Aop.OnLogExecuting = (sql, pars) =>
-            //    {
-            //        Console.WriteLine(db.GetConnectionScope(WcsDlog).Ado.Connection.ConnectionString + "\r\n " + sql);
-            //        Console.WriteLine();
-            //        Console.WriteLine();
-            //    };
-            //}));
 
             //³õʼ»¯Êý¾Ý¿â
             SqlSugarHelper.Do(db =>

+ 1 - 1
WCS.WorkEngineering/Extensions/DeviceExtension.cs

@@ -11,7 +11,7 @@ namespace WCS.WorkEngineering.Extensions
     {
         public static bool IsConv(this Device source)
         {
-            return source.HasProtocol(typeof(IStation521)) || source.HasProtocol(typeof(IStation520)) || source.HasProtocol(typeof(IStation522));
+            return source.HasProtocol(typeof(IStation521)) || source.HasProtocol(typeof(IStation520)) || source.HasProtocol(typeof(IStation523));
         }
 
         #region WCS_DEVICE扩展数据

+ 2 - 2
WCS.WorkEngineering/Systems/MainLineScanCode.cs

@@ -10,13 +10,13 @@ namespace WCS.WorkEngineering.Systems
     /// </summary>
     [BelongTo(typeof(SortingMainLineWorld))]
     [Description("主线扫码")]
-    public class MainLineScanCode : DeviceSystem<Device<IStation520, IStation521, IStation522>>
+    public class MainLineScanCode : DeviceSystem<Device<IStation520, IStation521, IStation523>>
     {
         protected override bool ParallelDo => throw new NotImplementedException();
 
         protected override bool SaveLogsToFile => throw new NotImplementedException();
 
-        public override void Do(Device<IStation520, IStation521, IStation522> obj)
+        public override void Do(Device<IStation520, IStation521, IStation523> obj)
         {
             throw new NotImplementedException();
         }

+ 8 - 8
WCS.WorkEngineering/Systems/SrmSystems.cs

@@ -22,30 +22,30 @@ namespace WCS.WorkEngineering.Systems
         /// <summary>
         /// 取货点设备集合
         /// </summary>
-        private List<Device<IStation520, IStation521, IStation522>> PickUpDevices;
+        private List<Device<IStation520, IStation521, IStation523>> PickUpDevices;
 
         /// <summary>
         /// 放货设备
         /// </summary>
-        private List<Device<IStation520, IStation521, IStation522>> PutDevices;
+        private List<Device<IStation520, IStation521, IStation523>> PutDevices;
 
         public SrmSystems()
         {
             //分拣库1
             PickUpDevices = World.Devices.Where(v => v.Code is "" or "")
-                                         .Select(v => new Device<IStation520, IStation521, IStation522>(v)).ToList();
+                                         .Select(v => new Device<IStation520, IStation521, IStation523>(v)).ToList();
             PutDevices = World.Devices.Where(v => v.Code is "" or "")
-                                         .Select(v => new Device<IStation520, IStation521, IStation522>(v)).ToList();
+                                         .Select(v => new Device<IStation520, IStation521, IStation523>(v)).ToList();
             //分拣库2
             PickUpDevices = World.Devices.Where(v => v.Code is "" or "")
-                                         .Select(v => new Device<IStation520, IStation521, IStation522>(v)).ToList();
+                                         .Select(v => new Device<IStation520, IStation521, IStation523>(v)).ToList();
             PutDevices = World.Devices.Where(v => v.Code is "" or "")
-                                         .Select(v => new Device<IStation520, IStation521, IStation522>(v)).ToList();
+                                         .Select(v => new Device<IStation520, IStation521, IStation523>(v)).ToList();
             //分拣库3
             PickUpDevices = World.Devices.Where(v => v.Code is "" or "")
-                                         .Select(v => new Device<IStation520, IStation521, IStation522>(v)).ToList();
+                                         .Select(v => new Device<IStation520, IStation521, IStation523>(v)).ToList();
             PutDevices = World.Devices.Where(v => v.Code is "" or "")
-                                         .Select(v => new Device<IStation520, IStation521, IStation522>(v)).ToList();
+                                         .Select(v => new Device<IStation520, IStation521, IStation523>(v)).ToList();
         }
 
         protected override bool ParallelDo => true;

+ 1 - 1
WCS.WorkEngineering/WCS.WorkEngineering.csproj

@@ -8,7 +8,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
-    <PackageReference Include="ServiceCenter" Version="1.0.1.2" />
+    <PackageReference Include="ServiceCenter" Version="1.0.1.4" />
   </ItemGroup>
 
   <ItemGroup>

+ 1 - 1
WCS.WorkEngineering/worlds/MainWorld.cs

@@ -63,7 +63,7 @@ namespace WCS.WorkEngineering.Worlds
                 foreach (var log in Logs)
                 {
                     var msg = $"--------------------{log.Time}[{Thread.CurrentThread.ManagedThreadId}]--------------------\n{log}\n";
-                    File.AppendAllText(Path.Combine(dir, $"{log.Channel.Item}.txt"), msg);
+                    File.AppendAllText(Path.Combine(dir, $"{log.Log.Message.Split(":")[0]}.txt"), msg);
                 }
             }