111
cjs
2025-06-17 84c580cccb118f5ec4a039d0009255935c3c2490
ams/Hanhe.iWCS.TaizhouGEMTwoProtocol/PLCControl.cs
@@ -1470,8 +1470,10 @@
        /// </summary>
        /// <param name="ip"></param>
        /// <param name="taskNo"></param>
        internal static void CacheStackingMouth6(Settings.PlcInfo plc)
        internal static void CacheStackingMouth6(Settings.PlcInfo plc, string taskNo)
        {
            var taskInfo = MongoDBSingleton.Instance.FindOne<TN_I_TASK_MST>(Query.EQ("CN_S_TASK_NO", taskNo), "TN_I_TASK_MST");
            MongoDBSingleton.Instance.Remove<WMSInfo>(Query.EQ("trayCode", taskInfo.CN_S_BATCH_NO), RemoveFlags.Single);
            var wirte = OITcpHelper.RegisterWriteOutPut(new OITcpHelper.RegisterWriteOutPutModel
            {
                addr = plc.writeAddr + 1,
@@ -1749,6 +1751,7 @@
                    host = plc.ip,
                    port = plc.port
                });
                CMMLog.Info($"叠盘下线读取通道{plc.ip},port:{plc.port},地址:{plc.readAddr + 1}的值为{JsonConvert.SerializeObject(result)}");
                if (result != null && result.errCode == 0)
                {
                    //1.满托下线
@@ -1760,7 +1763,14 @@
                            string wmstaskno = "";
                            string traycode = "";
                            string trayType = "";
                            if(plc.deviceType == "25") trayType = result.result[1] == 1 ? "川字托" : "田字托";
                            if (plc.deviceType == "25")
                            {
                                trayType = result.result[1] == 1 ? "川字托" : result.result[1] == 2 ? "田字托" : "";
                                if (string.IsNullOrEmpty(trayType))
                                {
                                    return;
                                }
                            }
                            bool req = WMSHelper.WMSIn(plc.location, "", ref wmstaskno, ref traycode,"","",false, trayType);
                            if (req)
                            {
@@ -2056,9 +2066,9 @@
                                if (timecuo != null)
                                {
                                    string timeStamp = timecuo.TimeCuo;
                                    string employeeId = timecuo.employeeId1;
                                    // ERP变更-调用ERP接口传输相关数据
                                    WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeStamp, timeStamp, employeeId,true);
                                    //string employeeId = timecuo.employeeId1;
                                    //// ERP变更-调用ERP接口传输相关数据
                                    //WMSHelper.WMSIn(plc.location, "time", ref wmstaskno, ref timeStamp, timeStamp, employeeId,true);
                                }
                                else CMMLog.Info($"时间戳接口返回值为空!");
                            }
@@ -3975,7 +3985,7 @@
                if (result != null && result.errCode == 0)
                {
                    //3:人工叫空托盘(川字)  4:人工叫空托盘(田字)
                    if (result.result[0] == 3 || result.result[0] == 4)
                    if ((pmInfo.deviceType == "1" && result.result[0] == 3)|| (pmInfo.deviceType == "21" &&(result.result[0] == 3 || result.result[0] == 4)))
                    {
                        //包装线补空流程
                        //判断空托缓存点(5 对 2)是否有空托,有空托判断是否有任务,有任务则判断另一个点位
@@ -3988,9 +3998,9 @@
                            {
                                CMMLog.Info($"周转托盘位:{a}");
                                var ddInfo = Settings.GetDDSiteList().Where(b => b.ddLoc == a && b.Enable == 1).FirstOrDefault();
                                if(ddInfo != null)
                                if (ddInfo != null)
                                {
                                    if(ddInfo.trayType == result.result[0] - 2)
                                    if (ddInfo.trayType == result.result[0] - 2)
                                    {
                                        if (ProcessHelper.PickUpEndFree(pmInfo.location) && ProcessHelper.PickUpStartFree(a))
                                        {
@@ -4015,21 +4025,6 @@
                            CMMLog.Info("配置文件未配置包装机空托缓存点");
                        }
                    }
                    //流程未对接好,是否这样使用 待定
                    //if (result.result[0] == 4)
                    //{
                    //    //调用wms出库接口
                    //    var tasks = MongoDBSingleton.Instance.Find<TN_I_TASK_MST>(Query.EQ("CN_S_END_BIT", pmInfo.location), "TN_I_TASK_MST");
                    //    //判断一下当前叠托点是否有任务占用
                    //    if (ProcessHelper.CheckEndFree(pmInfo.location) && tasks.Count == 0)
                    //    {
                    //        //可以生成任务,调WMS接口获取任务信息
                    //        bool req = WMSHelper.WMSOut(pmInfo.location, "");
                    //        if (req) CMMLog.Debug($"调用WMS获取辅材出库生成任务成功!");//现在任务由WMS自己下发,AMS做拦截处理(查询ext1里面对应的任务类型,并更改任务类型)
                    //        else CMMLog.Debug($"调用WMS获取辅材出库生成任务失败!");
                    //    }
                    //    else CMMLog.Debug($"检查当前叠托点是否有任务占用,或者MST主表中有缓存架入叠盘机的任务!");
                    //}
                }
                else
                {
@@ -4202,6 +4197,59 @@
            }
            Thread.Sleep(100000);
        }
        internal static void CheckPackingLineFullThree(Settings.PlcInfo plc)
        {
            var result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel
            {
                dataNum = 25,
                addr = plc.readAddr,
                host = plc.ip,
                port = plc.port
            });
            if(result != null && result.errCode == 0)
            {
                if (result.result[0] == 1)
                {
                    //获取物料信息 根据托盘码区分
                    string trayCode = RemoveNull(GetTrayCode(result.result.Skip(6).Take(3).ToArray()));//托盘码
                    var infoPack = MongoDBSingleton.Instance.FindOne<TimeCuoInfoComTwo>(Query.And(Query.EQ("trayCode", trayCode)), "TimeCuoInfoComTwo");
                    if (infoPack != null)
                    {
                        string empCode = RemoveNull(GetTrayCode(result.result.Skip(1).Take(5).ToArray()));//员工编码
                        string machineCode = RemoveNull(GetTrayCode(result.result.Skip(9).Take(1).ToArray()));//包装机号
                        int needWeight = Convert.ToInt32(Completion(result.result[10]) + Completion(result.result[11]), 2);//产品需求重量
                        int oneWeight = Convert.ToInt32(Completion(result.result[12]) + Completion(result.result[13]), 2);//单托毛重
                        int readWeight = Convert.ToInt32(Completion(result.result[14]) + Completion(result.result[15]), 2);//单托净重
                        int fcWeight = Convert.ToInt32(Completion(result.result[16]) + Completion(result.result[17]), 2);//单托复称重量
                        int trayType = Convert.ToInt32(Completion(result.result[18]), 2);//托盘类型
                        int addState = Convert.ToInt32(Completion(result.result[19]), 2);//叠包层数
                        int bagNumber = Convert.ToInt32(Completion(result.result[20]), 2);//袋号
                        int productTime = Convert.ToInt32(Completion(result.result[21]) + Completion(result.result[22]), 2);//生产日期
                        string timeCuoTwo = Convert.ToInt32(Completion(result.result[23]) + Completion(result.result[24]), 2).ToString(); //时间戳
                        UpdateBuilder updateBuilder = Update.Set("employeeId", empCode).Set("trayCode", trayCode).Set("packingMachineNumber", machineCode).Set("needWeight", needWeight)
                                                .Set("oneWeight", oneWeight).Set("realWeight", readWeight).Set("FCWeight", fcWeight).Set("trayType", trayType)
                                                .Set("isFold", addState).Set("bagNumber", bagNumber).Set("productData", productTime);
                        //产品批次号  产品型号 物料名称 计量单位均可在erp表中根据物料编码获取
                        result = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel
                        {
                            dataNum = 15,
                            addr = plc.readAddr + 131,
                            host = plc.ip,
                            port = plc.port
                        });
                        string materialCode = RemoveNull(GetTrayCode(result.result.Skip(0).Take(15).ToArray()).Trim().ToString());
                        UpdateBuilder update = Update.Set("materialCode", materialCode);
                        MongoDBSingleton.Instance.Update<TimeCuoInfoComTwo>(Query.EQ("trayCode", trayCode), update, UpdateFlags.None);
                    }
                }
            }
        }
        #endregion
    }
}