Administrator
2024-06-25 65dac074f71375381eba0a5ff8dc108cacafc3f9
Wms/WMS.BLL/DataServer/StockDetailServer.cs
@@ -403,5 +403,87 @@
            }
        }
        #endregion
        #region 二楼业务
        /// <summary>
        /// 添加托盘库存明细
        /// </summary>
        public void InsertStockDetail(string PalletNo,string WareHouseNo,string AreaNo,string LocatNo, string PalletStatus,int userId)
        {
            try
            {
                if (string.IsNullOrEmpty(PalletNo))
                {
                    throw new Exception("托盘号不能为空!");
                }
                if (string.IsNullOrEmpty(WareHouseNo))
                {
                    throw new Exception("所属仓库不能为空!");
                }
                if (string.IsNullOrEmpty(AreaNo))
                {
                    throw new Exception("所属区域不能为空!");
                }
                if (string.IsNullOrEmpty(LocatNo))
                {
                    throw new Exception("储位地址不能为空!");
                }
                if (string.IsNullOrEmpty(PalletStatus))
                {
                    throw new Exception("托盘状态不能为空!");
                }
                var palletInfo = Db.Queryable<DataStockDetail>().First(w => w.PalletNo == PalletNo);
                if (palletInfo != null)
                {
                    throw new Exception($"库存中已有编号为:{PalletNo}的明细,请勿重复添加!");
                }
                Db.BeginTran();
                var comTime = DateTime.Now;
                var model = new DataStockDetail()
                {
                    Qty = 0,
                    LockQty = 0,
                    FrozenQty = 0,
                    InspectQty = 0,
                    WareHouseNo = WareHouseNo,//所属仓库
                    RoadwayNo = "",//所属巷道
                    AreaNo = AreaNo,//所属区域
                    LocatNo = LocatNo,//储位地址
                    PalletNo = PalletNo,
                    PalletNo2 = "",
                    PalletNo3 = "",
                    PalletTags = "0",
                    CompleteTime = comTime,
                    ProductionTime = null,
                    ExpirationTime = null,
                    Status = "0",
                    InspectMark = "0",
                    InspectStatus = "0",//待检验
                    BitPalletMark = "0",
                    PackagNo = "",
                    IsBale = "0",
                    IsBelt = "0",
                    PalletStatus = PalletStatus,
                    IsDel = "0",
                    CreateUser = userId,
                    CreateTime = comTime
                };
                //插入库存明细
                Db.Insertable(model).ExecuteCommand();
                Db.CommitTran();
            }
            catch (Exception e)
            {
                //回滚事务
                Db.RollbackTran();
                throw new Exception(e.Message);
            }
        }
        #endregion
    }
}