wxw
2 天以前 cb4ee362c99bc7902663c3134e6b0f103434946a
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -29,6 +29,7 @@
using Model.ModelVm.SysVm;
using System.Security.Cryptography.X509Certificates;
using AutoMapper.Configuration.Annotations;
using Utility;
namespace WMS.BLL.BllPdaServer
{
@@ -6512,6 +6513,113 @@
        }
        #endregion
        #region 仓库收货
        /// <summary>
        /// 仓库确认收货
        /// </summary>
        /// <param name="model"></param>
        public void ConfirmTakeOf(string palletNo,int userId)
        {
            try
            {
                #region 验证信息
                if (string.IsNullOrEmpty(palletNo))
                {
                    throw new Exception("托盘条码不能为空!");
                }
                //获取托盘信息
                var pallet = Db.Queryable<SysPallets>().First(w => w.IsDel == "0" && w.PalletNo == palletNo);
                //验证托盘信息是否为空
                if (pallet == null)
                {
                    throw new Exception("托盘信息不存在,请检查!");
                }
                if (pallet.Status == "0")
                {
                    throw new Exception("托盘未使用,请检查!");
                }
                #endregion
                //获取库存明细信息
                var stockDetailList = Db.Queryable<DataStockDetail>().Where(s => s.IsDel == "0" && s.PalletNo == palletNo).ToList();
                //验证库存明细信息是否存在
                if (stockDetailList.Count<=0)
                {
                    throw new Exception("库存明细不存在,请检查库存信息!");
                }
                //开启事务
                Db.BeginTran();
                foreach (var item in stockDetailList)
                {
                    if (item.AreaNo != "B06" && item.AreaNo != "B07" && item.AreaNo != "B09")
                    {
                        throw new Exception("该托盘非线边回库托盘!");
                    }
                    //库存总表
                    var stock = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == item.SkuNo && w.LotNo == item.LotNo);
                    if (stock == null)
                    {
                        throw new Exception($"未查询到该托盘上物料编码为:{item.SkuNo}的库存信息!");
                    }
                    var boxInfoList = Db.Queryable<DataBoxInfo>().Where(w => w.IsDel == "0" && w.PalletNo == palletNo && w.SkuNo == item.SkuNo && w.LotNo == item.LotNo).ToList();
                    if (boxInfoList.Count > 0)
                    {
                        foreach (var box in boxInfoList)
                        {
                            var bllBox = Db.Queryable<BllBoxInfo>().First(w => w.IsDel == "0" && w.Status != "0");
                            if (bllBox != null)
                            {
                                bllBox.Status = "0";
                                bllBox.ASNDetailNo = null;
                                bllBox.BindNo = null;
                                bllBox.PalletNo = "";
                                //更新箱支明细表
                                Db.Updateable(bllBox).ExecuteCommand();
                            }
                        }
                        //删除库存箱码信息
                        Db.Deleteable(boxInfoList).ExecuteCommand();
                    }
                    //删除或修改库存
                    stock.Qty -= (decimal)item.Qty;
                    if (stock.Qty <= 0)
                    {
                        Db.Deleteable(stock).ExecuteCommand();
                    }
                    else
                    {
                        Db.Updateable(stock).ExecuteCommand();
                    }
                    //删除库存明细
                    Db.Deleteable(item).ExecuteCommand();
                    //判断托盘上还有没有其他物料
                    var palletData = Db.Queryable<DataStockDetail>().First(w => w.IsDel == "0" && w.PalletNo == palletNo && w.Id != item.Id);
                    if (palletData == null)
                    {
                        pallet.Status = "0";
                        Db.Updateable(pallet).ExecuteCommand();
                    }
                }
                new OperationASNServer().AddLogOperationAsn("PDA模块", "仓库收货", palletNo, "完成", $"在PDA上完成托盘码为:{palletNo}的仓库收货操作", userId);
                //提交事务
                Db.CommitTran();
            }
            catch (Exception ex)
            {
                //回滚事务
                Db.RollbackTran();
                throw ex;
            }
        }
        #endregion
        #region JC23取样业务接口
        //获取未组托或已组托的箱码级别