lss
2025-06-26 011d17bc8df981ba31e895873ab0e4a17da8288f
HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/process/DeviceProcess.cs
@@ -7,6 +7,7 @@
using S7.Net;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using static HH.WCS.JiaTong.LISTA.process.HttpModel;
@@ -90,8 +91,9 @@
        /// </summary>
        internal static void Traffic()
        {
            Console.WriteLine("开始原材料叠盘位置判断");
            var db = new SqlHelper<object>().GetInstance();
            List<string> locs = new List<string>() { "LCDP-001" };
            List<string> locs = new List<string>() { "LCDP-001", "BADPW-01" };
            var location = db.Queryable<Location>().Where(a => locs.Contains(a.S_CODE)).ToList();
            if (location.Count > 0)
            {
@@ -104,8 +106,8 @@
                        var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == item.S_CODE).ToList();
                        if (cntr.Count > 0)
                        {
                            var cntrcodes = cntr.Select(a => a.S_CNTR_CODE).ToArray();
                            cntrcode = string.Join(",", cntrcodes);
                             cntrcode = cntr.OrderBy(a=>a.T_CREATE).First().S_CNTR_CODE;
                           // cntrcode = string.Join(",", cntrcodes);
                        }
                        //创建过未完成的任务不发起请求
@@ -125,7 +127,7 @@
        internal static void KjTraffic()
        {
            Console.WriteLine("开始井松agv叠盘回库位置判断");
            var db = new SqlHelper<object>().GetInstance();
            List<string> locs = new List<string>() { "PMDDW-001" };
            var location = db.Queryable<Location>().Where(a => locs.Contains(a.S_CODE)).ToList();
@@ -155,6 +157,8 @@
            }
        }
        public static Dictionary<string, DpjErrorInfo> DpjInfoDirectory = new Dictionary<string, DpjErrorInfo>();
        /// <summary>
        /// 井松叠盘机叠盘回库
        /// </summary>
@@ -169,9 +173,30 @@
                {
                    foreach (var device in devices)
                    {
                        var IsDp = S7Helper.ReadDpj(device.address,2001, S7.Net.VarType.Byte);
                        var value = S7Helper.ReadDpj(device.address,2014, S7.Net.VarType.Int);
                        var IsDp = S7Helper.ReadDpj(device.address, 2001, S7.Net.VarType.Byte);
                        var value = S7Helper.ReadDpj(device.address, 2014, S7.Net.VarType.Int);
                        var ErrorCode = S7Helper.ReadDpj(device.address, 2016, S7.Net.VarType.Int);
                        //记录叠盘机报错信息
                        if (DpjInfoDirectory.ContainsKey(device.address))
                        {
                            DpjInfoDirectory[device.address].Address = device.address;
                            DpjInfoDirectory[device.address].DeviceName = device.deviceName;
                            var ErrorInfo = Settings.dpjErrorInfos.Where(a => a.ErrorCode == ErrorCode).First();
                            if (ErrorInfo != null)
                            {
                                DpjInfoDirectory[device.address].ErrorInfo = ErrorInfo.ErrorInfo;
                            }
                        }
                        else
                        {
                            string errorinfo = "";
                            var ErrorInfo = Settings.dpjErrorInfos.Where(a => a.ErrorCode == ErrorCode).First();
                            if (ErrorInfo != null)
                            {
                                errorinfo = ErrorInfo.ErrorInfo;
                            }
                            DpjInfoDirectory.Add(device.address, new DpjErrorInfo() { Address = device.address, DeviceName = device.deviceName, ErrorInfo = errorinfo });
                        }
                        if (value >= 1 && IsDp == 1)
                        {
                            //var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == item.S_CODE).ToList();
@@ -191,7 +216,21 @@
                            {
                                LogHelper.Info($"有执行中的叠盘回库任务{mst.S_CODE},不触发叠盘任务");
                            }
                            //var loc = LocationHelper.GetLocByLoc(device.TN_Location);
                            //if (loc != null)
                            //{
                            //    if (loc.N_LOCK_STATE == 0) {
                            //        Traystacker(device.TN_Location, value, 2);
                            //    }
                            //    else
                            //    {
                            //        LogHelper.Info($"设备起点:{device.TN_Location}有锁,不生成任务");
                            //    }
                            //}
                            //else
                            //{
                            //    LogHelper.Info($"根据设备:{device.deviceName},起点:{device.TN_Location},未找到货位");
                            //}
                        }
                        else
                        {
@@ -200,10 +239,11 @@
                        Thread.Sleep(8000);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error($"ReadDpj DpjTraffic:{ex}", ex);
            }
@@ -245,5 +285,13 @@
                LogHelper.Info($"空托返回  Error=>{ex.ToString()}");
            }
        }
        public class DpjErrorInfo
        {
            public string Address { get; set; }
            public string DeviceName { get; set; }
            public string ErrorInfo { get; set; }
        }
    }
}