Browse Source

改变配置

林豪 左 3 years ago
parent
commit
fce633f581

+ 4 - 3
Projects/永冠OPP/WCS.Entity.Protocol/BCR/WCS_BCR80.cs

@@ -1,4 +1,4 @@
-using System.ComponentModel.DataAnnotations;
+using SqlSugar;
 using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol.BCR
@@ -6,14 +6,15 @@ namespace WCS.Entity.Protocol.BCR
     /// <summary>
     /// 读码器读取协议
     /// </summary>
+    [SugarTable(nameof(WCS_BCR80), "读码器读取协议")]
     [DataContract]
     public class WCS_BCR80 : WCS_PROTOCOLDATA, IBCR80
     {
         /// <summary>
         /// 内容
         /// </summary>
+        [SugarColumn(ColumnDescription = "内容", Length = 130)]
         [DataMember(Order = 0)]
-        [StringLength(130)]
         public string Content { get; set; }
     }
-}
+}

+ 21 - 3
Projects/永冠OPP/WCS.Entity.Protocol/RGV/WCS_RGV520.cs

@@ -1,60 +1,78 @@
-using System.Runtime.Serialization;
+using SqlSugar;
+using System.Runtime.Serialization;
 using WCS.Entity.Protocol.RGV;
 
 namespace WCS.Entity.Protocol
 {
     /// <summary>
-    /// RGV 读取记录表 后缀 _1=1工位 _2=2工位 
+    /// RGV 读取记录表 后缀 _1=1工位 _2=2工位
     /// </summary>
+    [SugarTable(nameof(WCS_RGV520), "RGV 读取记录表 后缀 _1=1工位 _2=2工位 ")]
     [DataContract]
     public class WCS_RGV520 : WCS_PROTOCOLDATA, IRGV520
     {
+        [SugarColumn(ColumnDescription = "WCS任务号")]
         [DataMember(Order = 0)]
         public int TaskID_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "任务类型")]
         [DataMember(Order = 1)]
         public RGVTaskType TaskType_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "起始地址环穿RGV无起始地址,只有目标地址")]
         [DataMember(Order = 2)]
         public short StartPosition_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "目标地址")]
         [DataMember(Order = 3)]
         public short DestPosition_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "优先")]
         [DataMember(Order = 4)]
         public short Priority_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "备用")]
         [DataMember(Order = 5)]
         public short RES1_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "备用")]
         [DataMember(Order = 6)]
         public short RES2_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "触发")]
         [DataMember(Order = 7)]
         public int Trigger_1 { get; set; }
 
+        [SugarColumn(ColumnDescription = "WCS任务号")]
         [DataMember(Order = 8)]
         public int TaskID_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "任务类型")]
         [DataMember(Order = 9)]
         public RGVTaskType TaskType_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "起始地址环穿RGV无起始地址,只有目标地址")]
         [DataMember(Order = 10)]
         public short StartPosition_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "目标地址")]
         [DataMember(Order = 11)]
         public short DestPosition_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "优先")]
         [DataMember(Order = 12)]
         public short Priority_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "备用")]
         [DataMember(Order = 13)]
         public short RES1_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "备用")]
         [DataMember(Order = 14)]
         public short RES2_2 { get; set; }
 
+        [SugarColumn(ColumnDescription = "触发")]
         [DataMember(Order = 15)]
         public int Trigger_2 { get; set; }
     }
-}
+}

+ 10 - 14
Projects/永冠OPP/WCS.Entity.Protocol/WCS_AGVTask.cs

@@ -1,6 +1,5 @@
 using SqlSugar;
 using System;
-using System.ComponentModel.DataAnnotations;
 using System.Runtime.Serialization;
 
 namespace WCS.Entity.Protocol
@@ -27,73 +26,70 @@ namespace WCS.Entity.Protocol
         /// <summary>
         /// 任务类型
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "任务类型")]
         [DataMember(Order = 2)]
         public AGVTaskType TaskType { get; set; }
 
         /// <summary>
         /// WCS AGV任务状态
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "WCS AGV任务状态")]
         [DataMember(Order = 3)]
         public AGVTaskStatus Status { get; set; }
 
         /// <summary>
         /// AGV自身状态
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "AGV自身状态")]
         [DataMember(Order = 4)]
         public AGVTaskStatus AGVStatus { get; set; }
 
         /// <summary>
         /// 车间
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "车间")]
         [DataMember(Order = 5)]
         public int Workshop { get; set; }
 
         /// <summary>
         /// 站台
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "站台", Length = 20)]
         [DataMember(Order = 6)]
-        [StringLength(20)]
         public string Station { get; set; }
 
         /// <summary>
         /// 位置
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "位置", Length = 20)]
         [DataMember(Order = 7)]
-        [StringLength(20)]
-        [Required]
         public string Position { get; set; }
 
         /// <summary>
         /// 货物数量(1.两个位置放1个货物,2.两个位置放2个货物)
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "货物数量(1.两个位置放1个货物,2.两个位置放2个货物)")]
         [DataMember(Order = 11)]
         public int Goodsnum { get; set; }
 
         /// <summary>
         /// 创建时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "创建时间")]
         [DataMember(Order = 8)]
         public DateTime CreateTime { get; set; }
 
         /// <summary>
         /// WCS更新时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "WCS更新时间")]
         [DataMember(Order = 9)]
         public DateTime? UpdateTime { get; set; }
 
         /// <summary>
         /// AGV更新时间
         /// </summary>
-        [SugarColumn(ColumnDescription = "")]
+        [SugarColumn(ColumnDescription = "AGV更新时间")]
         [DataMember(Order = 10)]
         public DateTime? AGVUpdateTime { get; set; }
 

+ 9 - 4
Projects/永冠OPP/WCS.Entity.Protocol/WCS_StatusLog.cs

@@ -1,42 +1,47 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using SqlSugar;
 
 namespace WCS.Entity.Protocol
 {
     /// <summary>
     /// 任务状态变更记录
     /// </summary>
+    [SugarTable(nameof(WCS_StatusLog), "任务状态变更记录")]
     public class WCS_StatusLog : OBJ
     {
         /// <summary>
         /// 关联任务ID
         /// </summary>
+        [SugarColumn(ColumnDescription = "关联任务ID")]
         public int WCS_TASKID { get; set; }
 
         /// <summary>
         /// 新的状态
         /// </summary>
+        [SugarColumn(ColumnDescription = "新的状态")]
         public TaskStatus NewStatus { get; set; }
 
         /// <summary>
         /// 旧的状态
         /// </summary>
+        [SugarColumn(ColumnDescription = "旧的状态")]
         public TaskStatus OldStatus { get; set; }
 
         /// <summary>
         /// 上传的状态
         /// </summary>
+        [SugarColumn(ColumnDescription = "上传的状态")]
         public TaskStatus upStatus { get; set; }
 
         /// <summary>
         /// 产生本次变化的节点
         /// </summary>
+        [SugarColumn(ColumnDescription = "产生本次变化的节点")]
         public string Node { get; set; }
 
         /// <summary>
-        /// 变化的内容 
+        /// 变化的内容
         /// </summary>
+        [SugarColumn(ColumnDescription = "变化的内容")]
         public string msg { get; set; }
     }
 }

+ 0 - 874
Projects/永冠OPP/WCS.Service/Extensions/DeviceExtension.cs

@@ -1,874 +0,0 @@
-using Logs;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using WCS.Core;
-using WCS.Entity;
-using WCS.Entity.Protocol;
-using WCS.Entity.Protocol.RGV;
-
-namespace WCS.Service.Extensions
-{
-    /// <summary>
-    /// 输送机设备组
-    /// </summary>
-    public class StationDeviceGroup : DeviceGroup<IStation520, IStation521, IStation523>
-    {
-        /// <summary>
-        /// 当前设备可用的RGV
-        /// </summary>
-        private static readonly List<RGVDevice> AllRgvList;
-
-        static StationDeviceGroup()
-        {
-            AllRgvList = Device.Where(v => v.IsRGV() && v.CODE != "RGV8").Select(v => v.Create<RGVDevice>()).ToList();
-        }
-
-        public StationDeviceGroup(WCS_DEVICE entity) : base(entity)
-        {
-        }
-
-        /// <summary>
-        /// 执行输送机设备组任务 单例锁
-        /// </summary>
-        /// <param name="act"></param>
-        public void EX(Action<StationDeviceGroup> act)
-        {
-            var key = $"WCS:Lock:{Entity.CODE}";
-            try
-            {
-                if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"[{Entity.CODE}]--触发并发管控");
-                ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                act(this);
-            }
-            catch (DoException ex)
-            {
-                ex.DoExceptionEX(Entity);
-            }
-            catch (WarnException ex)
-            {
-                ex.WarnExceptionEX(Entity);
-            }
-            catch (Exception ex)
-            {
-                ex.ExceptionEx(Entity);
-            }
-            finally
-            {
-                ProtocolProxy.Yg150Redis.Del(key);
-            }
-        }
-
-        /// <summary>
-        /// 当前设备可用的RGV
-        /// </summary>
-        public List<RGVDevice> RgvList
-        {
-            get
-            {
-                return AllRgvList.Where(v => v.LocationList.Any(p => p.Entity == Entity) && v.Data2.WorkMode != 0).ToList();
-            }
-        }
-
-        /// <summary>
-        /// 设备组自身的位置
-        /// </summary>
-        public float Position
-        {
-            get
-            {
-                return StationLocation.ALLlocations.FirstOrDefault(v => v.Station == Entity.CODE)!.Location;
-            }
-        }
-
-        /// <summary>
-        /// 设备组所在环穿的总长度
-        /// </summary>
-        public float Length
-        {
-            get
-            {
-                return StationLocation.ALLlocations.FirstOrDefault(v => v.Station == Entity.CODE)!.Length;
-            }
-        }
-
-        /// <summary>
-        /// 设备组是否满足任务执行条件
-        /// </summary>
-        /// <param name="type">给当前设备组下发任务时需要的请求</param>
-        /// <returns>true:不满足执行条件需要进行停止执行  false:表示满足条件不需要停止执行 </returns>
-        /// <exception cref="Exception"></exception>
-        public void WhetherToExecute(IstationRequest type = IstationRequest.无)
-        {
-            foreach (var item in Items)
-            {
-                if (item.Data.VoucherNo != item.Data2.VoucherNo) throw new WarnException($"等待{item.Entity.CODE}执行任务{item.Data.Tasknum},凭证号不一致");
-                if (item.Data3.Status.HasFlag(StationStatus.运行状态位)) throw new DoException($"{item.Entity.CODE}运行中");
-                if (!item.Data2.Status.HasFlag(IstationStatus.光电状态)) throw new DoException($"[{item.Entity.CODE}]无光电");
-            }
-        }
-
-        /// <summary>
-        /// 获取设备组中需要取货的设备
-        /// </summary>
-        /// <param name="obj"></param>
-        /// <returns></returns>
-        public List<Device<IStation520, IStation521, IStation523>> RgvGetTaskedDevice()
-        {
-            var a = Items.Where(v => v.Data2.Status.HasFlag(IstationStatus.光电状态) && v.Data2.Tasknum > 10000)
-                        .Where(v => v.Entity.CODE.ToShort() != v.Data2.Goodsend && v.Data2.Goodsend != 0)
-                        .ToList();
-            return a.Count == 0 ? null : a;
-        }
-
-        /// <summary>
-        /// 最近的RGV
-        /// </summary>
-        /// <returns></returns>
-        public RGVDevice RecentRgv()
-        {
-            return RgvList.MinBy(v => v.Distance(this));
-        }
-
-        /// <summary>
-        /// 计算目标RGV与站台自身的距离
-        /// </summary>
-        /// <param name="rgv"></param>
-        /// <returns></returns>
-        public float Distance(RGVDevice rgv)
-        {
-            return DevEX.Distance(Position, rgv.Position, Length);
-        }
-
-        /// <summary>
-        /// 计算两个站台之间的距离
-        /// </summary>
-        /// <param name="rgv"></param>
-        /// <returns></returns>
-        public float Distance(StationDeviceGroup dev)
-        {
-            return DevEX.Distance(Position, dev.Position, Length);
-        }
-
-        /// <summary>
-        /// 当前RGV
-        /// </summary>
-        /// <returns></returns>
-        public RGVDevice CurrentRGV()
-        {
-            //RGV与站台距离误差为 正负50
-            var max = Position + 500;
-            var min = Position - 500;
-            return RgvList?.FirstOrDefault(v => v.Data2.Position < max && v.Data2.Position > min);
-        }
-
-        /// <summary>
-        /// 是否需要RGV
-        /// </summary>
-        /// <returns>true:需要RGV false:不需要RGV</returns>
-        public bool NeedRgv()
-        {
-            var rgvs = Device.Where(v => v.IsRGV()).Select(v => v.Device<IRGV521>());
-            var code = Entity.CODE.Replace("G", "").ToShort();
-            if (rgvs.Any(v => v.Data.DestPosition_1 == code && v.Data.SystemStatus != RGVRunStatus.空闲))
-                throw new WarnException("已有RGV执行中");
-            foreach (var item in Items)
-            {
-                if (item.Data3.Status.HasFlag(StationStatus.运行状态位)) return false;
-                if (!item.Data2.Status.HasFlag(IstationStatus.光电状态)) return false;
-            }
-
-            return true;
-        }
-
-        /// <summary>
-        /// BCR 站点是否被禁止
-        /// </summary>
-        /// <returns></returns>
-        public void BcrStationIsForbid()
-        {
-            var config = ProtocolProxy.Ygwms150Redis.Get("ForbidTubuEnter").Split(",");
-            if (config.Contains(Entity.CODE)) throw new WarnException("当前入库口已被禁用,请联系机修人员了解具体情况");
-        }
-    }
-
-    /// <summary>
-    /// 输送机设备
-    /// </summary>
-    public class StationDevice : Device<IStation520, IStation521, IStation523>
-    {
-        public StationDevice(WCS_DEVICE entity) : base(entity)
-        {
-        }
-
-        /// <summary>
-        /// 设备组是否满足任务执行条件
-        /// </summary>
-        /// <param name="type">给当前设备组下发任务时需要的请求</param>
-        /// <returns>true:不满足执行条件需要进行停止执行  false:表示满足条件不需要停止执行 </returns>
-        /// <exception cref="Exception"></exception>
-        public void WhetherToExecute(IstationRequest type = IstationRequest.无)
-        {
-            //正在运行
-            if (Data3.Status.HasFlag(StationStatus.运行状态位)) throw new DoException("运行中");
-            //上一次的任务还未执行
-            if (Data.VoucherNo != Data2.VoucherNo)
-                throw new WarnException($"等待任务[{Data2.Tasknum}]执行");
-            //没有光电
-            if (!Data2.Status.HasFlag(IstationStatus.光电状态)) throw new DoException("无光电"); ;
-            //没有任务号
-            switch (type)
-            {
-                case IstationRequest.无:
-                    if (Data2.Tasknum < 10000 && Data.Tasknum < 10000)
-                        throw new WarnException($"设备无任务");
-                    break;
-
-                case IstationRequest.扫码入库:
-                    if (Data2.Tasknum > 10000 && Data.Tasknum > 10000)
-                        throw new WarnException($"设备已有任务任务");
-                    break;
-
-                case IstationRequest.堆垛机放货完成请求目标地址:
-                    if (Data2.Tasknum < 10000 && Data.Tasknum < 10000)
-                        throw new WarnException($"设备无任务信息");
-                    break;
-
-                case IstationRequest.请求分配目标地址:
-                    if (Data2.Tasknum < 10000 && Data.Tasknum < 10000)
-                        throw new WarnException($"设备无任务信息");
-                    break;
-            }
-            //没有请求
-            if (type != IstationRequest.无 && Data2.Request != type)
-                throw new WarnException($"有光电无{type}请求");
-        }
-
-        /// <summary>
-        /// 执行输送机任务 单例锁
-        /// </summary>
-        /// <param name="act"></param>
-        public void EX(Action<StationDevice> act)
-        {
-            var key = $"WCS:Lock:{Entity.CODE}";
-
-            try
-            {
-                if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"[{Entity.CODE}]--触发并发管控");
-                ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                act(this);
-            }
-            catch (DoException ex)
-            {
-                ex.DoExceptionEX(Entity);
-            }
-            catch (WarnException ex)
-            {
-                ex.WarnExceptionEX(Entity);
-            }
-            catch (Exception ex)
-            {
-                ex.ExceptionEx(Entity);
-            }
-            finally
-            {
-                ProtocolProxy.Yg150Redis.Del(key);
-            }
-        }
-    }
-
-    /// <summary>
-    /// RGV设备
-    /// </summary>
-    public class RGVDevice : Device<IRGV520, IRGV521, IRGV523>
-    {
-        static RGVDevice()
-        {
-            AllRGVList = Device.Where(v => v.IsRGV() && v.CODE != "RGV8").Select(v => v.Create<RGVDevice>()).ToList();
-        }
-
-        public RGVDevice(WCS_DEVICE entity) : base(entity)
-        {
-        }
-
-        /// <summary>
-        /// 所有环穿RGV
-        /// </summary>
-        private static List<RGVDevice> AllRGVList { get; set; }
-
-        /// <summary>
-        /// 与当前RGV处于同一环穿的RGV
-        /// </summary>
-        public List<RGVDevice> RGVList
-        {
-            get
-            {
-                return AllRGVList.Where(v => v.Entity.DEVICEPROTOCOLS.Any(d => Entity.DEVICEPROTOCOLS.Any(e => e.DB.PLC.IP == d.DB.PLC.IP)))
-                    .Where(v => v.Entity.CODE != Entity.CODE && v.Data2.WorkMode != 0).ToList();
-            }
-        }
-
-        /// <summary>
-        /// RGV当前位置
-        /// </summary>
-        public float Position
-        {
-            get
-            {
-                return Data2.Position;
-            }
-        }
-
-        /// <summary>
-        /// 与当前RGV处于同一环穿的站台
-        /// </summary>
-        public List<StationDeviceGroup> LocationList
-        {
-            get
-            {
-                return StationLocation.ALLlocations.Where(v => Entity.DEVICEPROTOCOLS.Any(p => p.DB.PLC.CODE == v.PLC))
-                                      .Select(v => Device.Find(v.Station).Create<StationDeviceGroup>()).ToList();
-            }
-        }
-
-        /// <summary>
-        /// 总长度
-        /// </summary>
-        public float Length
-        {
-            get
-            {
-                return LocationList.FirstOrDefault().Length;
-            }
-        }
-
-        /// <summary>
-        /// 执行RGV任务 单例锁
-        /// </summary>
-        /// <param name="act"></param>
-        public void EX(Action<RGVDevice> act)
-        {
-            var key = $"WCS:Lock:{Entity.CODE}";
-
-            try
-            {
-                if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"[{Entity.CODE}]--触发并发管控");
-                ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                act(this);
-            }
-            catch (DoException ex)
-            {
-                ex.DoExceptionEX(Entity);
-            }
-            catch (WarnException ex)
-            {
-                ex.WarnExceptionEX(Entity);
-            }
-            catch (Exception ex)
-            {
-                ex.ExceptionEx(Entity);
-            }
-            finally
-            {
-                ProtocolProxy.Yg150Redis.Del(key);
-            }
-        }
-
-        /// <summary>
-        /// 获取前一个取货点
-        /// </summary>
-        /// <returns></returns>
-        public StationDeviceGroup BeforeStation()
-        {
-            var a = LocationList.Where(v => v.Entity.Is(DF.涂布RGV取货设备组) || v.Entity.Is(DF.BOPPRGV取货设备组));
-            return LocationList.Where(v => v.Entity.Is(DF.涂布RGV取货设备组) || v.Entity.Is(DF.BOPPRGV取货设备组) && v.Entity.CODE != this.CurrentStation().Entity.CODE).OrderBy(v => Distance(v)).FirstOrDefault();
-        }
-
-        /// <summary>
-        /// 前一个RGV
-        /// </summary>
-        /// <returns></returns>
-        public RGVDevice Before()
-        {
-            //按照位置排序
-            var arr = RGVList.OrderBy(v => v.Position);
-            var rgv = arr.FirstOrDefault(v => v.Position > Position);
-            if (rgv == null)
-                rgv = arr.LastOrDefault(v => v.Position < Position);
-            return rgv;
-        }
-
-        /// <summary>
-        /// 后一个RGV
-        /// </summary>
-        /// <returns></returns>
-        public RGVDevice After()
-        {
-            //到当前RGV最近的一个RGV
-            return RGVList.OrderBy(v => v.Distance(this)).FirstOrDefault();
-        }
-
-        /// <summary>
-        /// 获取当前所在的取货站台
-        /// </summary>
-        /// <returns></returns>
-        public StationDeviceGroup CurrentStation()
-        {
-            return LocationList.Where(v => v.Entity.Is(DF.涂布RGV取货设备组) || v.Entity.Is(DF.涂布RGV放货设备组) || v.Entity.Is(DF.BOPPRGV取货设备组) || v.Entity.Is(DF.BOPPRGV放货设备组)).Where(v =>
-                {
-                    //RGV与站台距离误差为 正负50500
-                    var max = v.Position + 500;
-                    var min = v.Position - 500;
-                    return Data2.Position < max && Data2.Position > min;
-                }).FirstOrDefault();
-        }
-
-        /// <summary>
-        /// 计算当前RGV与指定RGV之间的距离
-        /// </summary>
-        /// <param name="rgv"></param>
-        /// <returns></returns>
-        public float Distance(RGVDevice rgv)
-        {
-            //return Math.Abs((Position - rgv.Position + Length) % Length);
-            return DevEX.Distance(Position, rgv.Position, Length);
-        }
-
-        /// <summary>
-        /// 计算当前RGV与指定站台之间的距离
-        /// </summary>
-        /// <param name="after"></param>
-        /// <returns></returns>
-        public float Distance(StationDeviceGroup after)
-        {
-            if (after == null) throw new WarnException($"不是一个有效的StationDeviceGroup,{Entity.CODE}");
-            return DevEX.Distance(Position, after.Position, Length);
-        }
-
-        /// <summary>
-        /// 是否需要执行放货任务
-        /// </summary>
-        /// <returns></returns>
-        public bool IsPut()
-        {
-            if (Data2.TaskType_1 != RGVTaskType.取货) return false;
-            if (!Data2.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.RGV到站)) return false;
-            if (!Data2.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.任务完成)) return false;
-            if (!Data2.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.光电)) return false;
-            return true;
-        }
-
-        /// <summary>
-        /// 写入移动任务
-        /// </summary>
-        /// <param name="addr">目标地址</param>
-        public void Move(StationDeviceGroup addr)
-        {
-            InfoLog.INFO_RGVINFO($"[{Entity.CODE}]--写入RGV移动任务-开始:{Data.TaskID_1},{Data.TaskType_1},{Data.DestPosition_1},{Data.Trigger_1}");
-            if (Data2.WorkMode != RGVMode.自动) throw new WarnException($"RGV状态{Data2.WorkMode},无法执行移动任务");
-            if (Data2.SystemStatus != RGVRunStatus.空闲) throw new WarnException($"rgv状态为{Data2.SystemStatus},无法执行移动任务");
-            if (Data2.Status_1.HasFlag(WCS.Entity.Protocol.RGVStatus.光电)) throw new WarnException("RGV有光电,无法执行移动任务");
-            Data.TaskID_1 = addr.Entity.CODE.GetShortCode();
-            Data.TaskType_1 = RGVTaskType.移动;
-            Data.DestPosition_1 = addr.Entity.CODE.GetShortCode();
-            Data.Trigger_1++;
-            InfoLog.INFO_RGVINFO($"[{Entity.CODE}]--写入RGV移动任务-结束:{Data.TaskID_1},{Data.TaskType_1},{Data.DestPosition_1},{Data.Trigger_1}");
-        }
-
-        /// <summary>
-        /// 写入取货任务
-        /// </summary>
-        /// <param name="addr">目标地址</param>
-        public void Pick(StationDeviceGroup addr, int task1 = 0, int task2 = 0)
-        {
-            InfoLog.INFO_RGVINFO($"[{Entity.CODE}]--写入RGV取货任务-开始:{Data.TaskID_1},{Data.TaskID_2},{Data.TaskType_1},{Data.DestPosition_1},{Data.Trigger_1}");
-            Data.TaskType_1 = RGVTaskType.取货;
-            Data.DestPosition_1 = addr.Entity.CODE.GetShortCode();
-            if (task1 != 0) Data.TaskID_1 = task1;
-            if (task2 != 0) Data.TaskID_2 = task2;
-            Data.Trigger_1++;
-            InfoLog.INFO_RGVINFO($"[{Entity.CODE}]--写入RGV取货任务-结束:{Data.TaskID_1},{Data.TaskID_2},{Data.TaskType_1},{Data.DestPosition_1},{Data.Trigger_1}");
-        }
-
-        /// <summary>
-        /// 写入放货任务
-        /// </summary>
-        /// <param name="addr">目标地址</param>
-        public void Put(StationDeviceGroup addr, int task1 = 0, int task2 = 0)
-        {
-            InfoLog.INFO_RGVINFO($"[{Entity.CODE}]--写入RGV放货任务-开始:{Data.TaskID_1},{Data.TaskID_2},{Data.TaskType_1},{Data.DestPosition_1},{Data.Trigger_1}");
-            Data.TaskType_1 = RGVTaskType.放货;
-            Data.DestPosition_1 = addr.Entity.CODE.GetShortCode();
-            if (task1 != 0) Data.TaskID_1 = task1;
-            if (task2 != 0) Data.TaskID_2 = task2;
-            Data.Trigger_1++;
-            InfoLog.INFO_RGVINFO($"[{Entity.CODE}]--写入RGV放货任务-结束:{Data.TaskID_1},{Data.TaskID_2},{Data.TaskType_1},{Data.DestPosition_1},{Data.Trigger_1}");
-        }
-
-        /// <summary>
-        /// 筛选出所有与当前RGV距离小于指定长度的RGV
-        /// </summary>
-        /// <param name="distance">指定长度</param>
-        /// <returns></returns>
-        public RGVDevice[] RgvAfter(float distance)
-        {
-            return RGVList.Where(v => Distance(v) < distance).ToArray();
-        }
-
-        /// <summary>
-        /// 当前RGV是否有拦住指定RGV
-        /// </summary>
-        /// <param name="rgv">RGV</param>
-        /// <returns></returns>
-        public bool StopedByMe(RGVDevice rgv)
-        {
-            //目标站台
-            var target = rgv.Data2.DestPosition_1;
-            //获取目标站台的设备组信息
-            var station = Device.Find($"G{target}").Create<StationDeviceGroup>();
-
-            if (station.Distance(rgv) < 5000) return false;
-
-            //当前RGV与目标站台的距离小于传入RGV到达目标站台的距离
-            return (this.Distance(station) < rgv.Distance(station)) || station.CurrentRGV()?.Entity.CODE == this.Entity.CODE;
-        }
-
-        /// <summary>
-        /// 获取当前RGV的下一个站台,即距离最近的一个站台
-        /// </summary>
-        /// <returns></returns>
-        public StationDeviceGroup NextStation()
-        {
-            //先取当前RGV与所有站台的距离
-            var dev = LocationList.OrderBy(v => v.Distance(this)).FirstOrDefault();
-            return dev;
-        }
-    }
-
-    /// <summary>
-    /// 堆垛机设备
-    /// </summary>
-    public class SRMDevice : Device<ISRM520, ISRM521, ISRM537>
-    {
-        public SRMDevice(WCS_DEVICE entity) : base(entity)
-        {
-        }
-
-        /// <summary>
-        /// 获取放货点
-        /// </summary>
-        public List<StationDevice> GetDeliveryPoint()
-        {
-            return Entity.ROUTES.Select(v => v.NEXT) //巷道
-                                .SelectMany(v => v.ROUTES.Select(d => d.NEXT)) //放货点
-                                .Where(v => v.IsConv()) //必须是输送线
-                                .Select(v => v.Create<StationDevice>()).ToList();
-        }
-
-        /// <summary>
-        /// 获取取货点
-        /// </summary>
-        public List<StationDevice> GetPickPoint()
-        {
-            return Device.Where(v => v.Is(DF.SRM二级品取货) || v.Is(DF.SRM涂布取货) || v.Is(DF.SRMBOPP取货))
-                         .Where(v => v.ROUTES.Any(p => p.NEXT.ROUTES.Any(d => d.NEXT == Entity)))
-                         .Select(v => v.Create<StationDevice>())
-                         .ToList();
-        }
-
-        /// <summary>
-        /// 处理完成任务
-        /// </summary>
-        public void FinishedTaskHandle()
-        {
-            WCS_TASK task = new WCS_TASK();
-        }
-
-        /// <summary>
-        /// 执行堆垛机任务 单例锁
-        /// </summary>
-        /// <param name="act"></param>
-        public void EX(Action<SRMDevice> act)
-        {
-            var key = $"WCS:Lock:{Entity.CODE}";
-
-            try
-            {
-                if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"[{Entity.CODE}]--触发并发管控");
-                ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                act(this);
-            }
-            catch (DoException ex)
-            {
-                ex.DoExceptionEX(Entity);
-            }
-            catch (WarnException ex)
-            {
-                ex.WarnExceptionEX(Entity);
-            }
-            catch (Exception ex)
-            {
-                ex.ExceptionEx(Entity);
-            }
-            finally
-            {
-                ProtocolProxy.Yg150Redis.Del(key);
-            }
-        }
-
-        /// <summary>
-        /// 执行出库任务 出库单例锁
-        /// </summary>
-        /// <param name="act"></param>
-        public void EXOutStock(Action<SRMDevice> act)
-        {
-            var key = "WCS:Lock:";
-            try
-            {
-                if (Entity.CODE == "SRM3" || Entity.CODE == "SRM4")
-                {
-                    key += "SRM3-SRM4-Out";
-                    if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"触发出库并发管控--[{Entity.CODE}]");
-                    ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                }
-                if (Entity.CODE == "SRM5" || Entity.CODE == "SRM6")
-                {
-                    key += "SRM5-SRM6-Out";
-                    if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"触发出库并发管控--[{Entity.CODE}]");
-                    ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                }
-
-                if (Entity.CODE == "SRM7" || Entity.CODE == "SRM8")
-                {
-                    key += "SRM7-SRM8-Out";
-                    if (ProtocolProxy.Yg150Redis.Get(key) != null) throw new WarnException($"触发出库并发管控--[{Entity.CODE}]");
-                    ProtocolProxy.Yg150Redis.Set(key, Entity.CODE);
-                }
-
-                act(this);
-            }
-            finally
-            {
-                if (Entity.CODE == "SRM3" || Entity.CODE == "SRM4") ProtocolProxy.Yg150Redis.Del($"{key}SRM3-SRM4-Out");
-                if (Entity.CODE == "SRM5" || Entity.CODE == "SRM6") ProtocolProxy.Yg150Redis.Del($"{key}SRM5-SRM6-Out");
-                if (Entity.CODE == "SRM7" || Entity.CODE == "SRM8") ProtocolProxy.Yg150Redis.Del($"{key}SRM7-SRM8-Out");
-            }
-        }
-
-        /// <summary>
-        /// 一工位写任务
-        /// </summary>
-        /// <param name="task"></param>
-        /// <param name="goodsnum">货物数量</param>
-        public void WriteTask1(Task task, short goodsnum)
-        {
-            InfoLog.INFO_SRMINFO($"出库--写入堆垛机[{Entity.CODE}]1工位-开始:[{Data.TaskID_1}][{Data.SLine_1}][{Data.SCol_1}][{Data.SLayer_1}][{Data.ELine_1}][{Data.VoucherNo_1}]--[{Data.RES1_1}]");
-            Data.TaskID_1 = task.ID;
-            Data.SLine_1 = task.Line;
-            Data.SCol_1 = task.Col;
-            Data.SLayer_1 = task.Layer;
-            Data.ELine_1 = task.SRMSTATION.ToShort();
-            Data.ECol_1 = 0;
-            Data.ELayer_1 = 0;
-            Data.RES1_1 = goodsnum;
-            Data.VoucherNo_1++;
-            InfoLog.INFO_SRMINFO($"出库--写入堆垛机[{Entity.CODE}]1工位-结束:[{Data.TaskID_1}][{Data.SLine_1}][{Data.SCol_1}][{Data.SLayer_1}][{Data.ELine_1}][{Data.VoucherNo_1}]--[{Data.RES1_1}]");
-        }
-
-        /// <summary>
-        /// 二工位写任务
-        /// </summary>
-        /// <param name="task"></param>
-        /// <param name="goodsnum">货物数量</param>
-        public void WriteTask2(Task task, short goodsnum)
-        {
-            InfoLog.INFO_SRMINFO($"出库--写入堆垛机[{Entity.CODE}]2工位-开始:[{Data.TaskID_2}][{Data.SLine_2}][{Data.SCol_2}][{Data.SLayer_2}][{Data.ELine_2}][{Data.VoucherNo_2}]--[{Data.RES1_2}]");
-            Data.TaskID_2 = task.ID;
-            Data.SLine_2 = task.Line;
-            Data.SCol_2 = task.Col;
-            Data.SLayer_2 = task.Layer;
-            Data.ELine_2 = task.SRMSTATION.ToShort();
-            Data.ECol_2 = 0;
-            Data.ELayer_2 = 0;
-            Data.RES1_2 = goodsnum;
-            Data.VoucherNo_2++;
-            InfoLog.INFO_SRMINFO($"出库--写入堆垛机[{Entity.CODE}]2工位-结束:[{Data.TaskID_2}][{Data.SLine_2}][{Data.SCol_2}][{Data.SLayer_2}][{Data.ELine_2}][{Data.VoucherNo_2}]--[{Data.RES1_2}]");
-        }
-
-        /// <summary>
-        /// 获取任务对应的货叉
-        /// </summary>
-        /// <param name="task">任务信息</param>
-        /// <param name="index">任务在下发任务集合中的索引</param>
-        /// <returns></returns>
-        public SrmFork GetFork(Task task, int index)
-        {
-            if (index > 1) throw new WarnException("一次最多下发两个任务");
-            //如果索引是1,直接返回货叉2
-            if (index == 1) return SrmFork.货叉2;
-
-            //判断任务列是多少
-            return task.Col switch
-            {
-                102 => Entity.CODE switch
-                {
-                    "SRM1" => SrmFork.货叉1,
-                    _ => SrmFork.货叉2,
-                },
-                112 => SrmFork.货叉2,
-                _ => SrmFork.货叉1,
-            };
-        }
-
-        /// <summary>
-        /// 检查同组堆垛机是否有出库任务正在执行
-        /// </summary>
-        public void CheckOutTask()
-        {
-        }
-    }
-
-    /// <summary>
-    /// 异常处理
-    /// </summary>
-    public static class DevEX
-    {
-        /// <summary>
-        /// 计算两点距离
-        /// </summary>
-        /// <param name="start">起始点</param>
-        /// <param name="end">结束点</param>
-        /// <param name="total">总长</param>
-        /// <returns></returns>
-        public static float Distance(float start, float end, float total)
-        {
-            float distance = 0;
-            if (start > end) distance = (total - start) + end;
-            else distance = end - start;
-            return distance;
-        }
-
-        public static void DoExceptionEX(this DoException ex, WCS_DEVICE Entity)
-        {
-            InfoLog.INFO_INFO($"[{Entity.CODE}]--{ex.Message}");
-        }
-
-        /// <summary>
-        /// 警报执行记录
-        /// </summary>
-        /// <param name="ex">警报信息</param>
-        /// <param name="Entity">发生设备</param>
-        /// <param name="reportMonitor">是否上报监控</param>
-        /// <exception cref="Exception"></exception>
-        public static void WarnExceptionEX(this WarnException ex, WCS_DEVICE Entity, bool reportMonitor = true)
-        {
-            InfoLog.INFO_WARN($"[{Entity.CODE}]--{ex.Message}");
-            if (ex.Message.Contains("The database operation was expected")) return;
-
-            Helpers.LogHelper.AddWCS_EXCEPTION(ex.Message, Entity.CODE, WCS_EXCEPTIONTYPE.无.ToString());
-            //排除部分频繁触发的异常上报
-            if (ex.Message.Contains("触发并发管控")) return;
-
-            if (reportMonitor)
-            {
-                Ltc.Log(ex.GetBaseException().Message);
-                throw new Exception($"[{Entity.CODE}]--{ex.Message}");
-            }
-        }
-
-        public static void ExceptionEx(this Exception ex, WCS_DEVICE Entity)
-        {
-            InfoLog.INFO_ERROR($"[{Entity.CODE}]--{ex.Message}--{ex.StackTrace}");
-            //排除部分频繁触发的异常上报
-            if (ex.Message.Contains("Collection was modified; enumeration operation may not execute.")) return;
-            Ltc.Log(ex.GetBaseException().Message);
-        }
-    }
-
-    /// <summary>
-    /// 堆垛机货叉/工位
-    /// </summary>
-    public enum SrmFork
-    {
-        货叉1 = 0,
-        货叉2 = 1,
-    }
-
-    /// <summary>
-    /// 站台位置信息
-    /// </summary>
-    public class StationLocation
-    {
-        /// <summary>
-        /// 所有环穿站台的信息
-        /// </summary>
-        public static List<StationLocation> ALLlocations { get; set; } = new List<StationLocation>();
-
-        static StationLocation()
-        {
-            ALLlocations.AddRange(new List<StationLocation>() {
-                new StationLocation("G1",486326,"RGV3",1567770),
-                new StationLocation("G2",693631,"RGV3",1567770),
-                new StationLocation("G3",789931,"RGV3",1567770),
-                new StationLocation("G4",961595,"RGV3",1567770),
-                new StationLocation("G5",1013350,"RGV3",1567770),
-                new StationLocation("G6",1069938,"RGV3",1567770),
-                new StationLocation("G7",1126338,"RGV3",1567770),
-                new StationLocation("G8",1178355,"RGV3",1567770),
-                new StationLocation("G9",1256875,"RGV3",1567770),
-                new StationLocation("G10",1313239,"RGV3",1567770),
-                new StationLocation("G11",1369970,"RGV3",1567770),
-                new StationLocation("G12",636770,"RGV1",3719290),
-                new StationLocation("G13",749520,"RGV1",3719290),
-                new StationLocation("G14",879930,"RGV1",3719290),
-                new StationLocation("G15",936310,"RGV1",3719290),
-                new StationLocation("G16",988000,"RGV1",3719290),
-                //new StationLocation("G17",1607000,"RGV1",3719290),
-                //new StationLocation("G18",1667000,"RGV1",3719290),
-                new StationLocation("G19",1785000,"RGV1",3719290),
-                //new StationLocation("G20",2548012,"RGV1",3719290),
-                //new StationLocation("G21",2606033,"RGV1",3719290),
-                //new StationLocation("G22",2660833,"RGV1",3719290),
-                new StationLocation("G23",2714350,"RGV1",3719290),
-            });
-        }
-
-        public StationLocation(string station, int location, string plc, int length)
-        {
-            Station = station;
-            Location = location;
-            PLC = plc;
-            Length = length;
-        }
-
-        /// <summary>
-        /// 输送机设备组编号
-        /// </summary>
-        public string Station { get; set; }
-
-        /// <summary>
-        /// 输送机在环轨中的位置
-        /// </summary>
-        public int Location { get; set; }
-
-        /// <summary>
-        /// 所属RGV组 PLC名称
-        /// </summary>
-        public string PLC { get; set; }
-
-        /// <summary>
-        /// 所属环穿轨道的长度
-        /// </summary>
-        public int Length { get; set; }
-    }
-
-    /// <summary>
-    /// 巷道信息
-    /// </summary>
-    public class TunnelInfo
-    {
-        public WCS_DEVICE Tunnel;
-        public WCS_DEVICE taskIN;
-        public Device<ISRM520, ISRM521, ISRM537> SRM;
-    }
-}

+ 0 - 158
Projects/永冠OPP/WCS.Service/Extensions/TaskExtension.cs

@@ -1,158 +0,0 @@
-using DBHelper_SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using WCS.Core;
-using WCS.Entity;
-using WCS.Service.Helpers;
-
-namespace WCS.Service.Extensions
-{
-    /// <summary>
-    /// 任务扩展
-    /// </summary>
-    public static class TaskExtension
-    {
-        public static T Create<T>(this WCS_TASK source)
-        {
-            return (T)Activator.CreateInstance(typeof(T), source);
-        }
-
-        /// <summary>
-        /// 获取可用的出库任务
-        /// </summary>
-        /// <param name="tasks"></param>
-        /// <returns></returns>
-        public static Task[] GetOutTask(this List<WCS_TASK> tasks)
-        {
-            var tasklist = tasks.Select(v => v.Create<Task>());
-            var task = tasklist.FirstOrDefault() ?? throw new WarnException("无可用出库任务--GetOutTask");
-            //AGV任务ID不为零表示为车间叫料任务
-            if (task.AGVTASKID != 0)
-            {
-                //按照AGV任务ID分一次组
-                tasklist = tasklist.OrderByDescending(v => v.Priority)
-                                   .ThenBy(v => v.CREATETIME)
-                                   .GroupBy(v => v.AGVTASKID)
-                                   .FirstOrDefault() ?? throw new WarnException("无可用叫料任务--GetOutTask");
-                //无论这个AGV任务绑定的货物相隔多远都必须要一起出出去
-                return tasklist.OrderBy(v => v.Col).ToArray();
-            }
-            return tasklist.OrderByDescending(v => v.Priority)
-                .GroupBy(v => v.MaterialCode).MinBy(v => v.Key)!
-                           .OrderByDescending(v => v.Priority)
-                           .ThenBy(v => v.Line)
-                           .ThenBy(v => v.Layer)
-                           .ThenBy(v => v.Col)
-                           .Take(2)
-                           .DistinctBy(v => v.Col)
-                           .OrderBy(v => v.Col)
-                           .ToArray();
-        }
-
-        /// <summary>
-        /// 获取出库任务的站台号及下一个地址
-        /// </summary>
-        /// <param name="task">任务</param>
-        /// <param name="srmFork">货叉</param>
-        public static void GetSrmStationAndaddNext(this WCS_TASK task, SrmFork srmFork)
-        {
-            //取任务巷道到达目标地址的下一个地址,即任务堆垛机的站台对应的设备组
-            var stations = Device.Where(v => v.DEVICEGROUP.Any(p => p.MEMBER == Device.Find(task.TUNNEL).GetPath(task.ADDRTO.Replace("G", ""))))
-                .Select(v => v.Create<StationDeviceGroup>())
-                .FirstOrDefault()!.Items
-                                 .OrderByDescending(v => v.Entity.CODE)
-                                 .ToArray();
-            //一工位放较大的站台号
-            switch (srmFork)
-            {
-                case SrmFork.货叉1:
-                    task.SRMSTATION = stations[0].Entity.CODE;
-                    task.ADDRNEXT = stations[0].Entity.GetPath(task.ADDRTO).CODE;
-                    break;
-
-                case SrmFork.货叉2:
-                    task.SRMSTATION = stations[1].Entity.CODE;
-                    task.ADDRNEXT = stations[1].Entity.GetPath(task.ADDRTO).CODE;
-                    break;
-            }
-        }
-
-        /// <summary>
-        /// 有效任务数是否符合任务组任务数
-        /// </summary>
-        /// <param name="tasks"></param>
-        /// <param name="executable"></param>
-        /// <param name="db"></param>
-        public static void ValidTaskCheck(this List<WCS_TASK> tasks, int executable, Db db)
-        {
-            var task = tasks.FirstOrDefault();
-            var taskCount = db.Default.Queryable<WCS_TASK>().Count(v => v.TaskGroupKey == task.TaskGroupKey && v.TYPE == TaskType.入库);
-            //开始检查任务数是否匹配
-            if (executable != taskCount) throw new WarnException($"可执行数{executable},任务组任务数{taskCount},数量不匹配,{task.ID}-{task.TaskGroupKey}");
-        }
-
-        /// <summary>
-        /// 有效任务数是否符合任务组任务数  临时
-        /// </summary>
-        /// <param name="tasks"></param>
-        /// <param name="executable"></param>
-        /// <param name="db"></param>
-        public static List<WCS_TASK> ValidTaskCheck(this List<FinishTaskList<string>> devs, Db db)
-        {
-            var taskIds = devs.Select(v => v.Station.Data2.Tasknum).ToList();
-            var taskList = db.Default.Queryable<WCS_TASK>().Where(v => taskIds.Contains(v.ID)).ToList();
-            var task = taskList.FirstOrDefault() ?? throw new WarnException($"ValidTaskCheck 无任务"); ;
-            var taskCount = db.Default.Queryable<WCS_TASK>().Count(v => v.TaskGroupKey == task.TaskGroupKey && v.TYPE == TaskType.入库);
-            //开始检查任务数是否匹配
-            if (devs.Count != taskCount) throw new WarnException($"可执行数{devs.Count},任务组任务数{taskCount},数量不匹配,{task.ID}-{task.TaskGroupKey}");
-            return taskList;
-        }
-
-        public static List<WCS_TASK> GetSrmValidTaskList(this IGrouping<string, WCS_TASK>[] taksList, SRMDevice srm, int index = 0)
-        {
-            return taksList[index].ToList();
-        }
-    }
-
-    public enum SrmIndex
-    {
-        工位一 = 0,
-        工位二 = 1,
-    }
-
-    public class Task : WCS_TASK
-    {
-        /// <summary>
-        /// 行
-        /// </summary>
-        public short Line { get; set; }
-
-        /// <summary>
-        /// 列
-        /// </summary>
-        public short Col { get; set; }
-
-        /// <summary>
-        /// 层
-        /// </summary>
-        public short Layer { get; set; }
-
-        public Task(WCS_TASK task)
-        {
-            var addrFrom = task.ADDRFROM.Split("-");
-            ADDRTO = task.ADDRTO;
-            TUNNEL = task.TUNNEL;
-            DEVICE = task.DEVICE;
-            Priority = task.Priority;
-            AGVTASKID = task.AGVTASKID;
-            CREATETIME = task.CREATETIME;
-            MaterialCode = task.MaterialCode;
-
-            ID = task.ID;
-            Line = addrFrom[0].ToShort();
-            Col = addrFrom[1].ToShort();
-            Layer = addrFrom[2].ToShort();
-        }
-    }
-}

+ 6 - 7
Projects/永冠OPP/WCS.Service/Extensions/TypeExtension.cs

@@ -7,7 +7,7 @@ namespace WCS.Service.Extensions
         /// <summary>
         /// 将字符串转换为short
         /// </summary>
-        /// <param name="txt">需要转换的字符串</param>
+        /// <param name="value">需要转换的字符串</param>
         /// <returns></returns>
         public static short ToShort(this string value)
         {
@@ -17,7 +17,7 @@ namespace WCS.Service.Extensions
         /// <summary>
         /// 将int转换为short
         /// </summary>
-        /// <param name="txt">需要转换的字符串</param>
+        /// <param name="value">需要转换的字符串</param>
         /// <returns></returns>
         public static short ToShort(this int value)
         {
@@ -27,7 +27,7 @@ namespace WCS.Service.Extensions
         /// <summary>
         /// 将decimal转换为short
         /// </summary>
-        /// <param name="txt">需要转换的字符串</param>
+        /// <param name="value">需要转换的字符串</param>
         /// <returns></returns>
         public static short ToShort(this decimal value)
         {
@@ -37,7 +37,7 @@ namespace WCS.Service.Extensions
         /// <summary>
         /// 将字符串转换为int
         /// </summary>
-        /// <param name="txt">需要转换的字符串</param>
+        /// <param name="value">需要转换的字符串</param>
         /// <returns></returns>
         public static int ToInt(this string value)
         {
@@ -51,8 +51,7 @@ namespace WCS.Service.Extensions
         /// <returns> true:是奇数   false:是偶数</returns>
         public static bool OddNumberOrEven(this short value)
         {
-            if (value % 2 == 0) return false;
-            else return true;
+            return value % 2 != 0;
         }
 
         /// <summary>
@@ -65,4 +64,4 @@ namespace WCS.Service.Extensions
             return value.Replace("G", "").ToShort();
         }
     }
-}
+}

+ 0 - 0
WCS.Core/Device.cs → Projects/永冠OPP/WCS.Service/Handlers/Device.cs


+ 34 - 0
Projects/永冠OPP/WCS.Service/Handlers/DeviceWork.cs

@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using WCS.Core;
+using WCS.Entity;
+
+namespace WCS.Service.Handlers
+{
+    /// <summary>
+    /// 设备工作器
+    /// </summary>
+    /// <typeparam name="T"></typeparam>
+    public abstract class DeviceWork<T> : Work<T> where T : EntityEx<WCS_DEVICE>
+    {
+        private readonly string[] _typenames;
+
+        protected DeviceWork()
+        {
+            _typenames = typeof(T).GenericTypeArguments.Select(v => v.AssemblyQualifiedName).ToArray();
+        }
+
+        protected abstract override void Do(T obj);
+
+        protected override sealed IEnumerable<T> InitObjects()
+        {
+            var arr = Device.Where(v => v.ENABLED && v.DEVICEPROTOCOLS.All(d => d.ENABLED && d.DB.ENABLED && d.DB.PLC.ENABLED))
+                .Where(v => _typenames.All(d => v.DEVICEPROTOCOLS.Any(e => e.DB.PROTOCOL == d)))
+                .Where(SelectDevice).ToArray();
+            var res = arr.Select(v => Activator.CreateInstance(typeof(T), v) as T);
+
+            return res;
+        }
+    }
+}

+ 33 - 0
Projects/永冠OPP/WCS.Service/Handlers/Work.cs

@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using WCS.Core;
+using WCS.Entity;
+
+namespace WCS.Service.Handlers
+{
+    public abstract class Work<T> : Work
+    {
+        public override sealed void Execute(object obj)
+        {
+            Do((T)obj);
+        }
+
+        public override sealed IEnumerable<object> GetObjs()
+        {
+            return InitObjects().OfType<object>().ToArray();
+        }
+
+        protected abstract void Do(T obj);
+
+        protected abstract bool SelectDevice(WCS_DEVICE dev);
+
+        protected virtual IEnumerable<T> InitObjects()
+        {
+            var arr = Device.Where(v => v.ENABLED)
+                .Where(SelectDevice).ToArray();
+            var res = arr.Select(v => (T)Activator.CreateInstance(typeof(T), v));
+            return res;
+        }
+    }
+}

+ 0 - 86
Projects/永冠OPP/WCS.Service/Helpers/FinishTaskList.cs

@@ -1,86 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using WCS.Service.Entity;
-using WCS.Service.Extensions;
-
-namespace WCS.Service.Helpers
-{
-    /// <summary>
-    /// 处理完成任务记录集合
-    /// </summary>
-    /// <typeparam name="T"></typeparam>
-    public class FinishTaskList<T>
-    {
-        public FinishTaskList(T finishCode, StationDevice station)
-        {
-            FinishCode = finishCode;
-            Station = station;
-        }
-
-        /// <summary>
-        /// 完成
-        /// </summary>
-        public T FinishCode { get; set; }
-
-        /// <summary>
-        /// 对应设备信息
-        /// </summary>
-        public StationDevice Station { get; set; }
-    }
-
-    /// <summary>
-    /// 处理完成任务记录集合
-    /// </summary>
-    /// <typeparam name="T"></typeparam>
-    public class FinishTaskList<T,T1>
-    {
-        public FinishTaskList(T finishCode, T1 station)
-        {
-            FinishCode = finishCode;
-            Station = station;
-        }
-
-        /// <summary>
-        /// 完成
-        /// </summary>
-        public T FinishCode { get; set; }
-
-        /// <summary>
-        /// 对应设备信息
-        /// </summary>
-        public T1 Station { get; set; }
-    }
-
-    public static class FinishTaskListExtensions
-    {
-        /// <summary>
-        /// 入库可用任务数是否有效
-        /// </summary>
-        /// <param name="finishes"></param>
-        /// <exception cref="WarnException"></exception>
-        public static void Valid(this List<FinishTaskList<string>> finishes)
-        {
-            var maxGoodsnum = finishes.Select(v => v.Station.Data2.Goodsnum).OrderByDescending(v => v).FirstOrDefault();
-            if (finishes.Count != maxGoodsnum) throw new WarnException($"可用货物数{finishes.Count},实际货物数{maxGoodsnum}");
-            if (!finishes.Any()) throw new DoException("没有任务");
-        }
-
-        /// <summary>
-        /// 入库可用任务数是否有效
-        /// </summary>
-        /// <param name="finishes"></param>
-        /// <exception cref="WarnException"></exception>
-        public static List<I_WCS_GetInTaskResponseItem> GetWMSInTask(this List<FinishTaskList<string>> finishes)
-        {
-            if (!finishes.Any()) throw new DoException("没有任务");
-            var items = finishes.ToArray();
-            var infos = items.Length switch
-            {
-                1 => WMS.I_WCS_GetInTask(items[0].FinishCode, items[0].Station.Entity.CODE),
-                2 => WMS.I_WCS_GetInTask(items[0].FinishCode, items[0].Station.Entity.CODE, items[1].FinishCode, items[1].Station.Entity.CODE),
-                _ => throw new WarnException($"一组任务数量最大为2,当前{items.Length}"),
-            };
-            return infos;
-        }
-    }
-}

+ 12 - 0
Projects/永冠OPP/WCS.Service/PLCAccessors/HuiChuangPLC.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace WCS.Service.PLCAccessors
+{
+    internal class HuiChuangPLC
+    {
+    }
+}

+ 9 - 1
Projects/永冠OPP/WCS.Service/WCS.Service.csproj

@@ -5,6 +5,14 @@
     <UserSecretsId>dotnet-WCS.Service-EBA9AC2B-E82A-472A-97B6-2D33DEFA8D48</UserSecretsId>
   </PropertyGroup>
 
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+    <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+  </PropertyGroup>
+
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
+    <CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
+  </PropertyGroup>
+
   <ItemGroup>
     <Compile Remove="DLL\**" />
     <Content Remove="DLL\**" />
@@ -30,7 +38,7 @@
     <PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.0" />
     <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.6" />
     <PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
-    <PackageReference Include="WCS.Core" Version="1.0.0.2" />
+    <PackageReference Include="WCS.Core" Version="1.0.0.3" />
   </ItemGroup>
 
   <ItemGroup>

+ 3 - 2
Projects/永冠OPP/WCS.Service/Worker.cs

@@ -16,6 +16,7 @@ using WCS.Core;
 using WCS.Core.DataTrans;
 using WCS.Entity;
 using WCS.Entity.Protocol;
+using WCS.Entity.Protocol.BCR;
 
 namespace WCS.Service
 {
@@ -75,8 +76,8 @@ namespace WCS.Service
                 db.Default.CodeFirst.InitTables(typeof(WCS_MAPPINGENTRY));
                 db.Default.CodeFirst.InitTables(typeof(WCS_USERS));
                 db.Default.CodeFirst.InitTables(typeof(WCS_StatusLog));
-                //db.Default.CodeFirst.InitTables(typeof(WCS_DATABLOCK));
-                //db.Default.CodeFirst.InitTables(typeof(WCS_DATABLOCK));
+                db.Default.CodeFirst.InitTables(typeof(WCS_BCR80));
+                db.Default.CodeFirst.InitTables(typeof(WCS_RGV520));
                 //db.Default.CodeFirst.InitTables(typeof(WCS_DATABLOCK));
                 //db.Default.CodeFirst.InitTables(typeof(WCS_DATABLOCK));
                 //db.Default.CodeFirst.InitTables(typeof(WCS_DATABLOCK));

+ 7 - 7
Projects/永冠OPP/WCS.Service/Works/RGV/RGVWorks.cs

@@ -1,16 +1,16 @@
 using WCS.Core;
 using WCS.Entity;
-using WCS.Service.Extensions;
+using WCS.Entity.Protocol;
 using WCS.Service.Handlers;
 
 namespace WCS.Service.Works.RGV
 {
     [WorkTitle(typeof(RGVHandler), "直穿RGV")]
-    public class 直穿RGV : DeviceWork<RGVDevice>
+    public class 直穿RGV : Work<IRGV520>
     {
         private const string Rgv8 = "RGV8";
 
-        protected override void Do(RGVDevice rgv)
+        protected override void Do(IRGV520 rgv)
         {
         }
 
@@ -21,9 +21,9 @@ namespace WCS.Service.Works.RGV
     }
 
     [WorkTitle(typeof(RGVHandler), "涂布环穿")]
-    public class 涂布环穿 : DeviceWork<RGVDevice>
+    public class 涂布环穿 : Work<IRGV520>
     {
-        protected override void Do(RGVDevice obj)
+        protected override void Do(IRGV520 obj)
         {
         }
 
@@ -34,9 +34,9 @@ namespace WCS.Service.Works.RGV
     }
 
     [WorkTitle(typeof(RGVHandler), "BOPP环穿")]
-    public class BOPP环穿 : DeviceWork<RGVDevice>
+    public class BOPP环穿 : Work<IRGV520>
     {
-        protected override void Do(RGVDevice obj)
+        protected override void Do(IRGV520 obj)
         {
         }
 

+ 5 - 5
Projects/永冠OPP/WCS.Service/Works/SRM/SRMWork.cs

@@ -1,26 +1,26 @@
 using System.Linq;
 using WCS.Core;
 using WCS.Entity;
-using WCS.Service.Extensions;
+using WCS.Entity.Protocol;
 using WCS.Service.Handlers;
 
 namespace WCS.Service.Works.SRM
 {
     [WorkTitle(typeof(SRMHandler), "堆垛机")]
-    internal class SRMWork : DeviceWork<SRMDevice>
+    internal class SRMWork : Work<ISRM520>
     {
         //月台发货需要的设备
-        private StationDevice[] DockDevs;
+        private ISRM520[] DockDevs;
 
         public SRMWork()
         {
             //只取设备组 设备过多,先写程序后填写
             DockDevs = new string[]
             {
-            }.Select(v => Device.Find(v)).SelectMany(v => v.DEVICEGROUP).Select(v => v.MEMBER.Create<StationDevice>()).ToArray();
+            }.Select(v => Device.Find(v)).SelectMany(v => v.DEVICEGROUP).Select(v => v.MEMBER.Create<ISRM520>()).ToArray();
         }
 
-        protected override void Do(SRMDevice obj)
+        protected override void Do(ISRM520 obj)
         {
         }
 

+ 7 - 6
Projects/永冠OPP/WCS.Service/Works/Station/BOPP入库.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using WCS.Core;
 using WCS.Entity;
+using WCS.Entity.Protocol;
 using WCS.Service.Extensions;
 using WCS.Service.Handlers;
 
@@ -10,9 +11,9 @@ namespace WCS.Service.Works.Station
     ///BOPP扫码入库
     /// </summary>
     [WorkTitle(typeof(BOPPHandler), "BOPP扫码入库")]
-    public class BOPP扫码入库 : Work<StationDeviceGroup>
+    public class BOPP扫码入库 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -26,9 +27,9 @@ namespace WCS.Service.Works.Station
     /// BOPP巷道分配
     /// </summary>
     [WorkTitle(typeof(BOPPHandler), "BOPP巷道分配")]
-    public class BOPP巷道分配 : Work<StationDeviceGroup>
+    public class BOPP巷道分配 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -42,9 +43,9 @@ namespace WCS.Service.Works.Station
     /// 涂布入库旋转台二次分配巷道
     /// </summary>
     [WorkTitle(typeof(BOPPHandler), "BOPP入库旋转台二次分配巷道")]
-    public class BOPP入库旋转台二次分配巷道 : Work<StationDeviceGroup>
+    public class BOPP入库旋转台二次分配巷道 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 

+ 10 - 21
Projects/永冠OPP/WCS.Service/Works/Station/一楼入库.cs

@@ -1,52 +1,42 @@
-using DBHelper;
-using Microsoft.EntityFrameworkCore;
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
+using System.Collections.Generic;
 using WCS.Core;
 using WCS.Entity;
 using WCS.Entity.Protocol;
-using WCS.Entity.Protocol.SRM;
-using WCS.Service.Extensions;
-using WCS.Service.Helpers;
+using WCS.Service.Handlers;
 
 namespace WCS.Service.Works.Station
 {
     [WorkTitle(typeof(ProductHandler), "扫码入库")]
-    internal class 扫码入库 : Work<StationDeviceGroup>
+    internal class 扫码入库 : Work<IStation520>
     {
         protected override bool SelectDevice(WCS_DEVICE dev)
         {
             return dev.CODE == "G1028";
         }
 
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
-           
         }
     }
 
     [WorkTitle(typeof(ProductHandler), "一楼分配巷道")]
-    internal class 巷道分配 : Work<StationDeviceGroup>
+    internal class 巷道分配 : Work<IStation520>
     {
         protected override bool SelectDevice(WCS_DEVICE dev)
         {
             return dev.CODE == "G1030";
         }
 
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
-         
         }
     }
 
     //[WorkTitle(typeof(ProductHandler), "一楼入库旋转台二次分配巷道")]
-    internal class 一楼入库旋转台二次分配巷道 : Work<StationDeviceGroup>
+    internal class 一楼入库旋转台二次分配巷道 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
-            
         }
 
         protected override bool SelectDevice(WCS_DEVICE dev)
@@ -58,11 +48,10 @@ namespace WCS.Service.Works.Station
     }
 
     [WorkTitle(typeof(ProductHandler), "一楼RGV放货结束分配目标地址")]
-    internal class 一楼RGV放货结束分配目标地址 : Work<StationDeviceGroup>
+    internal class 一楼RGV放货结束分配目标地址 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
-            
         }
 
         protected override bool SelectDevice(WCS_DEVICE dev)

+ 8 - 7
Projects/永冠OPP/WCS.Service/Works/Station/一楼出库.cs

@@ -1,14 +1,15 @@
 using System.Collections.Generic;
 using WCS.Core;
 using WCS.Entity;
-using WCS.Service.Extensions;
+using WCS.Entity.Protocol;
+using WCS.Service.Handlers;
 
 namespace WCS.Service.Works.Station
 {
     [WorkTitle(typeof(ProductHandler), "一楼出库堆垛机放货完成后分配下一个地址")]
-    public class 一楼出库 : Work<StationDeviceGroup>
+    public class 一楼出库 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -22,9 +23,9 @@ namespace WCS.Service.Works.Station
     }
 
     [WorkTitle(typeof(ProductHandler), "月台出货口完成任务")]
-    public class 月台完成任务 : Work<StationDeviceGroup>
+    public class 月台完成任务 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -37,9 +38,9 @@ namespace WCS.Service.Works.Station
     }
 
     [WorkTitle(typeof(ProductHandler), "转圈交互点分配目标地址")]
-    public class 转圈交互点分配目标地址 : Work<StationDeviceGroup>
+    public class 转圈交互点分配目标地址 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 

+ 8 - 8
Projects/永冠OPP/WCS.Service/Works/Station/涂布入库.cs

@@ -18,9 +18,9 @@ namespace WCS.Service.Works.Station
     /// 涂布入库AGV交互
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布入库AGV交互")]
-    public class 涂布入库AGV交互 : Work<StationDeviceGroup>
+    public class 涂布入库AGV交互 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
           
         }
@@ -35,9 +35,9 @@ namespace WCS.Service.Works.Station
     /// 涂布扫码入库
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布入库")]
-    public class 涂布扫码入库 : Work<StationDeviceGroup>
+    public class 涂布扫码入库 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
           
         }
@@ -52,9 +52,9 @@ namespace WCS.Service.Works.Station
     /// 涂布入库分配巷道
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布入库分配巷道")]
-    public class 涂布入库分配巷道 : Work<StationDeviceGroup>
+    public class 涂布入库分配巷道 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
            
         }
@@ -69,9 +69,9 @@ namespace WCS.Service.Works.Station
     /// 涂布入库旋转台二次分配巷道
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布入库旋转台二次分配巷道")]
-    public class 涂布入库旋转台二次分配巷道 : Work<StationDeviceGroup>
+    public class 涂布入库旋转台二次分配巷道 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
             
         }

+ 11 - 10
Projects/永冠OPP/WCS.Service/Works/Station/涂布出库.cs

@@ -1,6 +1,7 @@
 using System.Collections.Generic;
 using WCS.Core;
 using WCS.Entity;
+using WCS.Entity.Protocol;
 using WCS.Service.Extensions;
 using WCS.Service.Handlers;
 
@@ -10,9 +11,9 @@ namespace WCS.Service.Works.Station
     /// 涂布堆垛机放货分配目标地址
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布堆垛机放货分配目标地址")]
-    public class 涂布堆垛机放货分配目标地址 : Work<StationDeviceGroup>
+    public class 涂布堆垛机放货分配目标地址 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -28,9 +29,9 @@ namespace WCS.Service.Works.Station
     /// 涂布出库分配出库口
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布出库分配出库口")]
-    public class 涂布出库分配出库口 : Work<StationDeviceGroup>
+    public class 涂布出库分配出库口 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -46,9 +47,9 @@ namespace WCS.Service.Works.Station
     /// 涂布出库分配AGV取货点
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布出库分配AGV取货点")]
-    public class 涂布出库分配AGV取货点 : Work<StationDeviceGroup>
+    public class 涂布出库分配AGV取货点 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -62,9 +63,9 @@ namespace WCS.Service.Works.Station
     /// 涂布出库返回任务长度
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布出库返回任务长度")]
-    public class 涂布出库返回任务长度 : Work<StationDeviceGroup>
+    public class 涂布出库返回任务长度 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 
@@ -78,9 +79,9 @@ namespace WCS.Service.Works.Station
     /// 涂布叫料
     /// </summary>
     [WorkTitle(typeof(CoatingHandler), "涂布叫料")]
-    public class 涂布叫料 : Work<StationDeviceGroup>
+    public class 涂布叫料 : Work<IStation520>
     {
-        protected override void Do(StationDeviceGroup obj)
+        protected override void Do(IStation520 obj)
         {
         }
 

+ 2 - 45
WCS.Core/LogicHandler.cs

@@ -366,50 +366,7 @@ namespace WCS.Core
         public abstract void Execute(object obj);
     }
 
-    public abstract class Work<T> : Work
-    {
-        public override sealed void Execute(object obj)
-        {
-            Do((T)obj);
-        }
-
-        public override sealed IEnumerable<object> GetObjs()
-        {
-            return InitObjects().OfType<object>().ToArray();
-        }
-
-        protected abstract void Do(T obj);
-
-        protected abstract bool SelectDevice(WCS_DEVICE dev);
-
-        protected virtual IEnumerable<T> InitObjects()
-        {
-            var arr = Device.Where(v => v.ENABLED)
-                     .Where(SelectDevice).ToArray();
-            var res = arr.Select(v => (T)Activator.CreateInstance(typeof(T), v));
-            return res;
-        }
-    }
-
-    public abstract class DeviceWork<T> : Work<T> where T : EntityEx<WCS_DEVICE>
-    {
-        private readonly string[] _typenames;
-
-        protected DeviceWork()
-        {
-            _typenames = typeof(T).GenericTypeArguments.Select(v => v.AssemblyQualifiedName).ToArray();
-        }
+   
 
-        protected abstract override void Do(T obj);
-
-        protected override sealed IEnumerable<T> InitObjects()
-        {
-            var arr = Device.Where(v => v.ENABLED && v.DEVICEPROTOCOLS.All(d => d.ENABLED && d.DB.ENABLED && d.DB.PLC.ENABLED))
-                   .Where(v => _typenames.All(d => v.DEVICEPROTOCOLS.Any(e => e.DB.PROTOCOL == d)))
-                   .Where(SelectDevice).ToArray();
-            var res = arr.Select(v => Activator.CreateInstance(typeof(T), v) as T);
-
-            return res;
-        }
-    }
+   
 }

+ 7 - 3
WCS.Core/WCS.Core.csproj

@@ -2,15 +2,19 @@
 
   <PropertyGroup>
     <TargetFramework>net6.0</TargetFramework>
-    <AssemblyVersion>1.0.0.2</AssemblyVersion>
-    <FileVersion>1.0.0.2</FileVersion>
-    <Version>1.0.0.2</Version>
+    <AssemblyVersion>1.0.0.3</AssemblyVersion>
+    <FileVersion>1.0.0.3</FileVersion>
+    <Version>1.0.0.3</Version>
   </PropertyGroup>
 
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <OutputPath>D:\Source\WCS\DLL\</OutputPath>
   </PropertyGroup>
 
+  <ItemGroup>
+    <Content Remove="C:\Users\ZUOLINHAO\.nuget\packages\hslcommunication\6.2.2\contentFiles\any\netstandard2.0\Doc.txt" />
+  </ItemGroup>
+
   <ItemGroup>
     <PackageReference Include="DBHelper-SqlSugar" Version="1.0.0.1" />
     <PackageReference Include="FreeRedis" Version="0.3.5" />