Administrator
2024-02-27 5f35c217da1424cf6a1aafd5e912e9cf29450fa4
Wms/WMS.BLL/BllPdaServer/PdaCrServer.cs
@@ -8,6 +8,7 @@
using WMS.BLL.LogServer;
using WMS.Entity.BllAsnEntity;
using WMS.Entity.BllCheckEntity;
using WMS.Entity.BllSoEntity;
using WMS.Entity.Context;
using WMS.Entity.DataEntity;
using WMS.Entity.SysEntity;
@@ -656,6 +657,10 @@
                {
                    throw new Exception("托盘储位信息不存在,请检查!");
                }
                if (models.WareHouseNo != "W02")
                {
                    throw new Exception("该托盘未在平库内,请检查!");
                }
                return models.LocatNo;
            }
            catch (Exception ex)
@@ -682,6 +687,10 @@
                {
                    throw new Exception("托盘储位信息不存在,请检查!");
                }
                if (models.WareHouseNo != "W02")
                {
                    throw new Exception("该托盘未在平库内,请检查!");
                }
                var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == models.LocatNo);
                if (storageLocat == null)
                {
@@ -703,6 +712,204 @@
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 获取已分配的出库单据
        /// </summary>
        /// <returns></returns>
        public List<string> GetRunSoNoticeList()
        {
            try
            {
                var allotList = Db.Queryable<BllExportNotice>().Where(m => m.IsDel == "0" && m.Status == "2").Select(m => m.SONo).Distinct().ToList();
                return allotList;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 根据托盘号获取托盘上物料信息
        /// </summary>
        /// <param name="palletNo"></param>
        /// <returns></returns>
        public List<DataStockDetail> GetSkuInfoByPalletNo(string palletNo)
        {
            try
            {
                if (string.IsNullOrEmpty(palletNo))
                {
                    throw new Exception("请扫描托盘条码!");
                }
                var skuInfoList = Db.Queryable<DataStockDetail>().Where(m => m.IsDel == "0" && m.PalletNo == palletNo).ToList();
                return skuInfoList;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// 根据出库单号获取分配的托盘信息
        /// </summary>
        /// <param name="soNo"></param>
        /// <returns></returns>
        public List<string> GetPalletNoListBySoNo(string soNo)
        {
            try
            {
                if (string.IsNullOrEmpty(soNo))
                {
                    throw new Exception("请选择出库单号!");
                }
                var palletNoList = Db.Queryable<BllExportAllot>().Where(m => m.IsDel == "0" && m.SONo == soNo).Select(m => m.PalletNo).Distinct().ToList();
                return palletNoList;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// agv转运呼叫小车-开发未完成待确认
        /// </summary>
        /// <param name="palletNo"></param>
        /// <param name="areaNo"></param>
        /// <param name="ruku"></param>
        public void AgvTransport(string palletNo, string areaNo, string ruku, int userId)
        {
            if (string.IsNullOrEmpty(palletNo))
            {
                throw new Exception("请扫描托盘条码!");
            }
            if (string.IsNullOrEmpty(areaNo) && string.IsNullOrEmpty(ruku))
            {
                throw new Exception("请选择目标区域或入库口!");
            }
            try
            {
                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
                if (stockDetail == null)
                {
                    throw new Exception("托盘库存信息不存在,请检查!");
                }
                if (string.IsNullOrEmpty(stockDetail.LocatNo))
                {
                    throw new Exception("托盘储位信息不存在,请检查!");
                }
                if (stockDetail.WareHouseNo != "W02")
                {
                    throw new Exception("该托盘未在平库内,请检查!");
                }
                var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
                if (storageLocat == null)
                {
                    throw new Exception("储位信息不存在,请检查!");
                }
                //开启事务
                Db.BeginTran();
                //修改库存明细信息
                stockDetail.WareHouseNo = "";
                stockDetail.RoadwayNo = "";
                stockDetail.AreaNo = "";
                stockDetail.LocatNo = "";
                Db.Updateable(stockDetail).ExecuteCommand();
                //修改储位地址状态
                storageLocat.Status = "0";//空储位
                Db.Updateable(storageLocat).ExecuteCommand();
                #region 呼叫小车代码
                #endregion
                //提交事务
                Db.CommitTran();
            }
            catch (Exception ex)
            {
                Db.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// agv转运呼叫小车取货-开发未完成待确认
        /// </summary>
        /// <param name="soNo"></param>
        /// <param name="palletNo"></param>
        /// <param name="areaNo"></param>
        /// <param name="userId"></param>
        public void AgvTransport2(string soNo,string palletNo, string areaNo, int userId)
        {
            if (string.IsNullOrEmpty(soNo))
            {
                throw new Exception("请选择出库单据!");
            }
            if (string.IsNullOrEmpty(palletNo))
            {
                throw new Exception("请扫描托盘条码!");
            }
            if (string.IsNullOrEmpty(areaNo))
            {
                throw new Exception("请选择目标区域!");
            }
            try
            {
                var notice = Db.Queryable<BllExportNotice>().First(w => w.IsDel == "0" && w.SONo == soNo);
                if (notice == null)
                {
                    throw new Exception("出库单据信息不存在,请检查!");
                }
                var allot = Db.Queryable<BllExportAllot>().First(w => w.IsDel == "0" && w.SONo == soNo && w.PalletNo == palletNo);
                if (allot == null)
                {
                    throw new Exception("该托盘出库分配信息不存在,请检查!");
                }
                var stockDetail = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
                if (stockDetail == null)
                {
                    throw new Exception("托盘库存信息不存在,请检查!");
                }
                if (string.IsNullOrEmpty(stockDetail.LocatNo))
                {
                    throw new Exception("托盘储位信息不存在,请检查!");
                }
                if (stockDetail.WareHouseNo != "W02")
                {
                    throw new Exception("该托盘未在平库内,请检查!");
                }
                var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == stockDetail.LocatNo);
                if (storageLocat == null)
                {
                    throw new Exception("储位信息不存在,请检查!");
                }
                //开启事务
                Db.BeginTran();
                //修改库存明细信息
                stockDetail.WareHouseNo = "";
                stockDetail.RoadwayNo = "";
                stockDetail.AreaNo = "";
                stockDetail.LocatNo = "";
                Db.Updateable(stockDetail).ExecuteCommand();
                //修改储位地址状态
                storageLocat.Status = "0";//空储位
                Db.Updateable(storageLocat).ExecuteCommand();
                #region 呼叫小车代码
                #endregion
                //提交事务
                Db.CommitTran();
            }
            catch (Exception ex)
            {
                Db.RollbackTran();
                throw new Exception(ex.Message);
            }
        }
        #endregion
    }