zhaowc
2025-10-18 219a08427376efdd304e9b11e481ccd8276018bb
Wms/WMS.BLL/BllTransServer/HopperTransportServer.cs
@@ -159,13 +159,14 @@
        /// <param name="palletStatus"></param>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        public List<string> GetSkuByStatus(string palletStatus)
        public List<DataStockDetail> GetSkuByStatus(string palletStatus)
        {
            try
            {
                //获取储位上的库存物料
                var detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LocatNo) && m.PalletStatus == palletStatus).Select(m=>m.SkuNo).Distinct().ToList();
                return detail;
                var detail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.LocatNo) && m.PalletStatus == palletStatus).ToList();
                List<DataStockDetail> result = detail.GroupBy(x => x.SkuNo).Select(xx => xx.First()).ToList();
                return result;
            }
            catch (Exception e)
            {
@@ -191,12 +192,14 @@
            }
        }
        public List<string> GetSku()
        public List<SysMaterials> GetSku()
        {
            try
            {
                //获取储位上的库存物料
                var detail = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0" ).Select(m => m.SkuNo).Distinct().ToList();
                //var detail = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0" ).Select(m => m.SkuNo).Distinct().ToList();
                var detail = Db.Queryable<SysMaterials>().Where(m => m.IsDel == "0").ToList();
                return detail;
            }
            catch (Exception e)
@@ -264,12 +267,20 @@
                    throw new Exception("没有查询到仓库信息");
                }
                //查找状态是未分配且储位不为空的库存信息
                var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.Status == "0" && m.WareHouseNo == house.WareHouseNo && !string.IsNullOrWhiteSpace(m.LocatNo)).ToList();
                var stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.Status == "0" && m.WareHouseNo == house.WareHouseNo && !string.IsNullOrWhiteSpace(m.LocatNo) && m.IsDel=="0").ToList();
                //净桶
                if (plnStatus == "0")
                if (plnStatus == "0")  //4L叫净桶不分楼层
                {
                    stockDetail = stockDetail.Where(m => m.PalletStatus == "0" && m.Standard == standard).OrderBy(m => m.LocatNo).ToList();
                    if (house.WareHouseNo == "M01")
                    {
                        stockDetail = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList();
                    }
                    else
                    {
                        stockDetail = stockDetail.Where(m => m.IsDel == "0" && m.Status == "0" && m.PalletStatus == "0" && m.Standard == standard && !string.IsNullOrWhiteSpace(m.LocatNo)).OrderBy(m => m.LocatNo).ToList();
                    }
                }
                //满桶
                else if (plnStatus == "2") 
@@ -292,12 +303,12 @@
                bool resultYi = false;
                #region#查找合适的 桶号 储位
                //目标仓库所有储位
                var locatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.WareHouseNo == house.WareHouseNo).ToList();
                //目标仓库所有不需要移库的储位
                var locatList = Db.Queryable<SysStorageLocat>().Where(w => w.IsDel == "0" && w.Flag=="0" && w.WareHouseNo == house.WareHouseNo).OrderBy(w=>w.Column).ToList();
                //目标仓库所有最外侧的储位
                var locatListWai = locatList.Where(w => string.IsNullOrEmpty(w.AisleOne)).Select(s => s.LocatNo);
                //先找不需要移库的桶
                var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo)).OrderByDescending(w => w.UpdateTime).FirstOrDefault();
                var palletModel = stockDetail.Where(w => locatListWai.Contains(w.LocatNo) && w.Status == "0").OrderByDescending(w => w.UpdateTime).FirstOrDefault();
                if (palletModel == null)
                {
                    //找需要移库的桶
@@ -383,16 +394,12 @@
                        }
                        else//失败
                        {
                            logTaskEntry.IsSuccess = 0;
                            logTaskEntry.Information = agvMsg;
                            Db.Updateable(logTaskEntry).ExecuteCommand();
                            throw new Exception("桶号:"+ task.Pallno + ",调度小车失败");
                        }
                    }
                    else 
                    {
                        logTaskEntry.IsSuccess = 0;
                        logTaskEntry.Information = "货架与货位绑定失败,原因:"+agvBindMsg;
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                        throw new Exception("桶号:" + task.Pallno + ",绑定货位失败");
                    }
                   
                }
@@ -428,6 +435,11 @@
                if (string.IsNullOrWhiteSpace(areaNo) || string.IsNullOrWhiteSpace(StartLocate) || string.IsNullOrWhiteSpace(plnStatus))
                {
                    throw new Exception("区域/起始位/桶类型不能为空");
                }
                if (weight < 0)
                {
                    throw new Exception("重量应不小于0");
                }
                //if (plnStatus == "0" && string.IsNullOrWhiteSpace(standard))
@@ -586,17 +598,13 @@
                    }
                    else//失败
                    {
                        logTaskEntry.IsSuccess = 0;
                        logTaskEntry.Information = agvMsg;
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                        throw new Exception("桶号:" + task.Pallno + ",调度小车失败");
                    }
                }
                else
                {
                    logTaskEntry.IsSuccess = 0;
                    logTaskEntry.Information = "货架与货位绑定失败,原因:"+agvBindMsg;
                    Db.Updateable(logTaskEntry).ExecuteCommand();
                    throw new Exception("桶号:" + task.Pallno + ",绑定货位失败");
                }
                
@@ -619,7 +627,7 @@
        /// <param name="comeFrom"></param>
        /// <param name="userId"></param>
        /// <exception cref="Exception"></exception>
        public void RCSFinishTask(string taskNo, string status, string comeFrom, int userId = 0)
        public void RCSFinishTask(string taskNo, string locateNo, string status, string comeFrom, int userId = 0)
        {
            try
            {
@@ -659,7 +667,7 @@
                    return;
                }
                //库存明细
                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo);
                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == taskInfo.PalletNo && w.IsDel=="0");
                if (stockDetail == null)
                {
                    throw new Exception($"桶库存信息不存在");
@@ -789,7 +797,7 @@
                                break;
                            case "2002":
                                deviceID = "1004";
                                break;
                                break;
                            default:
                                throw new Exception("叫净桶点位异常");
                        }
@@ -829,7 +837,7 @@
                            //判断当前清洗机设备上有几个脏桶,status:2 正在清洗的脏桶(状态触发变更为AGV叫第2个脏桶时触发)
                            int ztQty = Db.Queryable<DataStockDetail>().Count(w => w.IsDel == "0" && w.Status == "2" && w.LocatNo == deviceID);
                            if (ztQty == 1)
                            if (ztQty == 2)
                            {
                                throw new Exception((deviceID == "1001"?"1":"2") + "号清洗机脏桶已满,重复叫料!");
                            }
@@ -866,6 +874,14 @@
                            {
                                throw new Exception($"起始目标储位信息不存在,桶号:{palletModel.LocatNo}");
                            }
                            //起始桶信息
                            var startDataDetil = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.Status == "0" && w.PalletStatus == "3");
                            if (startDataDetil == null)
                            {
                                throw new Exception($"清洗机所叫的桶状态错误,桶号:{palletModel.LocatNo}");
                            }
                            startDataDetil.Status = "4";
                            Db.Updateable(startDataDetil).ExecuteCommand();
                        }
                        else
                        {
@@ -891,7 +907,7 @@
                            {
                                palletModel.LocatNo = startLoction.LocatNo;
                                palletModel.PalletStatus = "0";
                                palletModel.Status = "0";
                                palletModel.Status = "4";
                                Db.Updateable(palletModel).ExecuteCommand();
                            }
                            //分配储位
@@ -903,13 +919,13 @@
                                throw new Exception("没有空余的净桶储位");
                            }
                            //优先分配四楼中间站净桶区
                            //endLoction = jtLocate.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C01")
                            //                    .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
                            //if (endLoction == null)//四楼中间站净桶区没有空储位,再从三楼中间站净桶区查找
                            //{
                            endLoction = jtLocate.Where(w => w.WareHouseNo == "M01" && w.AreaNo == "C01")
                                                .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
                            if (endLoction == null)//四楼中间站净桶区没有空储位,再从三楼中间站净桶区查找
                            {
                            endLoction = jtLocate.Where(w => w.WareHouseNo == "M16" && w.AreaNo == "C24")
                                                .OrderBy(w => w.Row).OrderByDescending(w => w.Column).FirstOrDefault();
                            //}
                            }
                            if (endLoction == null)//三楼中间站净桶区没有空储位,再从三楼清洗间缓存区查找             PS:小车现在还不支持清洗机直接送往4楼净桶区
                            {
                                endLoction = jtLocate.Where(w => w.WareHouseNo == "M44" && w.AreaNo == "C55")
@@ -996,16 +1012,12 @@
                    }
                    else//失败
                    {
                        logTaskEntry.IsSuccess = 0;
                        logTaskEntry.Information = agvMsg;
                        Db.Updateable(logTaskEntry).ExecuteCommand();
                        throw new Exception("桶号:" + task.Pallno + ",调度小车失败");
                    }
                }
                else
                {
                    logTaskEntry.IsSuccess = 0;
                    logTaskEntry.Information = agvBindMsg;
                    Db.Updateable(logTaskEntry).ExecuteCommand();
                    throw new Exception("桶号:" + task.Pallno + ",绑定货位失败");
                }
                
                //提交事务
@@ -1046,6 +1058,8 @@
                //判断该储位是否是内侧储位
                if (!string.IsNullOrEmpty(locatInfo.AisleOne))
                {
                    ////获取当前库位的外侧储位信息
                    //var waiLocatInfo = Db.Queryable<SysStorageLocat>().First(w=>w.IsDel == "0" && w.Row == locatInfo.Row && w.Column == locatInfo.Column - 1);
                    //判断外侧储位是否有桶
                    var palletInfoYi = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.LocatNo == locatInfo.AisleOne);
                    if (palletInfoYi != null)
@@ -1429,6 +1443,7 @@
                string areaNo = string.Empty;
                switch (palletStatus)
                {
                    case "0"://净桶
                             //查到到净桶区域编号
                        areaNo = Db.Queryable<SysStorageArea>().Where(w => w.IsDel == "0" && w.WareHouseNo == houseNo && w.Type == "0").Select(s => s.AreaNo).First();