wxw
2 天以前 2cafdd83b5173ca7e78dffcde63897b4be251179
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
{
@@ -77,14 +78,15 @@
                else
                {
                    //从物料名称-批次中取出批次
                    int indexOfDash = model.LotNo.IndexOf("-");
                    int indexOfDash = model.LotNo.IndexOf("=>");
                    if (indexOfDash != -1)
                    {
                        model.LotNo = model.LotNo.Substring(indexOfDash + 1);
                        model.LotNo = model.LotNo.Substring(indexOfDash + 2);
                    }
                    else
                    {
                        throw new Exception("物料-批次不可为空!");
                        model.LotNo = "";
                        //throw new Exception("物料-批次不可为空!");
                    }
                }
@@ -531,7 +533,7 @@
                    #endregion
                    #region 质检请验
                    if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
                    if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1" && sku.IsControlled != "1")
                    {
                        var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
                        if (qualityRequest == null)
@@ -1047,7 +1049,7 @@
                        #endregion
                        #region 质检请验
                        if ((arrNotice.Type == "1" || arrNotice.Type == "4" || arrNotice.Type == "5") && sku.IsInspect != "1")
                        if ((arrNotice.Type == "1" || arrNotice.Type == "4" || arrNotice.Type == "5") && sku.IsInspect != "1" && sku.IsControlled != "1")
                        {
                            var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
                            if (qualityRequest == null)
@@ -1136,14 +1138,15 @@
                else
                {
                    //从物料名称-批次中取出批次
                    int indexOfDash = model.LotNo.IndexOf("-");
                    int indexOfDash = model.LotNo.IndexOf("=>");
                    if (indexOfDash != -1)
                    {
                        model.LotNo = model.LotNo.Substring(indexOfDash + 1);
                        model.LotNo = model.LotNo.Substring(indexOfDash + 2);
                    }
                    else
                    {
                        throw new Exception("物料批次不可为空!");
                        model.LotNo = "";
                        //throw new Exception("物料批次不可为空!");
                    }
                }
@@ -1497,7 +1500,7 @@
                #endregion
                #region 质检请验
                if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
                if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1" && sku.IsControlled != "1")
                {
                    var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
                    if (qualityRequest == null)
@@ -2226,15 +2229,17 @@
                };
                //获取状态是未组托的标签信息
                var models = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo && m.ASNDetailNo == asnDetailId ).GroupBy(m=> new { m.ProductionTime,m.ExpirationTime }).Select(m=>new { m.ProductionTime ,m.ExpirationTime}).OrderBy(m=>m.ProductionTime).ToList();//&& m.Status == "0"
                var models = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo && m.ASNDetailNo == asnDetailId && m.Status == "0")
                    .GroupBy(m=> new { m.ProductionTime,m.ExpirationTime })
                    .Select(m=>new { m.ProductionTime ,m.ExpirationTime}).OrderBy(m=>m.ProductionTime).ToList();//&& m.Status == "0"
                foreach (var item in models)
                {
                    var boxNoList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.ASNNo == asnNo && m.ASNDetailNo == asnDetailId && m.ProductionTime == item.ProductionTime).Select(m => m.BoxNo).ToList();
                    var boxNoList = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.Status == "0" && m.ASNNo == asnNo && m.ASNDetailNo == asnDetailId && m.ProductionTime == item.ProductionTime).Select(m => m.BoxNo).ToList();
                    if (boxNoList.Count > 0)
                    {
                        data.BoxNoList = boxNoList;
                        data.Date1 = item.ProductionTime.ToString();
                        data.Date2 = item.ExpirationTime.ToString();
                        data.Date1 = item.ProductionTime == null ? "" : Convert.ToDateTime(item.ProductionTime).ToString("yyyy-MM-dd");
                        data.Date2 = item.ExpirationTime == null ? "" : Convert.ToDateTime(item.ExpirationTime).ToString("yyyy-MM-dd");
                        break;
                    }
@@ -2411,6 +2416,492 @@
            {
                throw new Exception(e.Message);
            }
        }
        /// <summary>
        /// 根据箱码获取标签箱码信息(车间入库-获取WMS生成的箱信息)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public List<BoxInfoDto> GetWmsBoxInfos(string boxNo)
        {
            try
            {
                if (string.IsNullOrEmpty(boxNo))
                {
                    throw new Exception("请扫描外箱条码!");
                }
                string sqlString = $@"SELECT BoxNo, SkuNo, SkuName, LotNo, BitBoxMark, SUM(Qty) as Qty  FROM BllBoxInfo
                                        WHERE IsDel = '0' and Status='0' and BoxNo = '{boxNo}'
                                        GROUP BY BoxNo,SkuNo,SkuName,LotNo,BitBoxMark; ";
                var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString);
                if (models.Count != 0)
                {
                    return models;
                }
                else
                {
                    throw new Exception("没有查询到箱码信息");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        // 车间绑定托盘-贴标
        public void ChejianIn(string palletNo,string boxNo,decimal qty,string areaNo,int userId)
        {
            try
            {
                #region MyRegion
                if (string.IsNullOrWhiteSpace(palletNo))
                {
                    throw new Exception("托盘号不能为空");
                }
                if (string.IsNullOrWhiteSpace(boxNo))
                {
                    throw new Exception("箱号不能为空");
                }
                if (qty<=0)
                {
                    throw new Exception("数量不能小等0");
                }
                var boxInfo = Db.Queryable<BllBoxInfo>().Where(m => m.IsDel == "0" && m.BoxNo == boxNo).ToList();
                if (boxInfo.Count == 0)
                {
                    throw new Exception("未查询到当前箱号信息");
                }
                var boxInfoOne = boxInfo.First();
                var pall = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
                if (pall == null)
                {
                    throw new Exception("未查询到当前托盘信息");
                }
                #endregion
                //开启事务
                Db.BeginTran();
                //当前时间
                var comTime = DateTime.Now;
                #region 包装
                var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == boxInfoOne.SkuNo);
                var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == sku.PackagNo);
                var pNum = 0;//托盘物品数量
                var bNum = 0;//箱码物品数量
                //公共方法获取包装数量
                new Common().GetPackQtyInfo(pack.PackagNo, ref pNum, ref bNum);
                #endregion
                var msgStr = $"箱号为{boxNo}";
                var boxInfoList = new List<BllBoxInfo>();
                boxInfoList.AddRange(boxInfo);
                #region 库存明细
                var area = Db.Queryable<SysStorageArea>().First(m => m.IsDel == "0" && m.AreaNo == areaNo);
                if (area == null)
                {
                    throw new Exception("入库区域不能为空");
                }
                var tags = "0";
                // 判断库存明细是否已有此托盘信息
                var sd1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.SkuNo== boxInfoOne.SkuNo && m.LotNo == boxInfoOne.LotNo && m.PalletNo == palletNo);
                var sdId1 = 0;
                if (sd1 != null)
                {
                    if (sd1.AreaNo!= areaNo)
                    {
                        throw new Exception("选择的区域与库存不同");
                    }
                    sdId1 = sd1.Id;
                    // 库存已存在 更新数据
                    sd1.Qty += qty;
                    sd1.CompleteTime = comTime;
                    sd1.UpdateUser = userId;
                    sd1.UpdateTime = comTime;
                    Db.Updateable(sd1).ExecuteCommand();
                }
                else
                {
                    var sd2 = Db.Queryable<DataStockDetail>().Where(m => m.PalletNo == palletNo && m.IsDel == "0" && !string.IsNullOrWhiteSpace(m.AreaNo));
                    if (sd2.Count(m=>m.AreaNo!= areaNo) > 0)
                    {
                        throw new Exception("当前托盘位置与选择的不同,请核实");
                    }
                    // 库存不存在 插入数据
                    sd1 = new DataStockDetail()
                    {
                        ASNNo = "",
                        LotNo = boxInfoOne.LotNo,
                        LotText = boxInfoOne.LotText,
                        SupplierLot = boxInfoOne.SupplierLot,
                        SkuNo = sku.SkuNo,
                        SkuName = sku.SkuName,
                        Standard = sku.Standard,
                        Qty = qty,
                        LockQty = 0,
                        FrozenQty = 0,
                        InspectQty = 0,
                        WareHouseNo = area.WareHouseNo,//所属仓库
                        RoadwayNo = "",//所属巷道
                        AreaNo = area.AreaNo,//所属区域
                        LocatNo = "",//储位地址
                        PalletNo = palletNo,
                        PalletTags = tags,
                        CompleteTime = comTime,
                        ProductionTime = boxInfoOne.ProductionTime,
                        ExpirationTime = boxInfoOne.ExpirationTime,
                        Status = "0",
                        InspectMark = boxInfoOne.InspectMark,
                        InspectStatus = sku.IsInspect,
                        BitPalletMark = "1",
                        PackagNo = sku.PackagNo,
                        IsDel = "0",
                        CreateUser = 0,
                        CreateTime = comTime
                    };
                    //添加库存明细
                    sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
                }
                #endregion
                // 更改箱支关系表
                decimal factQty = 0.00m;//托盘总数量
                //标签组托
                var boxGroup = boxInfo.GroupBy(m => m.BoxNo).ToList();
                foreach (var g in boxGroup)
                {
                    decimal boxFullQty = 0;//箱内总数量
                    foreach (var box in g)
                    {
                        if (box.BindNo != null && box.BindNo != 0)
                        {
                            continue;
                        }
                        box.PalletNo = palletNo;
                        box.Status = "2";
                        box.CompleteTime = comTime;
                        box.UpdateTime = comTime;
                        box.UpdateUser = userId;
                        //box.Qty = box.Qty;
                        //box.BitBoxMark = box.Qty == box.FullQty ? "0" : "1";
                        factQty += box.Qty;
                        boxFullQty += box.Qty;
                        #region 库存箱码明细
                        var box2 = new DataBoxInfo()
                        {
                            StockDetailId = sdId1,
                            BoxNo = box.BoxNo,
                            BoxNo2 = box.BoxNo2,
                            BoxNo3 = box.BoxNo3,
                            PalletNo = box.PalletNo,
                            PalletNo2 = box.PalletNo2,
                            PalletNo3 = box.PalletNo3,
                            Qty = box.Qty,
                            FullQty = box.FullQty,
                            Status = "2",//0:未组托  1:已组托 2:已入库 3:已出库 4:已分配 5:已拣货
                            LotNo = box.LotNo,
                            LotText = box.LotText,
                            SkuNo = box.SkuNo,
                            SkuName = box.SkuName,
                            Standard = sku.Standard,
                            ProductionTime = box.ProductionTime,
                            SupplierLot = box.SupplierLot,
                            InspectStatus = sku.IsInspect,
                            InspectMark = box.InspectMark,
                            BitBoxMark = box.BitBoxMark,
                            ExpirationTime = box.ExpirationTime,
                            CreateUser = 0,
                            CreateTime = comTime
                        };
                        //添加库存箱码明细
                        Db.Insertable(box2).ExecuteCommand();
                        #endregion
                        #region  插入车间出入库记录表
                        //插入入库日志
                        var _log = new LogWorkShop
                        {
                            Type = "0",//类型,0:入库 1:出库
                            PalletNo = palletNo,
                            BoxNo=box.BoxNo,
                            LotNo=box.LotNo,
                            SkuNo=box.SkuNo,
                            SkuName=box.SkuName,
                            Qty=box.Qty
                        };
                        //添加库存箱码明细
                        Db.Insertable(_log).ExecuteCommand();
                        #endregion
                    }
                    if (boxFullQty > bNum)
                    {
                        throw new Exception($"绑定失败,{g.Key}箱码绑定数量大于该物品包装数量!");
                    }
                }
                //更改箱支关系表信息
                Db.Updateable(boxInfoList).ExecuteCommand();
                #region 库存
                var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == boxInfoOne.LotNo);
                if (dataStock != null)
                {
                    dataStock.Qty += factQty;
                    Db.Updateable(dataStock).ExecuteCommand();
                }
                else
                {
                    var stock = new DataStock()
                    {
                        SkuNo = sku.SkuNo,
                        SkuName = sku.SkuName,
                        Standard = sku.Standard,
                        LotNo = boxInfoOne.LotNo,
                        LotText = boxInfoOne.LotText,
                        Qty = qty,
                        LockQty = 0,
                        FrozenQty = 0,
                        IsSampling = "0",
                        IsDel = "0",
                        CreateUser = userId,
                        CreateTime = comTime
                    };
                    Db.Insertable(stock).ExecuteCommand();
                }
                #endregion
                // 更改托盘使用状态
                var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{palletNo}';";
                ////添加托盘记录表数据
                //sqlStr += $"insert into LogPalletTrack values('{palletNo}','{boxNo}','组盘','0',getDate(),{userId},NULL,NULL);";
                Db.Ado.ExecuteCommand(sqlStr);
                new OperationASNServer().AddLogOperationAsn("PDA模块", "车间入库", boxNo, "添加", $"添加了托盘码为:{palletNo}、{msgStr}的入库信息", userId);
                //提交事务
                Db.CommitTran();
            }
            catch (Exception e)
            {
                Db.RollbackTran();
                throw new Exception(e.Message);
            }
        }
        /// <summary>
        /// 车间绑定托盘 不贴标物料
        /// </summary>
        /// <param name="model"></param>
        /// <param name="userId"></param>
        /// <exception cref="Exception"></exception>
        public void ChejianQtyIn(string palletNo, string skuNo, string lotNo, decimal qty, string areaNo, int userId)
        {
            try
            {
                #region MyRegion
                if (string.IsNullOrWhiteSpace(palletNo))
                {
                    throw new Exception("托盘号不能为空");
                }
                if (string.IsNullOrWhiteSpace(skuNo))
                {
                    throw new Exception("物料不能为空");
                }
                if (qty <= 0)
                {
                    throw new Exception("数量不能小等0");
                }
                var skuInfo = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == skuNo);
                if (skuInfo == null)
                {
                    throw new Exception("未查询到物料信息");
                }
                var pall = Db.Queryable<SysPallets>().First(m => m.IsDel == "0" && m.PalletNo == palletNo);
                if (pall == null)
                {
                    throw new Exception("未查询到当前托盘信息");
                }
                #endregion
                //开启事务
                Db.BeginTran();
                //当前时间
                var comTime = DateTime.Now;
                #region 包装
                var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == skuInfo.PackagNo);
                var pNum = 0;//托盘物品数量
                var bNum = 0;//箱码物品数量
                //公共方法获取包装数量
                new Common().GetPackQtyInfo(pack.PackagNo, ref pNum, ref bNum);
                #endregion
                #region 库存明细
                var area = Db.Queryable<SysStorageArea>().First(m => m.IsDel == "0" && m.AreaNo == areaNo);
                if (area == null)
                {
                    throw new Exception("入库区域不能为空");
                }
                var tags = "0";
                // 判断库存明细是否已有此托盘信息
                var sd1 = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.SkuNo == skuNo && m.LotNo == lotNo && m.PalletNo == palletNo);
                var sdId1 = 0;
                if (sd1 != null)
                {
                    if (sd1.AreaNo != areaNo)
                    {
                        throw new Exception("选择的区域与库存不同");
                    }
                    sdId1 = sd1.Id;
                    // 库存已存在 更新数据
                    sd1.Qty += qty;
                    sd1.CompleteTime = comTime;
                    sd1.UpdateUser = userId;
                    sd1.UpdateTime = comTime;
                    if (sd1.Qty >= pNum)
                    {
                        sd1.BitPalletMark = "0";
                    }
                    Db.Updateable(sd1).ExecuteCommand();
                }
                else
                {
                    // 库存不存在 插入数据
                    sd1 = new DataStockDetail()
                    {
                        LotNo = lotNo,
                        SupplierLot = "",
                        SkuNo = skuInfo.SkuNo,
                        SkuName = skuInfo.SkuName,
                        Standard = skuInfo.Standard,
                        Qty = qty,
                        LockQty = 0,
                        FrozenQty = 0,
                        InspectQty = 0,
                        WareHouseNo = area.WareHouseNo,//所属仓库
                        RoadwayNo = "",//所属巷道
                        AreaNo = area.AreaNo,//所属区域
                        LocatNo = "",//储位地址
                        PalletNo = palletNo,
                        PalletTags = tags,
                        CompleteTime = comTime,
                        //ProductionTime = boxInfoOne.ProductionTime,
                        //ExpirationTime = boxInfoOne.ExpirationTime,
                        Status = "0",
                        InspectMark = "0",
                        InspectStatus = "1",
                        BitPalletMark = qty >= pNum ?"0" :"1",
                        PackagNo = skuInfo.PackagNo,
                        IsDel = "0",
                        CreateUser = 0,
                        CreateTime = comTime
                    };
                    //添加库存明细
                    sdId1 = Db.Insertable(sd1).ExecuteReturnIdentity();
                }
                #endregion
                // 更改箱支关系表
                decimal factQty = 0.00m;//托盘总数量
                #region 库存
                var dataStock = Db.Queryable<DataStock>().First(m => m.IsDel == "0" && m.SkuNo == skuInfo.SkuNo && m.LotNo == lotNo);
                if (dataStock != null)
                {
                    dataStock.Qty += factQty;
                    Db.Updateable(dataStock).ExecuteCommand();
                }
                else
                {
                    var stock = new DataStock()
                    {
                        SkuNo = skuInfo.SkuNo,
                        SkuName = skuInfo.SkuName,
                        Standard = skuInfo.Standard,
                        LotNo = lotNo,
                        LotText = "",
                        Qty = qty,
                        LockQty = 0,
                        FrozenQty = 0,
                        IsSampling = "0",
                        IsDel = "0",
                        CreateUser = userId,
                        CreateTime = comTime
                    };
                    Db.Insertable(stock).ExecuteCommand();
                }
                #endregion
                #region
                //插入入库日志
                var _log = new LogWorkShop
                {
                    Type = "0",//类型,0:入库 1:出库
                    PalletNo = palletNo,
                    BoxNo = "",
                    LotNo = lotNo,
                    SkuNo = sd1.SkuNo,
                    SkuName = sd1.SkuName,
                    Qty = qty
                };
                //添加库存箱码明细
                Db.Insertable(_log).ExecuteCommand();
                #endregion
                // 更改托盘使用状态
                var sqlStr = $"update SysPallets set Status = '1' where PalletNo = '{palletNo}';";
                ////添加托盘记录表数据
                //sqlStr += $"insert into LogPalletTrack values('{palletNo}','{boxNo}','组盘','0',getDate(),{userId},NULL,NULL);";
                Db.Ado.ExecuteCommand(sqlStr);
                new OperationASNServer().AddLogOperationAsn("PDA模块", "车间入库", skuNo, "添加", $"添加了托盘码为:{palletNo}的入库信息", userId);
                //提交事务
                Db.CommitTran();
            }
            catch (Exception e)
            {
                Db.RollbackTran();
                throw new Exception(e.Message);
            }
        }
        #endregion
@@ -5504,7 +5995,7 @@
                #endregion
                #region 质检请验
                if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1")
                if ((notice.Type == "1" || notice.Type == "4" || notice.Type == "5") && sku.IsInspect != "1"  && sku.IsControlled != "1")
                {
                    var qualityRequest = Db.Queryable<BllQualityInspectionRequest>().First(m => m.IsDel == "0" && m.SkuNo == sku.SkuNo && m.LotNo == bind.LotNo && m.SupplierLot == bind.SupplierLot);
                    if (qualityRequest == null)
@@ -5583,9 +6074,12 @@
                {
                    foreach (var item in stockDetail)
                    {
                        if (!string.IsNullOrEmpty(item.WareHouseNo))
                        if (!string.IsNullOrEmpty(item.WareHouseNo) && !string.IsNullOrEmpty(item.AreaNo))
                        {
                            throw new Exception("该托盘未在库外,请核查!");
                            if (item.AreaNo != "B06" && item.AreaNo != "B07" && item.AreaNo != "B09")
                            {
                                throw new Exception("该托盘未在库外,请核查!");
                            }
                        }
                    }
                    iscount = 1; //回流入库
@@ -6022,6 +6516,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取样业务接口
        //获取未组托或已组托的箱码级别