111
cjs
8 天以前 6fe4792f1f71389400d075b57fb613d7815b6783
ams/Hanhe.iWCS.JingmenGEMTwoProtocol/PLCControl.cs
@@ -731,7 +731,7 @@
        internal static void PickUpFullDoorComplete(string ip, string taskNo)
        {
            var plc = Settings.GetPlcInfo().Where(a => a.ip == ip).FirstOrDefault();
            if (plc != null && !plc.location.Contains("FLZT"))
            if (plc != null)
            {
                if (plc.location.Contains("FLZT"))
                {
@@ -755,7 +755,7 @@
                        data = 3,
                        port = plc.port
                    });
                    CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为4.");
                    CMMLog.Debug($"写入设备{plc.location}通道{plc.writeAddr + 1}里面数据为3.");
                }
            }
@@ -3978,6 +3978,50 @@
            }
        }
        /// <summary>
        /// 电钴接驳位入立库任务
        /// </summary>
        /// <param name="locCode"></param>
        internal static void DGInWarehouse(string locCode)
        {
            try
            {
                var locInfo = MongoDBSingleton.Instance.FindOne<DGConnectingBits>(Query.EQ("Bit", locCode), "DGConnectingBits");
                if (locInfo != null)
                {
                    if (locInfo.state == "1")
                    {
                        CMMLog.Info("DGInWarehouse:" + JsonConvert.SerializeObject(locInfo));
                        if (!string.IsNullOrEmpty(locInfo.END_LOC))
                        {
                            var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), locInfo.Bit, locInfo.END_LOC, "电钴生产退库(二段)", 0, locInfo.trayCode);
                            if(amsResult.success)
                            {
                                CMMLog.Info($"电钴生产退库(二段)流程:WMS生成任务成功!");
                                MongoDBSingleton.Instance.Update<DGConnectingBits>(Query.EQ("Bit", locCode), Update.Set("state", "2"), "DGConnectingBits", UpdateFlags.None);
                            }
                        }
                        else
                        {
                            string wmstaskno = "";
                            string trayCode = locInfo.trayCode;
                            bool req = WMSHelper.WMSIn(locCode, "电钴打包下线", ref wmstaskno, ref trayCode, "", "DGCK");
                            if (req)
                            {
                                CMMLog.Info($"电钴接驳位入立库流程:WMS生成任务成功!");
                                MongoDBSingleton.Instance.Update<DGConnectingBits>(Query.EQ("Bit", locCode), Update.Set("state", "2"), "DGConnectingBits", UpdateFlags.None);
                            }
                            else CMMLog.Info($"电钴接驳位入立库流程:WMS生成任务失败!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CMMLog.Info("DGInWarehouse" + ex.Message);
            }
        }
        internal static void outWare(string taskNo,bool flage)
        {
            var plc = Settings.GetPlcInfo().Where(a => a.Extend == "2" && a.enable == 1).FirstOrDefault();
@@ -4493,7 +4537,7 @@
        }
        /// <summary>
        /// 四钴A(洗板烘干机组)设备上空下满
        /// 电钴A(洗板烘干机组)设备上空下满
        /// </summary>
        /// <param name="plc"></param>
        /// <exception cref="NotImplementedException"></exception>
@@ -4516,8 +4560,8 @@
                        {
                            //送空
                            bool req = WMSHelper.WMSOut(plc.location, "", "");
                            if (req) CMMLog.Debug($"四钴A设备 调用WMS获取空托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"四钴A设备 调用WMS获取空托出库生成任务失败!");
                            if (req) CMMLog.Debug($"电钴A设备 调用WMS获取空托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"电钴A设备 调用WMS获取空托出库生成任务失败!");
                        }
                        if (result.result[0] == 2)
                        {
@@ -4525,20 +4569,20 @@
                            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获取满托入库生成任务失败!");
                            if (req) CMMLog.Debug($"电钴A设备 调用WMS获取满托入库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"电钴A设备 调用WMS获取满托入库生成任务失败!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    CMMLog.Info($"四钴A设备 err:{ex.Message}");
                    CMMLog.Info($"电钴A设备 err:{ex.Message}");
                }
            }
        }
        /// <summary>
        /// 四钴C(钴板剪切机组)设备上满下空
        /// 电钴C(钴板剪切机组)设备上满下空
        /// </summary>
        /// <param name="a"></param>
        /// <exception cref="NotImplementedException"></exception>
@@ -4561,8 +4605,8 @@
                        {
                            //送满
                            bool req = WMSHelper.WMSOut(plc.location, "", "");
                            if (req) CMMLog.Debug($"四钴C设备 调用WMS获取满托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"四钴C设备 调用WMS获取满托出库生成任务失败!");
                            if (req) CMMLog.Debug($"电钴C设备 调用WMS获取满托出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"电钴C设备 调用WMS获取满托出库生成任务失败!");
                        }
                        if (result.result[0] == 2)
                        {
@@ -4570,14 +4614,14 @@
                            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获取空托入库生成任务失败!");
                            if (req) CMMLog.Debug($"电钴C设备 调用WMS获取空托入库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                            else CMMLog.Debug($"电钴C设备 调用WMS获取空托入库生成任务失败!");
                        }
                    }
                }
                catch (Exception ex)
                {
                    CMMLog.Info($"四钴C设备 err:{ex.Message}");
                    CMMLog.Info($"电钴C设备 err:{ex.Message}");
                }
            }
        }
@@ -4607,7 +4651,7 @@
                    if (result.result[0] == 1)
                    {
                        //推送小车进入
                        TSHelper.GoToAGV(taskNo, 10, 3);
                        TSHelper.GoToAGV(taskNo, 10, 1);
                        writeRes = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel
                        {
                            host = plc.ip,
@@ -4695,65 +4739,78 @@
                        host = plc.ip,
                        port = plc.port
                    });
                    CMMLog.Debug($"包装机满托下线:读取通道号为:{plc.readAddr},ip:{plc.ip},端口:{plc.port}");
                    CMMLog.Debug($"包装机满托下线值为:{result.result[0]}");
                    if (result != null && result.errCode == 0)
                    {
                        if (result.result[0] == 1)
                        {
                            //成品下线任务生成到接驳平台
                            string traycode = DateTime.Now.ToString("yyyy-MM-dd").Replace("-", "");
                            //可生成任务
                            var CBInfo = Settings.GetConnectingbitsList().Where(a => a.enable == 1).ToList();
                            if (CBInfo != null)
                            string traycode = "";
                            var DGinfoList = MongoDBSingleton.Instance.FindAll<DGPackingLineFullModel>("DGPackingLineFullModel");
                            if (DGinfoList.Count > 0)
                            {
                                //string timeStamp = timecuo.data.First().timeStamp.ToString();
                                string timeStamp = "";
                                foreach (var a in CBInfo)
                                var DGinfo = DGinfoList.Where(a => a.isUse == "0").OrderBy(a => a.createTime).First();
                                //将数据插入中间表
                                traycode = DGinfo.trayCode;
                            }
                            //可生成任务
                            CMMLog.Debug($"包装机满托下线:获取托盘号:{traycode}");
                            if (!string.IsNullOrEmpty(traycode))
                            {
                                var CBInfo = Settings.GetDGConnectingbitsList().Where(a => a.enable == 1).ToList();
                                if (CBInfo != null)
                                {
                                    if (!string.IsNullOrEmpty(a.locCode))
                                    foreach (var a in CBInfo)
                                    {
                                        //在中间表中查找点位
                                        var CBTable = MongoDBSingleton.Instance.FindOne<ConnectingBits>(Query.EQ("Bit", a.locCode), "ConnectingBits");
                                        if (CBTable != null)
                                        if (!string.IsNullOrEmpty(a.locCode))
                                        {
                                            if (string.IsNullOrEmpty(CBTable.trayCode))
                                            //在中间表中查找点位
                                            var CBTable = MongoDBSingleton.Instance.FindOne<DGConnectingBits>(Query.EQ("Bit", a.locCode), "DGConnectingBits");
                                            if (CBTable != null)
                                            {
                                                if (string.IsNullOrEmpty(CBTable.trayCode))
                                                {
                                                    //生成任务,并且将点位写入中间表
                                                    var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), plc.location, a.locCode, "包装机满托下线", 0, traycode);
                                                    if (amsResult.success)
                                                    {
                                                        CMMLog.Debug($"包装机满托下线:AMS调用API成功!");
                                                        MongoDBSingleton.Instance.Update<DGConnectingBits>(Query.EQ("Bit", a.locCode), Update.Set("trayCode", traycode), UpdateFlags.None);
                                                        MongoDBSingleton.Instance.Update<DGPackingLineFullModel>(Query.EQ("trayCode", traycode), Update.Set("isUse", "1"), UpdateFlags.None);
                                                        break;
                                                    }
                                                    else CMMLog.Debug($"包装机满托下线:AMS调用API失败,开始重新调用!");
                                                }
                                            }
                                            else
                                            {
                                                //生成任务,并且将点位写入中间表
                                                var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), plc.location, a.locCode, "包装机满托下线", 0, traycode);
                                                if (amsResult.success)
                                                {
                                                    CMMLog.Debug($"包装机满托下线:AMS调用API成功!");
                                                    MongoDBSingleton.Instance.Update<ConnectingBits>(Query.EQ("Bit", a.locCode), Update.Set("trayCode", traycode).Set("timeCuo", timeStamp), UpdateFlags.None);
                                                    //打包下线任务生成成功,向中间表插入数据
                                                    MongoDBSingleton.Instance.Insert<DGConnectingBits>(new DGConnectingBits { Bit = a.locCode, trayCode = traycode, state = "0" });
                                                    MongoDBSingleton.Instance.Update<DGPackingLineFullModel>(Query.EQ("trayCode", traycode), Update.Set("isUse", "1"), UpdateFlags.None);
                                                    break;
                                                }
                                                else CMMLog.Debug($"包装机满托下线:AMS调用API失败,开始重新调用!");
                                            }
                                        }
                                        else
                                        {
                                            //生成任务,并且将点位写入中间表
                                            var amsResult = AMSHelper.CreateTask(DateTime.Now.Ticks.ToString(), plc.location, a.locCode, "包装机满托下线", 0, traycode);
                                            if (amsResult.success)
                                            {
                                                CMMLog.Debug($"包装机满托下线:AMS调用API成功!");
                                                //打包下线任务生成成功,向中间表插入数据
                                                MongoDBSingleton.Instance.Insert<ConnectingBits>(new ConnectingBits { Bit = a.locCode, trayCode = traycode, state = "0", timeCuo = timeStamp });
                                                break;
                                            }
                                            else CMMLog.Debug($"包装机满托下线:AMS调用API失败,开始重新调用!");
                                        }
                                        else CMMLog.Debug("打包下线口接驳位点位未配置");
                                    }
                                    else CMMLog.Debug("打包下线口接驳位点位未配置");
                                }
                                else CMMLog.Debug("打包下线口接驳位未配置");
                            }
                            else CMMLog.Debug("打包下线口接驳位未配置");
                        }
                    }
                }
                catch (Exception ex)
                {
                    CMMLog.Info($"四钴C设备 err:{ex.Message}");
                    CMMLog.Info($"电钴C设备 err:{ex.Message}");
                }
            }
        }
@@ -4802,14 +4859,33 @@
            public string Msg { get; set; }
            public LKData Data { get; set; }
            public int AffectedRows { get; set; }
            public bool Success { get; set; }
        }
        public class LKData
        {
            /// <summary>
            /// 批次号
            /// </summary>
            public string CN_S_LOT_NO { get; set; }
            public int CN_S_EXT8 { get; set; }
            /// <summary>
            /// 物料编码
            /// </summary>
            public string CN_S_ITEM_CODE { get; set; }
            /// <summary>
            /// 桶重量
            /// </summary>
            public float CN_F_QUANTITY { get; set; }
            /// <summary>
            /// 桶数量
            /// </summary>
            public int CN_N_CONUT { get; set; }
            /// <summary>
            /// 生产日期
            /// </summary>
            public string CN_T_PRODUCTION_S { get; set; }
            public string CN_S_EXT8 { get; set; }
        }
        #endregion