yuyou_x
2024-03-16 cd8800f471c9d7ee62dd915c4407f809638471af
Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -890,6 +890,11 @@
            {
                string EndLocat = string.Empty;//目标位置                
                var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
                if (log != null)
                {
                    throw new Exception("该托盘已有小车等待执行或正在执行的任务!");
                }
                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
                if (stockDetail == null)
                {
@@ -902,7 +907,7 @@
                    {
                        throw new Exception("所选区域信息不存在,请检查!");
                    }
                    EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo);
                    EndLocat = GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo);
                }
                else
                {
@@ -921,11 +926,23 @@
                {
                    throw new Exception("该托盘未在平库内,请检查!");
                }
                //起始储位信息
                var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
                if (storageLocat == null)
                {
                    throw new Exception("储位信息不存在,请检查!");
                }
                //目标储位信息
                var storageLocatEnd = new SysStorageLocat();
                if (!string.IsNullOrEmpty(areaNo))
                {
                    storageLocatEnd = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0");
                    if (storageLocatEnd == null)
                    {
                        throw new Exception("目标储位信息不存在,请检查!");
                    }
                }
                //开启事务
                Db.BeginTran();
@@ -960,10 +977,16 @@
                stock.LockQty += (decimal)stockDetail.Qty;
                Db.Updateable(stock).ExecuteCommand();
                //修改储位地址状态
                //修改起始储位地址状态
                storageLocat.Status = "5";//0:空储位 1:有物品 2:入库中 3:出库中 4:移入中 5:移出中 
                Db.Updateable(storageLocat).ExecuteCommand();
                //修改目标储位地址状态
                if (storageLocatEnd != null)
                {
                    storageLocatEnd.Status = "4";//0:空储位 1:有物品 2:入库中 3:出库中 4:移入中 5:移出中
                    Db.Updateable(storageLocatEnd).ExecuteCommand();
                }
                //添加操作日志记录
                var k = new OperationCrServer().AddLogOperationCr("PDA模块", "AGV转运", palletNo, "移库", $"PDA呼叫小车对托盘号:{palletNo}发起转运", userId);
                //提交事务
@@ -1002,6 +1025,12 @@
            }
            try
            {
                var log = Db.Queryable<LogTask>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && (w.Status == "0" || w.Status == "1"));
                if (log != null)
                {
                    throw new Exception("该托盘已有小车等待执行或正在执行的任务!");
                }
                var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo);
                if (notice == null)
                {
@@ -1041,7 +1070,13 @@
                    throw new Exception("所选区域信息不存在,请检查!");
                }
                string EndLocat = string.Empty;//目标位置
                EndLocat= GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo);
                EndLocat= GetLocat(areaNo, stockDetail.SkuNo, stockDetail.LotNo,palletNo);
                //目标储位信息
                var storageLocatEnd = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == EndLocat && w.Flag == "0" && w.Status == "0");
                if (storageLocatEnd == null)
                {
                    throw new Exception("目标储位信息不存在,请检查!");
                }
                //开启事务
                Db.BeginTran();
@@ -1080,6 +1115,10 @@
                storageLocat.Status = "5";//0:空储位 1:有物品 2:入库中 3:出库中 4:移入中 5:移出中 
                Db.Updateable(storageLocat).ExecuteCommand();
                //修改目标储位地址状态
                storageLocatEnd.Status = "4";//0:空储位 1:有物品 2:入库中 3:出库中 4:移入中 5:移出中
                Db.Updateable(storageLocatEnd).ExecuteCommand();
                //添加操作日志记录
                var k = new OperationCrServer().AddLogOperationCr("PDA模块", "AGV转运", palletNo, "移库", $"PDA呼叫小车对托盘号:{palletNo}发起转运", userId);
                //提交事务
@@ -1095,7 +1134,14 @@
                throw new Exception(ex.Message);
            }
        }
        private string GetLocat(string areaNo,string skuNo,string lotNo)
        /// <summary>
        /// 根据区域分配储位
        /// </summary>
        /// <param name="areaNo"></param>
        /// <param name="skuNo"></param>
        /// <param name="lotNo"></param>
        /// <returns></returns>
        private string GetLocat(string areaNo,string skuNo,string lotNo,string palletNo)
        {
            try
            {
@@ -1103,7 +1149,7 @@
                //当然区域所有储位信息
                var storageLocatList = Db.Queryable<SysStorageLocat>().Where(w => w.WareHouseNo == "W02" && w.AreaNo == areaNo).ToList();
                //同区域同批次物料的储位信息
                List<string> locatList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo)
                List<string> locatList = Db.Queryable<DataStockDetail>().Where(w => w.IsDel == "0" && w.SkuNo == skuNo && w.LotNo == lotNo && w.WareHouseNo == "W02" && w.AreaNo == areaNo && w.PalletNo != palletNo)
                    .OrderByDescending(o=>o.LocatNo).Select(s=>s.LocatNo).Distinct().ToList();
                foreach (var item in locatList)
                {
@@ -1119,7 +1165,7 @@
                if (string.IsNullOrEmpty(endLocat))
                {
                    var locatInfo3 = storageLocatList.Where(w => w.IsDel == "0" && w.Flag == "0" && w.Status == "0")
                                .OrderByDescending(m => new { m.Layer, m.Column, m.Row }).First();
                                .OrderByDescending(m => m.Layer).OrderByDescending(m=>m.Column).OrderByDescending(m=> m.Row).First();
                    if (locatInfo3 != null)
                    {