林豪 左 há 1 ano atrás
pai
commit
68df9e195d

+ 41 - 42
WCS.Core/System.cs

@@ -1,21 +1,16 @@
-using System;
-using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.ComponentModel;
+using System.Collections.Concurrent;
 using System.Diagnostics;
-using System.Linq;
 using System.Reflection;
-using System.Text;
-using System.Threading.Tasks; 
 
 namespace WCS.Core
 {
-    public abstract class SystemBase: DescriptionClass
+    public abstract class SystemBase : DescriptionClass
     {
         public World World { get; private set; }
+
         public SystemBase()
         {
-            var attr = this.GetType().GetCustomAttribute<BelongToAttribute>(); 
+            var attr = this.GetType().GetCustomAttribute<BelongToAttribute>();
             if (attr != null)
             {
                 var wt = attr.WorldType;
@@ -24,16 +19,14 @@ namespace WCS.Core
         }
 
         public abstract List<object> GetObjects();
+
         public abstract void Update(List<WorkTimes> list);
-         
     }
 
-   
-
     public abstract class SystemBase<T> : SystemBase
-    { 
+    {
         public List<T> Objects { get; set; }
-        
+
         /// <summary>
         /// 对所有Objects并行循环执行Do
         /// </summary>
@@ -55,12 +48,11 @@ namespace WCS.Core
             {
                 Parallel.ForEach(Objects, new ParallelOptions { MaxDegreeOfParallelism = 256 }, obj =>
                 {
-                    var sw= new Stopwatch();
+                    var sw = new Stopwatch();
                     sw.Start();
                     InvokeDo(obj);
                     sw.Stop();
                     list.AddSafe(new WorkTimes { Key = $"{obj?.ToString()}", Total = sw.ElapsedMilliseconds });
-
                 });
             }
             else
@@ -72,13 +64,11 @@ namespace WCS.Core
                     InvokeDo(obj);
                     sw.Stop();
                     list.AddSafe(new WorkTimes { Key = $"{obj?.ToString()}", Total = sw.ElapsedMilliseconds });
-
                 }
             }
-         
         }
-         
-        void InvokeDo(T obj)
+
+        private void InvokeDo(T obj)
         {
             var channel = new Channel
             {
@@ -88,11 +78,15 @@ namespace WCS.Core
                 Item = obj.ToString()
             };
             try
-            { 
+            {
+                if (channel.Item == "1")
+                {
+                    var a = 1;
+                }
                 Ltc.SetChannel(channel);
                 World.OnInternalLog(channel, "开始");
                 Do(obj);
-            } 
+            }
             catch (Exception ex)
             {
                 World.OnError(channel, ex);
@@ -105,11 +99,13 @@ namespace WCS.Core
         }
 
         public abstract List<T> Create();
+
         public abstract void Do(T obj);
+
         public override List<object> GetObjects()
         {
             return Objects.OfType<object>().ToList();
-        } 
+        }
     }
 
     public abstract class DeviceSystem<T> : SystemBase<T> where T : EntityEx<Device>
@@ -127,9 +123,9 @@ namespace WCS.Core
             }
 
             var types = t.GetGenericArguments();
-            var list= Device.All.Where(v => types.All(d => v.HasProtocol(d)))
+            var list = Device.All.Where(v => types.All(d => v.HasProtocol(d)))
                 .Where(v => Select(v))
-                .Select(v => Activator.CreateInstance(typeof(T), v,this.World)).OfType<T>().ToList();//此时才实例化Protocol
+                .Select(v => Activator.CreateInstance(typeof(T), v, this.World)).OfType<T>().ToList();//此时才实例化Protocol
             if (list.Count == 0)
             {
                 //throw new Exception($"{this.GetType().Name}未匹配到任何Device");
@@ -147,10 +143,10 @@ namespace WCS.Core
         //public abstract List<Device> CreateDevices();
     }
 
-
     public abstract class ServiceSystem<T, TR> : SystemBase
     {
-        ConcurrentQueue<Action<List<WorkTimes>>> Actions = new ConcurrentQueue<Action<List<WorkTimes>>>();
+        private ConcurrentQueue<Action<List<WorkTimes>>> Actions = new ConcurrentQueue<Action<List<WorkTimes>>>();
+
         public TR Invoke(T obj)
         {
             var flag = false;
@@ -160,12 +156,12 @@ namespace WCS.Core
                 var sw = new Stopwatch();
                 sw.Start();
                 try
-                { 
+                {
                     result = InvokeDo(obj);
                 }
                 finally
                 {
-                    sw.Stop(); 
+                    sw.Stop();
                     list.AddSafe(new WorkTimes { Key = $"{obj?.ToString()}", Total = sw.ElapsedMilliseconds });
                     flag = true;
                 }
@@ -173,21 +169,23 @@ namespace WCS.Core
             SpinWait.SpinUntil(() => flag);
             return result;
         }
+
         protected abstract TR Do(T obj);
+
         public override List<object> GetObjects()
         {
             return new List<object>();
         }
 
         public override void Update(List<WorkTimes> list)
-        { 
+        {
             while (Actions.TryDequeue(out var act))
             {
-                act(list); 
+                act(list);
             }
         }
-         
-        TR InvokeDo(T obj)
+
+        private TR InvokeDo(T obj)
         {
             var channel = new Channel
             {
@@ -198,25 +196,26 @@ namespace WCS.Core
             };
             try
             {
-                Ltc.SetChannel(channel);  
-                World.OnInternalLog(channel,"开始");
+                Ltc.SetChannel(channel);
+                World.OnInternalLog(channel, "开始");
                 return Do(obj);
-            } 
+            }
             catch (Exception ex)
-            { 
+            {
                 throw;
             }
             finally
             {
-                World.OnInternalLog(channel, "结束"); 
+                World.OnInternalLog(channel, "结束");
                 World.Publish();
             }
         }
     }
 
-    public abstract class ServiceSystem<T> :SystemBase
+    public abstract class ServiceSystem<T> : SystemBase
     {
-        ConcurrentQueue<Action<List<WorkTimes>>> Actions = new ConcurrentQueue<Action<List<WorkTimes>>>();
+        private ConcurrentQueue<Action<List<WorkTimes>>> Actions = new ConcurrentQueue<Action<List<WorkTimes>>>();
+
         public void Invoke(T obj)
         {
             Actions.Enqueue(list =>
@@ -230,14 +229,14 @@ namespace WCS.Core
                 finally
                 {
                     sw.Stop();
-                    list.AddSafe(new WorkTimes { Key = $"{obj?.ToString()}", Total = sw.ElapsedMilliseconds }); 
+                    list.AddSafe(new WorkTimes { Key = $"{obj?.ToString()}", Total = sw.ElapsedMilliseconds });
                 }
             });
         }
 
         protected abstract void Do(T obj);
 
-        void InvokeDo(T obj)
+        private void InvokeDo(T obj)
         {
             var channel = new Channel
             {

+ 20 - 0
WCS.WorkEngineering/Extensions/DeviceExtension.cs

@@ -177,6 +177,26 @@ namespace WCS.WorkEngineering.Extensions
             return barcode;
         }
 
+        /// <summary>
+        ///  获取历史扫码记录
+        /// </summary>
+        /// <returns></returns>
+        public static List<string> GetBcrCodeList(this IBCR83 bCR)
+        {
+            return new List<string>() {
+                bCR.BcrCode1.Trim('\0'),
+                bCR.BcrCode2.Trim('\0'),
+                bCR.BcrCode3.Trim('\0'),
+                bCR.BcrCode4.Trim('\0'),
+                bCR.BcrCode5.Trim('\0'),
+                bCR.BcrCode6.Trim('\0'),
+                bCR.BcrCode7.Trim('\0'),
+                bCR.BcrCode8.Trim('\0'),
+                bCR.BcrCode9.Trim('\0'),
+                bCR.BcrCode10.Trim('\0'),
+                bCR.BcrCode11.Trim('\0') };
+        }
+
         #endregion 设备扩展方法
     }
 

+ 1 - 19
WCS.WorkEngineering/Protocol/BCR/IBCR83.cs

@@ -46,24 +46,6 @@ namespace WCS.WorkEngineering.Protocol.BCR
         [StringLength(50)]
         public string BcrCode11 { get; set; }
 
-        /// <summary>
-        ///  获取历史扫码记录
-        /// </summary>
-        /// <returns></returns>
-        public List<string> GetBcrCodeList()
-        {
-            return new List<string>() {
-                BcrCode1.Trim('\0'),
-                BcrCode2.Trim('\0'),
-                BcrCode3.Trim('\0'),
-                BcrCode4.Trim('\0'),
-                BcrCode5.Trim('\0'),
-                BcrCode6.Trim('\0'),
-                BcrCode7.Trim('\0'),
-                BcrCode8.Trim('\0'),
-                BcrCode9.Trim('\0'),
-                BcrCode10.Trim('\0'),
-                BcrCode11.Trim('\0') };
-        }
+       
     }
 }

+ 15 - 2
WCS.WorkEngineering/Systems/湿拉满轮帘线芯股第一次扫码.cs

@@ -1,5 +1,8 @@
-using System.ComponentModel;
+using Newtonsoft.Json;
+using ServiceCenter.Redis;
+using System.ComponentModel;
 using WCS.Core;
+using WCS.WorkEngineering.Extensions;
 using WCS.WorkEngineering.Protocol.BCR;
 using WCS.WorkEngineering.Protocol.Station;
 using WCS.WorkEngineering.WebApi.Controllers;
@@ -21,9 +24,19 @@ namespace WCS.WorkEngineering.Systems
 
         public override void Do(Device<IStation520, IStation521, IStation523, IBCR83> obj)
         {
+            List<string> list = new List<string>();
+            for (int i = 0; i < 19; i++)
+            {
+                var a1 = RedisHub.Default.BRPop("EnteMainLine", 0);
+                var a2 = JsonConvert.DeserializeObject<List<string>>(a1);
+                list.AddRange(a2);
+            }
+            var a = list;
+            var b = a.Distinct();
+
             var bcrCodeList = obj.Data4.GetBcrCodeList();
             //获取当前站台对应的编码信息
-            //WmsApi.EnteMainLine(bcrCodeList);
+            WmsApi.EnteMainLine(bcrCodeList, obj.Entity.Code);
         }
 
         public override bool Select(Device dev)

+ 21 - 0
WCS.WorkEngineering/WebApi/Controllers/WmsApi.cs

@@ -396,5 +396,26 @@ namespace WCS.WorkEngineering.WebApi.Controllers
                 _ => "",
             };
         }
+
+        /// <summary>
+        ///  工字轮/芯股进入主线扫码
+        /// </summary>
+        /// <param name="reqDto"></param>
+        /// <param name="equNo"></param>
+        /// <returns></returns>
+        /// <exception cref="KnownException"></exception>
+        public static SRes EnteMainLine(List<string> reqDto, string equNo)
+        {
+            var res = APICaller.CallApi<SRes>(WMSUrl + "/api/FJ/EnteMainLine", new FJEnteMainLineRequest
+            {
+                IShapedWheelCodes = reqDto,
+                equNo = equNo
+            });
+            if (res.ResCode != ResponseStatusCodeEnum.Sucess)
+            {
+                throw new KnownException(res.ResMsg, LogLevelEnum.High);
+            }
+            return res;
+        }
     }
 }

+ 18 - 0
WCS.WorkEngineering/WebApi/Models/WMS/Request/FJEnteMainLineRequest.cs

@@ -0,0 +1,18 @@
+namespace WCS.WorkEngineering.WebApi.Models.WMS.Request
+{
+    /// <summary>
+    ///  工字轮/芯股进入主线扫码
+    /// </summary>
+    public class FJEnteMainLineRequest
+    {
+        /// <summary>
+        ///  工字轮条码集合
+        /// </summary>
+        public List<string> IShapedWheelCodes { get; set; }
+
+        /// <summary>
+        ///  设备号
+        /// </summary>
+        public string equNo { get; set; }
+    }
+}

+ 2 - 4
WCS.WorkEngineering/WorkStart.cs

@@ -86,8 +86,8 @@ namespace WCS.WorkEngineering
 
             List<StationSegmentInfo> segmentInfo1 = new List<StationSegmentInfo>
             {
-                //new StationSegmentInfo(1, 100, "10.30.37.166"),
-                //new StationSegmentInfo(401, 586, "10.30.37.166"),
+                new StationSegmentInfo(1, 100, "10.30.37.166"),
+                new StationSegmentInfo(401, 586, "10.30.37.166"),
             };
 
             foreach (var item in segmentInfo1)
@@ -307,8 +307,6 @@ namespace WCS.WorkEngineering
                 { DeviceFlags.一列堆垛机, new List<string>() { "SRM1"/*, "SRM3", "SRM5"*/} },
                 { DeviceFlags.二列堆垛机, new List<string>() { "SRM2"/*, "SRM4", "SRM6"*/ } },
                 {  DeviceFlags.一楼扫码,new List<string>(){ "2532","2732"} },
-                //{  DeviceFlags.满轮主线第一次扫码,new List<string>(){ "1"} },
-                //{  DeviceFlags.主线分流点,new List<string>(){ "22","41","61"} }
                 //{ DeviceFlags.称重, new List<string>() { "1011", "1013", "1015", "1025" } },
                 { DeviceFlags.一楼叠盘机,new List<string>() { "2527","2528","2727","2728"} }
             };