11
cjs
2 天以前 06747ef981873358950982e7a53c6d221ef93ac3
HH.WCS.Mobox3.NongFuLinZhi/process/TaskProcess.cs
@@ -1477,7 +1477,7 @@
                                        LogHelper.Info($"出库算法04:当前货位绑定的托盘码为:{cntrInfo.S_CNTR_CODE}");
                                        string endItemCode = "";
                                        var itemInfo = db.Queryable<CntrItemRel>().Where(b => b.S_CNTR_CODE == cntrInfo.S_CNTR_CODE).First();
                                        if (itemInfo != null && itemInfo.S_ITEM_CODE == itemCode)
                                        if (itemInfo != null)
                                        {
                                            endItemCode = itemInfo.S_ITEM_CODE;
                                        }
@@ -1571,11 +1571,11 @@
        /// <param name="taskName"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        internal static Location BCPFullOut(SqlSugarClient db, string taskName, string itemCode)
        internal static Location BCPFullOut(SqlSugarClient db, string taskName, string itemCode,string batch)
        {
            Location result = null;
            LogHelper.Info($"瓶坯注塑满托下线:类型:{taskName},物料编码:{itemCode}");
            LogHelper.Info($"瓶坯注塑满托下线:类型:{taskName},物料编码:{itemCode},批次号:{batch}");
            if (taskName.Contains("即产"))
            {
                //注塑机即产即用下线,首先下线到即产即用满框线边,满眶线边满了,下到即产即用满框缓存区,满框缓存区满了,下到入库接驳堆叠位
@@ -1946,24 +1946,7 @@
                    {
                        var cir = new LocCntrRel { S_LOC_CODE = loc, S_CNTR_CODE = cntrCode, S_SRC = deviceName };
                        if (db.Insertable<LocCntrRel>(cir).ExecuteCommand() > 0) LogHelper.Info($"货位容器表绑定成功,货位号:{loc},托盘号:{cntrCode}");
                        var Con = db.Queryable<Container>().Where(a => a.S_CODE == cntrCode).First();
                        if(Con == null)
                        {
                            int detallCount = 0;
                            if (!string.IsNullOrEmpty(itemCode))
                            {
                                detallCount = 1;
                            }
                            if(db.Insertable<Container>(new Container
                            {
                                S_CODE = cntrCode,
                                N_TYPE = 1,
                                N_DETAIL_COUNT = detallCount
                            }).ExecuteCommand() > 0)
                            {
                                LogHelper.Info($"容器表绑定成功,托盘号:{cntrCode}");
                            }
                        }
                        if (!string.IsNullOrEmpty(itemCode))
                        {
                            BindCntrItem(cntrCode, itemCode, batchNo, itemlayer, itemName);
@@ -1990,6 +1973,26 @@
            try
            {
                db.BeginTran();
                var Con = db.Queryable<Container>().Where(a => a.S_CODE == trayCode).First();
                if (Con == null)
                {
                    int detallCount = 1;
                    if (db.Insertable<Container>(new Container
                    {
                        S_CODE = trayCode,
                        N_TYPE = 1,
                        N_DETAIL_COUNT = detallCount
                    }).ExecuteCommand() > 0)
                    {
                        LogHelper.Info($"容器表绑定成功,托盘号:{trayCode}");
                    }
                }
                else
                {
                    Con.N_DETAIL_COUNT = 1;
                    db.Updateable(Con).UpdateColumns(a => new { a.N_DETAIL_COUNT }).ExecuteCommand();
                }
                //db.Updateable(cntr).UpdateColumns(it => new { it.S_DEST }).ExecuteCommand();
                //1.将原有容器物料信息删除
                //db.Deleteable<CntrItemRel>().Where(it => it.S_CNTR_CODE == cntr.S_CNTR_CODE.Trim()).ExecuteCommand();
@@ -2548,27 +2551,77 @@
            var op = WMSHelper.GetWmsTask(TN_Task.S_OP_CODE);
            if (op != null)
            {
                if (op.N_B_STATE == 0)
                {
                    //等待直接修改状态为取消
                    op.N_B_STATE = 3;
                }
                else if (op.N_B_STATE == 1)
                {
                    if (WCSHelper.CheckActionRecordExist(TN_Task.S_CODE, 4))
                    {
                        op.N_B_STATE = 2;
                    }
                    else
                    {
                        op.N_B_STATE = 3;
                    }
                }
                op.N_B_STATE = 2;
                WMSHelper.UpdateTaskState(op);
            }
            NDCApi.CancelOrder(TN_Task.S_CODE.Trim());
            OperateStatus(TN_Task, 7);
        }
        internal static Location BCPInOrOutTwo(SqlSugarClient db, string areaName, string itemCode)
        {
            Location result = null;
            var areaInfo = Settings.areaInfos.Where(a => a.areaName.Contains(areaName) && a.enable == 1).OrderByDescending(a => a.pri).ToList();
            if (areaInfo.Count > 0)
            {
                foreach (var it in areaInfo)
                {
                    LogHelper.Info($"瓶坯非即产满框转运:area:{it.areaName},itemCode:{itemCode}");
                    var locList = db.Queryable<Location>().Where(a => a.S_AREA_CODE == it.areaCode && a.N_CURRENT_NUM > 0).OrderBy(a => a.N_ROW).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).Includes(a => a.LocCntrRel).ToList();
                    if (locList.Count > 0)
                    {
                        LogHelper.Info($"瓶坯非即产满框转运:查询到可出货位数量:{locList.Count}");
                        foreach (var a in locList)
                        {
                            LogHelper.Info($"瓶坯非即产满框转运:查询货位:{a.S_CODE},锁状态:{a.S_LOCK_STATE}");
                            if (a.S_LOCK_STATE == "无")
                            {
                                var cntrInfo = db.Queryable<LocCntrRel>().Where(b => b.S_LOC_CODE == a.S_CODE).First();
                                if (cntrInfo != null)
                                {
                                    LogHelper.Info($"瓶坯非即产满框转运:当前货位绑定的托盘码为:{cntrInfo.S_CNTR_CODE}");
                                    string endItemCode = "";
                                    var itemInfo = db.Queryable<CntrItemRel>().Where(b => b.S_CNTR_CODE == cntrInfo.S_CNTR_CODE).First();
                                    if (itemInfo != null)
                                    {
                                        endItemCode = itemInfo.S_ITEM_CODE;
                                    }
                                    if (endItemCode == itemCode)
                                    {
                                        LogHelper.Info($"瓶坯非即产满框转运:当前货位绑定的物料编码为:{endItemCode},物料类型为:{itemInfo.S_BATCH_NO},绑定时间为:{itemInfo.T_CREATE}");
                                        if ((itemInfo.S_BATCH_NO == "非即产" && itemInfo.T_CREATE.AddHours(Settings.lQHours) <= DateTime.Now) || itemInfo.S_BATCH_NO == "即产")
                                        {
                                            //非即产瓶坯需要判断冷却时间是否大于一定时间
                                            //判断当前排有无锁
                                            var lockInfo = db.Queryable<Location>().Where(b => b.S_AREA_CODE == it.areaCode && b.N_ROW == a.N_ROW && (b.S_LOCK_STATE == "入库锁" || b.S_LOCK_STATE == "出库锁")).First();
                                            if (lockInfo == null)
                                            {
                                                result = a;
                                                break;
                                            }
                                            else
                                            {
                                                LogHelper.Info($"瓶坯非即产满框转运:当前排有锁,货位号:{lockInfo.S_CODE}");
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (result != null)
                    {
                        break;
                    }
                }
            }
            else
            {
                LogHelper.Info($"瓶坯非即产满框转运:{areaName}未配置");
            }
            return result;
        }
    }
}