lss
2025-06-05 e1a97fc8b29f063e96e3ebbae2f07ee95b276069
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;
@@ -155,46 +156,79 @@
            }
        }
        public static Dictionary<string, DpjErrorInfo> DpjInfoDirectory = new Dictionary<string, DpjErrorInfo>();
        /// <summary>
        /// 井松叠盘机叠盘回库
        /// </summary>
        internal static void DpjTraffic()
        {
            string startBti = "CMB17-DP-001";
            var devices = Settings.deviceInfos.Where(a => a.deviceType == 1).ToList();
            //var db = new SqlHelper<object>().GetInstance();
            //var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0  && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList();
            try
            {
                var IsDp = S7Helper.ReadDpj(2001, S7.Net.VarType.Byte);
                var value = S7Helper.ReadDpj(2014, S7.Net.VarType.Int);
                if (value >= 1 && IsDp == 1)
                if (devices.Count > 0)
                {
                    //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);
                    //}
                    //创建过未完成的任务不发起请求
                    var mst = WCSHelper.GetTaskByStartloc(startBti);
                    if (mst == null)
                    foreach (var device in devices)
                    {
                        Traystacker(startBti, value, 2);
                    }
                    else
                    {
                        LogHelper.Info($"有执行中的叠盘回库任务{mst.S_CODE},不触发叠盘任务");
                    }
                        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();
                            //if (cntr.Count > 0)
                            //{
                            //    var cntrcodes = cntr.Select(a => a.S_CNTR_CODE).ToArray();
                            //    cntrcode = string.Join(",", cntrcodes);
                            //}
                            //创建过未完成的任务不发起请求
                            var mst = WCSHelper.GetTaskByStartloc(device.TN_Location);
                            if (mst == null)
                            {
                                Traystacker(device.TN_Location, value, 2);
                            }
                            else
                            {
                                LogHelper.Info($"有执行中的叠盘回库任务{mst.S_CODE},不触发叠盘任务");
                            }
                        }
                        else
                        {
                            LogHelper.Info($"叠盘机数量:{value},叠盘信号:{IsDp},不触发叠盘任务");
                        }
                        Thread.Sleep(8000);
                    }
                }
                else
                {
                    LogHelper.Info($"叠盘机数量:{value},叠盘信号:{IsDp},不触发叠盘任务");
                }
                Thread.Sleep(8000);
            }
            catch (Exception ex)
            {
                LogHelper.Error($"ReadDpj DpjTraffic:{ex}", ex);
            }
@@ -236,5 +270,13 @@
                LogHelper.Info($"空托返回  Error=>{ex.ToString()}");
            }
        }
        public class DpjErrorInfo
        {
            public string Address { get; set; }
            public string DeviceName { get; set; }
            public string ErrorInfo { get; set; }
        }
    }
}