111
cjs
2025-06-10 f4302a3078545c8e3e2075bdfd4b01804dc79a5b
ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs
@@ -128,7 +128,8 @@
                                                    if (trayCode.errCode == 0 && trayCode.result.Length == 80)
                                                    {
                                                        //获取托盘码等信息  读取通道 10、11、12的数据作为托盘码   读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表
                                                        GetMachineData(pmInfo, trayCode.result);
                                                        string location = "";
                                                        GetMachineData(pmInfo,ref location, trayCode.result);
                                                        var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                        if (tray != null && tray.addState == 0)
                                                        {
@@ -182,7 +183,16 @@
                                                if (trayCode.errCode == 0 && trayCode.result.Length == 95)
                                                {
                                                    //获取托盘码等信息  读取通道 11、12、13的数据作为托盘码   读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表
                                                    GetMachineData(pmInfo, trayCode.result, false, "1");
                                                    string flLoc = "";
                                                    string location = "";
                                                    GetMachineData(pmInfo,ref location, trayCode.result, false, "1");
                                                    if (pmInfo.location.Contains("FLZT"))
                                                    {
                                                        flLoc = pmInfo.location;
                                                        pmInfo.location = location;
                                                    }
                                                    var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                    if (tray != null)
                                                    {
@@ -219,6 +229,7 @@
                                                            {
                                                                CMMLog.Info($"物料编码:{tray.materialCode},批次号:{tray.lotNo}");
                                                                string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1);
                                                                pmInfo.location = !string.IsNullOrEmpty(flLoc) ? flLoc : pmInfo.location;
                                                                HHAmsExecuteResult req = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), pmInfo.location, PlcBit02, "3楼包装取料", 0, tray.trayCode, timeStamp);
                                                                ProcessHelper.deleteInfo(pmInfo.location + "-包装下线");
                                                                //包装取料卸货完成,设备生产数量加一
@@ -378,7 +389,8 @@
                                                    if (trayCode.errCode == 0 && trayCode.result.Length == 80)
                                                    {
                                                        //获取托盘码等信息  读取通道 10、11、12的数据作为托盘码   读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表
                                                        GetMachineData(pmInfo, trayCode.result);
                                                        string location = "";
                                                        GetMachineData(pmInfo,ref location, trayCode.result);
                                                        var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                        if (tray != null && tray.addState == 0)
                                                        {
@@ -432,7 +444,14 @@
                                                if (trayCode.errCode == 0 && trayCode.result.Length == 95)
                                                {
                                                    //获取托盘码等信息  读取通道 11、12、13的数据作为托盘码   读取其它通道 重量 叠包等信息 所有数据存入MachineInfo表
                                                    GetMachineData(pmInfo, trayCode.result, false, "2");
                                                    string flLoc = "";
                                                    string location = "";
                                                    GetMachineData(pmInfo,ref location, trayCode.result, false, "2");
                                                    if (pmInfo.location.Contains("FLZT"))
                                                    {
                                                        flLoc = pmInfo.location;
                                                        pmInfo.location = location;
                                                    }
                                                    var tray = MongoDBSingleton.Instance.FindOne<MachineInfo>(Query.EQ("machineNo", pmInfo.location), "MachineInfo");
                                                    if (tray != null)
                                                    {
@@ -468,6 +487,7 @@
                                                            {
                                                                CMMLog.Info($"物料编码:{tray.materialCode},批次号:{tray.lotNo}");
                                                                string timeStamp = ProcessHelper.GetTimeStamp(31, 1, 1);
                                                                pmInfo.location = !string.IsNullOrEmpty(flLoc) ? flLoc : pmInfo.location;
                                                                HHAmsExecuteResult req;
                                                                if (pmInfo.deviceType == "22")
                                                                {
@@ -2747,7 +2767,7 @@
        /// <param name="info"></param>
        /// <param name="result"></param>
        /// <param name="noPack">true : MES交互方式  false : 无MES交互方式</param>
        private static void GetMachineData(Settings.PlcInfo pmInfo,int[] result ,bool noPack = true,string isOne = "")
        private static void GetMachineData(Settings.PlcInfo pmInfo, ref string loc, int[] result ,bool noPack = true,string isOne = "")
        {
            //Console.WriteLine($"进入数据处理流程!");
            CMMLog.Info($"进入数据处理流程!");
@@ -2755,6 +2775,7 @@
            string empCode = RemoveNull(GetTrayCode(result.Take(5).ToArray()));//员工编码
            string trayCode = RemoveNull(GetTrayCode(result.Skip(5).Take(3).ToArray()));//托盘码
            string location = RemoveNull(GetTrayCode(result.Skip(8).Take(1).ToArray()));//设备货位编码
            loc = location;
            #region 2024-12-30 变更 加入mes生产订单编号 分录ID   变更注释
            string orderCode = ""; //生产订单编号
            int fEntryID = 0; //分录ID
@@ -4457,6 +4478,96 @@
            CMMLog.Info($"在通道{plc.writeAddr + 2}中写入{JsonConvert.SerializeObject(num)},ip:{plc.ip},端口:{plc.port}");
        }
        /// <summary>
        /// 四钴A(洗板烘干机组)设备上空下满
        /// </summary>
        /// <param name="plc"></param>
        /// <exception cref="NotImplementedException"></exception>
        internal static void AMachine(Settings.PlcInfo plc)
        {
            if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location))
            {
                try
                {
                    var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel
                    {
                        dataNum = 1,
                        addr = plc.readAddr,
                        host = plc.ip,
                        port = plc.port
                    });
                    if (result != null && result.errCode == 0)
                    {
                        if (result.result[0] == 1)
                        {
                            //送空
                            bool req = WMSHelper.WMSOut(plc.location, "", "");
                            if (req) CMMLog.Debug($"四钴A设备 调用WMS获取空托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"四钴A设备 调用WMS获取空托出库生成任务失败!");
                        }
                        if (result.result[0] == 2)
                        {
                            //取满
                            string wmstaskno = "";
                            string traycode = "";
                            bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode);
                            if (req) CMMLog.Debug($"四钴A设备 调用WMS获取满托入库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"四钴A设备 调用WMS获取满托入库生成任务失败!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    CMMLog.Info($"四钴A设备 err:{ex.Message}");
                }
            }
        }
        /// <summary>
        /// 四钴C(钴板剪切机组)设备上满下空
        /// </summary>
        /// <param name="a"></param>
        /// <exception cref="NotImplementedException"></exception>
        internal static void CMachine(Settings.PlcInfo plc)
        {
            if (PickUpStartFree(plc.location) && PickUpEndFree(plc.location))
            {
                try
                {
                    var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel
                    {
                        dataNum = 1,
                        addr = plc.readAddr,
                        host = plc.ip,
                        port = plc.port
                    });
                    if (result != null && result.errCode == 0)
                    {
                        if (result.result[0] == 1)
                        {
                            //送满
                            bool req = WMSHelper.WMSOut(plc.location, "", "");
                            if (req) CMMLog.Debug($"四钴C设备 调用WMS获取满托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"四钴C设备 调用WMS获取满托出库生成任务失败!");
                        }
                        if (result.result[0] == 2)
                        {
                            //取空
                            string wmstaskno = "";
                            string traycode = "";
                            bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode);
                            if (req) CMMLog.Debug($"四钴C设备 调用WMS获取空托入库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"四钴C设备 调用WMS获取空托入库生成任务失败!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    CMMLog.Info($"四钴C设备 err:{ex.Message}");
                }
            }
        }
        #endregion
        public class WMS_STOCK_VIEW