Administrator
2024-02-02 ec258841a0f5249935578544ebed9121fbc71b2d
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -132,7 +132,7 @@
        public List<BoxInfoDto> GetBoxInfos(BoxInfoVm model)
        {
            try
            {
            {
                string sqlString = string.Empty;
                if (model.IsHuiKu == 0)
                {
@@ -517,7 +517,7 @@
                #region 是否回流入库
                int iscount = 0;
                //库存明细信息
                var stockDetail = Db.Queryable<DataStockDetail>().Where(a => a.IsDel == "0" && a.PalletNo == model.PalletNo).ToList();
                var stockDetail = Db.Queryable<DataStockDetail>().Where(a => a.IsDel == "0" && a.PalletNo == model.PalletNo).ToList();
                //验证库存是否拥有该托信息
                if (stockDetail != null && stockDetail.Count > 0)
                {
@@ -635,7 +635,7 @@
                            strMsg = "-1:箱码信息不存在,请核查!";
                            return strMsg;
                        }
                        else
                        else
                        {
                            // 改变箱支关系表状态:已入库
                            sqlString = $"Update BllBoxInfo set Status = '2' where PalletNo = '{model.PalletNo}' and ASNNo = '{model.ASNNo}' and Status = '1'";
@@ -644,7 +644,7 @@
                            pallQty = boxinfo2.Sum(w => w.Qty);
                            //入库单明细完成数量增加
                            noticeItem.CompleteQty += pallQty;
                        }
                        }
                        //判断入库数量增加后是否大于等于单据数量
                        if (noticeItem.CompleteQty >= noticeItem.Qty)
                        {
@@ -703,7 +703,7 @@
                            sqlString = "select sum(qty) from BllBoxInfo where isdel = 0 and ";
                            sqlString += $"BindNo = '{palletbindInfo.Id}'";
                            int inspectQty = Db.Ado.GetInt(sqlString);
                            // 添加库存明细表
                            detailModel = new DataStockDetail()
                            {
@@ -1109,7 +1109,7 @@
            try
            {
                //入库中
                var aSNNoList= Db.Ado.SqlQuery<string>($"SELECT DISTINCT ASNNo from BllPalletBind where IsDel=0 and Status=0 and PalletNo='{palletNo}' ").ToList();
                var aSNNoList = Db.Ado.SqlQuery<string>($"SELECT DISTINCT ASNNo from BllPalletBind where IsDel=0 and Status=0 and PalletNo='{palletNo}' ").ToList();
                if (aSNNoList.Count <= 0)
                {
                    //库外托盘或平库托盘
@@ -1166,7 +1166,7 @@
        //拼托入库
        public void CompleteInStockLing(PdaLingAsnVm model, int userId)
        {
            try
            try
            {
                if (string.IsNullOrWhiteSpace(model.AsnNo))
                {
@@ -1203,10 +1203,10 @@
                foreach (var item in boxinfo)
                {
                    if (!string.IsNullOrEmpty(item.PalletNo))
                    {
                    {
                        throw new Exception("-1:该箱码已绑定其他托盘,请先解绑托盘!");
                    }
                    bNum += item.Qty;
                    bNum += item.Qty;
                }
                if (bNum == boxinfo[0].FullQty)
                {
@@ -1267,7 +1267,7 @@
                    //修改入库单总单信息
                    arrival.Status = "2";
                    arrival.CompleteTime = serverTime;
                    arrival.UpdateUser =userId;
                    arrival.UpdateUser = userId;
                    arrival.UpdateTime = serverTime;
                    Db.Updateable(arrival).ExecuteCommand();
                }
@@ -1373,7 +1373,7 @@
                #region 库存明细表
                var boxinfoItem = boxinfo.First();
                var detailModel = Db.Queryable<DataStockDetail>() .First(it => it.PalletNo == model.PalletNo && it.LotNo == arrivalnotice.LotNo
                var detailModel = Db.Queryable<DataStockDetail>().First(it => it.PalletNo == model.PalletNo && it.LotNo == arrivalnotice.LotNo
                     && it.SkuNo == arrivalnotice.SkuNo && it.Standard == arrivalnotice.Standard && it.IsDel == "0");
                var stId = 0;
                if (detailModel == null || detailModel.Id == 0)
@@ -1537,19 +1537,24 @@
                {
                    throw new Exception("-1:托盘号不可为空!");
                }
                if (string.IsNullOrEmpty(model.BoxNo))
                //判断物料数量是否为0 为0判断箱码信息 不为0继续
                if (model.SkuQty == 0)
                {
                    throw new Exception("-1:箱码信息不可为空!");
                }
                if (model.IsContinue == "1")
                {
                    if (string.IsNullOrWhiteSpace(model.TailBoxNo))
                    if (string.IsNullOrEmpty(model.BoxNo))
                    {
                        throw new Exception("-1:开启连续组托时,尾箱码信息不可为空!");
                        throw new Exception("-1:箱码信息不可为空!");
                    }
                    if (model.IsContinue == "1")
                    {
                        if (string.IsNullOrWhiteSpace(model.TailBoxNo))
                        {
                            throw new Exception("-1:开启连续组托时,尾箱码信息不可为空!");
                        }
                    }
                }
                #endregion
                // 验证入库单总表
                var notice = Db.Queryable<BllArrivalNotice>().First(m => m.IsDel == "0" && m.ASNNo == model.AsnNo);
@@ -1560,11 +1565,11 @@
                //入库单类型,0:成品入库 1:采购入库 2:中间品入库 3:退货入库 4:车间余料退回入库 5:其它入库 6:代储入库
                if (notice.Type == "0" || notice.Type == "3" || notice.Type == "5" || notice.Type == "6")
                {
                    BindPalletForBox(model,userId,origin);
                    BindPalletForBox(model, userId, origin);
                }
                else
                {
                    BindPalletForLabelBox(model,userId);
                    BindPalletForLabelBox(model, userId);
                }
            }
            catch (Exception ex)
@@ -1763,7 +1768,7 @@
                // 更改入库单明细已组数量
                var sqlString = string.Empty;
                sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{factQty}' where id = '{model.AsnDetailId}';";
                sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{bind.Qty}' where id = '{model.AsnDetailId}';";
                Db.Ado.ExecuteCommand(sqlString);
                // 更改入库单及入库明细状态
@@ -1875,7 +1880,7 @@
                        PalletNo = model.PalletNo,
                        PalletNo2 = "",
                        PalletNo3 = "",
                        Qty = 0,
                        Qty = model.SkuQty,
                        FullQty = pNum,
                        Status = "0",
                        Type = "0",
@@ -1901,7 +1906,7 @@
                }
                #region 箱码信息
                var boxInfoList = new List<BllLabelBoxNo>();
                var msgStr = $"箱号为{model.BoxNo}";
                var boxInfoList = new List<BllLabelBoxNo>();
                //首箱
@@ -1924,6 +1929,29 @@
                    var sql = $"select * from BllLabelBoxNo where IsDel = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}' and Level='1'; ";
                    var list = Db.Ado.SqlQuery<BllLabelBoxNo>(sql);
                    boxInfoList.AddRange(list);
                decimal factQty = 0.00m;//托盘总数量
                if (model.SkuQty == 0)
                {
                    //首箱
                    var boxInfo = Db.Queryable<BllLabelBoxNo>().Where(m => m.IsDel == "0" && m.BoxNo == model.BoxNo && m.IsUse == "0" && m.Level == "1").ToList();
                    if (boxInfo.Count == 0)
                    {
                        throw new Exception("-1:箱码信息不存在!");
                    }
                    //是否连续组托
                    if (model.IsContinue == "1")
                    {
                        boxInfoList.AddRange(boxInfo);
                        //尾箱
                        var boxInfo2 = Db.Queryable<BllLabelBoxNo>().Where(m => m.IsDel == "0" && m.BoxNo == model.TailBoxNo && m.IsUse == "0" && m.Level == "1").ToList();
                        if (boxInfo2.Count == 0)
                        {
                            throw new Exception("-1:尾箱码信息不存在!");
                        }
                        boxInfoList.AddRange(boxInfo2);
                        var sql = $"select * from BllLabelBoxNo where IsDel = '0' and IsUse = '0' and boxNo>'{model.BoxNo}' and boxNo<'{model.TailBoxNo}' and Level='1'; ";
                        var list = Db.Ado.SqlQuery<BllLabelBoxNo>(sql);
                        boxInfoList.AddRange(list);
                    //找到相关的二级码
                    foreach (var item in boxInfoList)
@@ -2032,7 +2060,7 @@
                // 更改入库单明细已组数量
                var sqlString = string.Empty;
                sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{factQty}' where id = '{model.AsnDetailId}';";
                sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{bind.Qty}' where id = '{model.AsnDetailId}';";
                Db.Ado.ExecuteCommand(sqlString);
                // 更改入库单及入库明细状态