yuyou_x
2024-02-21 a339e5234e6299d32672aaae648e5315900c2633
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -1761,8 +1761,6 @@
                {
                    throw new Exception("-1:单据号不可为空!");
                }
                //根据单据号获取入库单总单
                var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
                if (model.AsnDetailId == null || model.AsnDetailId == 0)
                {
                    throw new Exception("-1:物料不可为空!");
@@ -1770,6 +1768,12 @@
                if (string.IsNullOrEmpty(model.PalletNo))
                {
                    throw new Exception("-1:托盘号不可为空!");
                }
                //根据单据号获取入库单总单
                var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == model.AsnNo);
                if (notice.Status != "0" && notice.Status != "1")
                {
                    throw new Exception("-1:入库单状态不是等待执行或执行完成!");
                }
                if (string.IsNullOrEmpty(model.LotNo))
                {
@@ -1815,6 +1819,12 @@
                if (pallet == null)
                {
                    throw new Exception("未查询到托盘信息,请核实!");
                }
                //判断托盘是否在库外
                var stockDetail = Db.Queryable<DataStockDetail>().First(m => m.IsDel == "0" && m.PalletNo == model.PalletNo);
                if (stockDetail != null && !string.IsNullOrEmpty(stockDetail.WareHouseNo))
                {
                    throw new Exception("该托盘未在库外,请核实!");
                }
                // 验证入库单明细是否存在
                var detail = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.IsDel == "0" && m.Id == model.AsnDetailId && m.ASNNo == model.AsnNo && m.LotNo.Contains(model.LotNo));
@@ -1916,6 +1926,7 @@
                        throw new Exception("-1:当前托盘正在执行中,绑定失败,请核实!");
                    }
                    bindId = bind.Id;
                    bind.Qty += model.SkuQty;
                }
                #region 箱码信息
@@ -1950,6 +1961,7 @@
                // 更改箱支关系表
                decimal factQty = 0.00m;//托盘总数量
                //成品组托
                if (model.SkuQty == 0)
                {
                    var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
@@ -2009,7 +2021,7 @@
                var sqlString = string.Empty;
                if (factQty == 0)
                {
                    sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{bind.Qty}' where id = '{model.AsnDetailId}';";
                    sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{model.SkuQty}' where id = '{model.AsnDetailId}';";
                }
                else
                {
@@ -2077,6 +2089,13 @@
                //验证库存是否拥有该托信息
                if (stockDetail != null && stockDetail.Count > 0)
                {
                    foreach (var item in stockDetail)
                    {
                        if (!string.IsNullOrEmpty(item.WareHouseNo))
                        {
                            throw new Exception("该托盘未在库外,请核查!");
                        }
                    }
                    iscount = 1; //回流入库
                }
                #endregion
@@ -2108,22 +2127,6 @@
                Db.BeginTran();//开启事务
                if (iscount == 0)//正常入库
                {
                    #region 箱码信息
                    var boxInfoList = Db.Queryable<BllBoxInfo>().Where(w => w.IsDel == "0" && w.ASNNo == model.ASNNo).ToList();
                    //验证箱码信息是否存在
                    if (boxInfoList.Count <= 0)
                    {
                        throw new Exception("箱码信息不存在,请核查!");
                    }
                    foreach (var item in boxInfoList)
                    {
                        item.Status = "2"; // 改变箱支关系表状态:已入库
                        item.UpdateTime = serverTime;
                        item.UpdateUser = model.CreateUser;
                    }
                    Db.Updateable(boxInfoList).ExecuteCommand();
                    #endregion
                    #region 入库总单信息
                    var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.Status != "3" && a.ASNNo == model.ASNNo);
                    //验证入库单总单是否关闭
@@ -2135,6 +2138,30 @@
                    if (notice.Status == "3")
                    {
                        throw new Exception("入库单总单已关闭,请核查!");
                    }
                    #endregion
                    #region 箱码信息
                    var boxInfoList = Db.Queryable<BllBoxInfo>().Where(w => w.IsDel == "0" && w.ASNNo == model.ASNNo).ToList();
                    // type 0:成品入库 1:采购入库 2:中间品入库 3:退货入库 4:车间余料退回入库 5:其它入库 6:代储入库 7:寄存入库
                    if (notice.Type == "2" || notice.Type == "6" || notice.Type == "7")
                    {
                        // 不贴码物料 无需验证箱码信息
                    }
                    else
                    {
                        //验证箱码信息是否存在
                        if (boxInfoList.Count <= 0)
                        {
                            throw new Exception("箱码信息不存在,请核查!");
                        }
                        foreach (var item in boxInfoList)
                        {
                            item.Status = "2"; // 改变箱支关系表状态:已入库
                            item.UpdateTime = serverTime;
                            item.UpdateUser = model.CreateUser;
                        }
                        Db.Updateable(boxInfoList).ExecuteCommand();
                    }
                    #endregion
@@ -2226,7 +2253,7 @@
                            ASNDetailNo = (int)bindInfo.ASNDetailNo,
                            WareHouseNo = "W02",
                            RoadwayNo = "",
                            AreaNo = "",
                            AreaNo = storageLocat.AreaNo,
                            LocatNo = model.LocatNo,
                            PalletNo = model.PalletNo,
                            PalletNo2 = bindInfo.PalletNo2,
@@ -2251,6 +2278,7 @@
                    {
                        stId = detailModel.Id;
                        detailModel.LocatNo = model.LocatNo;
                        detailModel.AreaNo = storageLocat.AreaNo;
                        detailModel.UpdateTime = serverTime;
                        detailModel.UpdateUser = (int)model.CreateUser;
                        // 变更储位地址