Administrator
2024-03-06 65ecd34acf0a3d33e6c1e10c93e351716d749e2f
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;
@@ -292,6 +293,17 @@
                        checkDetail.RealQty = qty;
                    }
                    checkDetail.CheckResult = 1;
                    var checkInfo = Db.Queryable<BllStockCheckLog>().First(m =>
                    m.IsDel == "0" && m.CRNo == crNo && m.PalletNo == palletNo && m.SkuNo == sku && m.LotNo == lotNo);
                    checkInfo.RealQty = qty;
                    checkInfo.CheckResult = 1;
                    checkInfo.CheckUserId = userId;
                    checkInfo.CheckDate = time;
                    checkInfo.UpdateUser = userId;
                    checkInfo.UpdateTime = time;
                    Db.Updateable(checkInfo).ExecuteCommand();
                    Db.Updateable(checkDetail).ExecuteCommand();
                    Db.Updateable(list).ExecuteCommand();
                }
@@ -738,6 +750,10 @@
                {
                    throw new Exception("托盘储位信息不存在,请检查!");
                }
                if (models.WareHouseNo != "W02")
                {
                    throw new Exception("该托盘未在平库内,请检查!");
                }
                return models.LocatNo;
            }
            catch (Exception ex)
@@ -764,6 +780,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)
                {
@@ -785,6 +805,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
    }