yuyou_x
2024-02-04 99185f80296a5bf22e7aed76e56f63624d6e9a58
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -15,6 +15,8 @@
using WMS.Entity.BllSoEntity;
using Model.ModelVm.PdaVm;
using Model.ModelDto.PdaDto;
using Dm;
using Model.InterFaceModel;
namespace WMS.BLL.BllPdaServer
{
@@ -157,6 +159,31 @@
                    sqlString += $"group by BoxNo,SkuNo,SkuName,LotNo; ";
                }
                var models = Db.Ado.SqlQuery<BoxInfoDto>(sqlString);
                return models;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        // 根据托盘号或箱码获取托盘信息   liudl
        public List<PalletBindDto> GetPalletBindInfo(BllPalletBind model)
        {
            try
            {
                string sqlString = string.Empty;
                sqlString = "select b.SkuNo,b.SkuName,a.LotNo,a.Qty,a.PalletNo,a.Id from BllPalletBind a left join BllArrivalNoticeDetail b on a.ASNDetailNo = b.Id where a.IsDel = '0' and b.IsDel = '0' ";
                if (!string.IsNullOrEmpty(model.PalletNo))
                {
                    sqlString += $"and PalletNo = '{model.PalletNo}' and a.Status = '0' ";
                }
                else
                {
                    throw new Exception("托盘号异常!");
                }
                var models = Db.Ado.SqlQuery<PalletBindDto>(sqlString);
                return models;
            }
@@ -474,6 +501,121 @@
                    sqlString = $"update SysPallets set Status = '0' where PalletNo = '{boxModel[0].PalletNo}';";
                    Db.Ado.ExecuteCommand(sqlString);
                }
                Db.CommitTran();
                return strMsg;
            }
            catch (Exception ex)
            {
                Db.RollbackTran();
                throw ex;
            }
        }
        // 删除已组信息
        public string DelPalletBind(BllPalletBind model)
        {
            string strMsg = "";
            string sqlString = string.Empty;
            try
            {
                if (model.Id == 0)
                {
                    throw new Exception("-1:托盘ID不可为0!");
                }
                //获取托盘绑定信息
                var bind = Db.Queryable<BllPalletBind>().First(a => a.IsDel == "0" && a.Status == "0" && a.Id == model.Id);
                //验证托盘绑定信息是否为空
                if (bind == null)
                {
                    throw new Exception("-1:未获取到对应托盘信息,请核实!");
                }
                //判断托盘绑定信息是否不是等待执行
                if (bind.Status != "0")
                {
                    throw new Exception("-1:该托盘已正在入库,请核实!");
                }
                //获取是否有指定库位
                SysStorageLocat locat = new SysStorageLocat();
                int isNullLocat = 0;
                //判断储位是否为空
                if (!string.IsNullOrWhiteSpace(bind.LocatNo))
                {
                    isNullLocat = 1;
                    locat = Db.Queryable<SysStorageLocat>().First(a=>a.IsDel == "0" && a.WareHouseNo == bind.WareHouseNo && a.RoadwayNo == bind.RoadwayNo && a.LocatNo == bind.LocatNo);
                    //判断储位地址是否为正在入库
                    if (locat.Status != "2")
                    {
                        throw new Exception("-1:当前托盘绑定的储位地址不是正在入库,请核实!");
                    }
                }
                //获取托盘信息
                var pallet = Db.Queryable<SysPallets>().First(a => a.IsDel == "0" && a.PalletNo == model.PalletNo);
                //判断托盘信息是否为空
                if (pallet == null)
                {
                    throw new Exception("-1:未获取到对应托盘信息,请核实!");
                }
                //获取对应入库单据总单
                var notice = Db.Queryable<BllArrivalNotice>().First(a => a.IsDel == "0" && a.ASNNo == bind.ASNNo);
                //验证入库单总单信息
                if (notice == null)
                {
                    throw new Exception("-1:未获取到对应入库单总单信息,请核实!");
                }
                //获取对应入库单据明细
                var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(a => a.IsDel == "0" && a.Id == bind.ASNDetailNo);
                //验证入库单单据明细
                if (noticeDetail == null)
                {
                    throw new Exception("-1:未获取到对应入库单单据明细信息,请核实!");
                }
                Db.BeginTran();
                //减少入库单明细数量 判断已组数量是否为0 再判断完成数量是否为0
                noticeDetail.FactQty -= bind.Qty;
                //判断已组数量是否为0
                if (noticeDetail.FactQty == 0)
                {
                    //判断是否有完成数量
                    if (noticeDetail.CompleteQty == 0)
                    {
                        noticeDetail.Status = "0"; //入库单明细状态
                        notice.Status = "0"; //入库单总单状态
                    }
                }
                Db.Updateable(noticeDetail).ExecuteCommand();
                Db.Updateable(notice).ExecuteCommand();
                // 清除托盘绑定上信息
                //ASNNo,ASNDetailNo,Qty,FullQty,LotNo,LotText,SupplierLot,IsDel,UpdateTime,UpdateUser
                bind.ASNNo = ""; //入库单号
                bind.ASNDetailNo = 0; //入库单明细id
                bind.Qty = 0; //数量
                bind.FullQty = 0; //整托数量
                bind.LotNo = ""; //批次
                bind.LotText = ""; //批次描述
                bind.SupplierLot = ""; //供货批次
                bind.IsDel = "1"; //是否删除
                bind.UpdateTime = Db.GetDate(); //修改时间
                bind.UpdateUser = model.CreateUser; //修改人
                if (isNullLocat == 1)
                {
                    bind.LocatNo = ""; //储位地址
                    bind.RoadwayNo = ""; //所属巷道
                    bind.WareHouseNo = ""; //所属仓库
                    //修改储位信息状态
                    locat.Status = "0"; //储位状态 0:空储位
                    Db.Updateable(locat).ExecuteCommand();
                }
                Db.Updateable(bind).ExecuteCommand();
                //修改托盘信息状态
                pallet.Status = "0"; //0:未使用
                Db.Updateable(pallet).ExecuteCommand();
                Db.CommitTran();
                return strMsg;
@@ -1773,7 +1915,7 @@
                //添加托盘记录表数据
                sqlStr += $"insert into LogPalletTrack values('{model.PalletNo}','{model.AsnNo}','组盘','0',getDate(),{userId},NULL,NULL);";
                Db.Ado.ExecuteCommand(sqlStr);
                new OperationASNServer().AddLogOperationAsn("PDA模块", "产品组托", model.AsnNo, "添加", $"添加了托盘码为:{model.PalletNo}、{msgStr}的组盘信息", userId);
                new OperationASNServer().AddLogOperationAsn("PDA模块", "托盘绑定1", model.AsnNo, "添加", $"添加了托盘码为:{model.PalletNo}、{msgStr}的组盘信息", userId);
                Db.CommitTran();
            }