Administrator
2024-02-05 fd2625521b82f91dcb8b1c9a227dc8738f580d40
PDA平库入库模块确认入库功能开发
5个文件已修改
415 ■■■■■ 已修改文件
Pda/View/AsnSetting/pingKuEnter.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs 375 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.Entity/DataEntity/DataStockDetail.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Wms/Wms/Controllers/PdaAsnController.cs 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Pda/View/AsnSetting/pingKuEnter.html
@@ -409,7 +409,7 @@
                        ASNNo:$("#bar").val()
                    }
                    param.Qty=Number(param.Qty)
                    sendData(IP + "/PdaAsn/CompleteInStock", param, 'post', function(res) {
                    sendData(IP + "/PdaAsn/ConfirmInStock", param, 'post', function(res) {
                        if (res.code == 0) { //成功 
                            layer.msg(res.msg, {
                                icon: 1,
Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -2004,5 +2004,380 @@
            }
        }
        #endregion
        #region 平库入库
        /// <summary>
        /// 平库确认入库
        /// </summary>
        /// <param name="model"></param>
        public void ConfirmInStock(PalletBindVm model)
        {
            try
            {
                #region 验证信息
                if (string.IsNullOrEmpty(model.ASNNo))
                {
                    throw new Exception("入库单不能为空!");
                }
                if (string.IsNullOrEmpty(model.PalletNo))
                {
                    throw new Exception("托盘条码不能为空!");
                }
                if (string.IsNullOrEmpty(model.LocatNo))
                {
                    throw new Exception("储位地址不能为空!");
                }
                #endregion
                //获取当前时间
                DateTime serverTime = Db.Ado.GetDateTime("select GETDATE();");
                #region 是否回流入库
                int iscount = 0;
                //库存明细信息
                var stockDetail = Db.Queryable<DataStockDetail>().Where(a => a.IsDel == "0" && a.PalletNo == model.PalletNo).ToList();
                //验证库存是否拥有该托信息
                if (stockDetail != null && stockDetail.Count > 0)
                {
                    iscount = 1; //回流入库
                }
                #endregion
                #region 托盘绑定信息
                var bindInfo = Db.Queryable<BllPalletBind>().First(w => w.IsDel == "0" && w.ASNNo == model.ASNNo && w.PalletNo == model.PalletNo && w.Status != "2");
                if (iscount == 0)
                {
                    if (bindInfo == null)
                    {
                        throw new Exception("托盘绑定信息不存在,请核查!");
                    }
                    if (!string.IsNullOrEmpty(bindInfo.WareHouseNo))
                    {
                        throw new Exception("该托盘未在库外,请核查!");
                    }
                }
                #endregion
                #region 地码信息(储位信息)
                var storageLocat = Db.Queryable<SysStorageLocat>().First(w => w.IsDel == "0" && w.LocatNo == model.LocatNo && w.Status == "0" && w.WareHouseNo == "W02");
                if (storageLocat == null)
                {
                    throw new Exception("储位信息不存在或非空闲状态,请核查!");
                }
                #endregion
                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);
                    //验证入库单总单是否关闭
                    if (notice == null)
                    {
                        throw new Exception("入库单总单信息不存在,请核查!");
                    }
                    //判断入库单总单是否为已关闭
                    if (notice.Status == "3")
                    {
                        throw new Exception("入库单总单已关闭,请核查!");
                    }
                    #endregion
                    bool isFinsh = true;//是否全部入库完成
                    #region 入库单明细
                    var noticeDetail = Db.Queryable<BllArrivalNoticeDetail>().First(w => w.IsDel == "0" && w.ASNNo == model.ASNNo && w.Id == bindInfo.ASNDetailNo);
                    if (noticeDetail == null)
                    {
                        throw new Exception("入库单明细信息不存在,请核查!");
                    }
                    noticeDetail.CompleteQty += bindInfo.Qty;//增加入库数量
                    //判断入库数量增加后是否大于等于单据数量
                    if (noticeDetail.CompleteQty >= noticeDetail.Qty)
                    {
                        noticeDetail.Status = "2";//执行完成
                        noticeDetail.CompleteTime = serverTime;
                    }
                    else
                    {
                        noticeDetail.Status = "1";//正在执行
                        isFinsh = false;
                    }
                    noticeDetail.UpdateUser = model.CreateUser;
                    noticeDetail.UpdateTime = serverTime;
                    Db.Updateable(noticeDetail).ExecuteCommand();
                    #endregion
                    #region 物料信息
                    var sku = Db.Queryable<SysMaterials>().First(s => s.SkuNo == noticeDetail.SkuNo && s.IsDel == "0" && s.SkuName == noticeDetail.SkuName);
                    //判断物料信息是否为空
                    if (sku == null)
                    {
                        throw new Exception("物料信息不存在,请核查!");
                    }
                    #endregion
                    #region 库存总表
                    // 判断当前物料库存表是否已存在
                    var stockModel = Db.Queryable<DataStock>().First(w => w.IsDel == "0" && w.SkuNo == noticeDetail.SkuNo && w.LotNo == bindInfo.LotNo && w.Standard == noticeDetail.Standard);
                    if (stockModel == null || stockModel.Id == 0)
                    {
                        stockModel = new DataStock
                        {
                            LotNo = bindInfo.LotNo,
                            LotText = bindInfo.LotText,
                            SupplierLot = bindInfo.SupplierLot,
                            SkuNo = noticeDetail.SkuNo,
                            SkuName = noticeDetail.SkuName,
                            Qty = bindInfo.Qty,
                            Standard = noticeDetail.Standard,
                            CreateUser = (int)model.CreateUser,
                            CreateTime = serverTime
                        };
                        //新增库存总信息
                        Db.Insertable<DataStock>(stockModel).ExecuteCommand();
                    }
                    else
                    {
                        stockModel.Qty += bindInfo.Qty;
                        stockModel.UpdateUser = (int)model.CreateUser;
                        stockModel.UpdateTime = serverTime;
                        //修改库存总信息
                        Db.Updateable(stockModel).ExecuteCommand();
                    }
                    #endregion
                    #region 库存明细表
                    // 判断当前托盘是否已存在(拣货回库托盘)
                    var detailModel = Db.Queryable<DataStockDetail>().First(it => it.PalletNo == bindInfo.PalletNo && it.LotNo == bindInfo.LotNo && it.SkuNo == noticeDetail.SkuNo
                        && it.Standard == noticeDetail.Standard && it.IsDel == "0");
                    var stId = 0;
                    if (detailModel == null || detailModel.Id == 0)
                    {
                        // 添加库存明细表
                        detailModel = new DataStockDetail()
                        {
                            LotNo = bindInfo.LotNo,
                            LotText = bindInfo.LotText,
                            SupplierLot = noticeDetail.SupplierLot,
                            SkuNo = noticeDetail.SkuNo,
                            SkuName = noticeDetail.SkuName,
                            Standard = noticeDetail.Standard,
                            Qty = bindInfo.Qty,
                            LockQty = 0,
                            FrozenQty = 0,
                            InspectQty = bindInfo.Qty,
                            ASNNo = noticeDetail.ASNNo,
                            ASNDetailNo = (int)bindInfo.ASNDetailNo,
                            WareHouseNo = "W02",
                            RoadwayNo = "",
                            AreaNo = "",
                            LocatNo = model.LocatNo,
                            PalletNo = model.PalletNo,
                            PalletNo2 = bindInfo.PalletNo2,
                            PalletNo3 = bindInfo.PalletNo3,
                            CompleteTime = serverTime,
                            ProductionTime = bindInfo.ProductionTime,
                            ExpirationTime = bindInfo.ExpirationTime,
                            Status = "0",
                            InspectMark = bindInfo.InspectMark,
                            BitPalletMark = bindInfo.BitPalletMark,
                            InspectStatus = sku.IsInspect,// 组盘的时候就要默认设定好是否合格
                            PackagNo = sku.PackagNo,
                            IsBale = bindInfo.IsBale,
                            IsBelt = bindInfo.IsBelt,
                            CreateUser = (int)model.CreateUser,
                            CreateTime = serverTime
                        };
                        stId = Db.Insertable<DataStockDetail>(detailModel).ExecuteReturnIdentity();
                    }
                    else
                    {
                        stId = detailModel.Id;
                        detailModel.LocatNo = model.LocatNo;
                        detailModel.UpdateTime = serverTime;
                        detailModel.UpdateUser = (int)model.CreateUser;
                        // 变更储位地址
                        Db.Updateable<DataStockDetail>(detailModel).UpdateColumns(it => new { it.LocatNo, it.UpdateTime, it.UpdateUser }).ExecuteCommand();
                    }
                    #endregion
                    #region 任务及组托信息
                    //创建任务信息
                    var taskNo = new Common().GetMaxNo("TK");
                    var exTask = new LogTask    //入库任务
                    {
                        TaskNo = taskNo,
                        Sender = "WMS",
                        Receiver = "PDA",
                        IsSuccess = 1, //是否下发成功 0失败 1成功
                        SendDate = serverTime,  //发送时间
                        BackDate = serverTime,  //返回时间
                        StartLocat = "",//起始位置
                        EndLocat = "力诺平库",//目标位置
                        PalletNo = bindInfo.PalletNo,//托盘码
                        IsSend = 0,//是否可再次下发
                        IsCancel = 0,//是否可取消
                        IsFinish = 0,//是否可完成
                        Type = "0",//任务类型 0 入库任务 1 出库任务  2 移库任务
                        Status = "2",//任务状态0:等待执行1正在执行2执行完成
                        OrderType = "0",//0 入库单 1 出库单  2 盘点单  3 移库单
                        Msg = "力诺平库的入库任务",
                    };
                    Db.Insertable(exTask).ExecuteCommand();
                    //修改组托状态
                    bindInfo.Status = "2"; //2 入库完成
                    bindInfo.WareHouseNo = "W02";//所属仓库
                    bindInfo.LocatNo = model.LocatNo;//储位地址
                    bindInfo.UpdateTime = serverTime;
                    bindInfo.UpdateUser = model.CreateUser;
                    bindInfo.CompleteTime = serverTime; //完成时间
                    bindInfo.TaskNo = taskNo; //任务号
                    Db.Updateable(bindInfo).ExecuteCommand();
                    #endregion
                    #region 库存箱支明细表
                    // 插入新组的箱支信息
                    var comTime = DateTime.Now;
                    foreach (var item in boxInfoList)
                    {
                        var info = new DataBoxInfo()
                        {
                            StockDetailId = stId,
                            BindNo = bindInfo.Id,
                            BoxNo = item.BoxNo,
                            BoxNo2 = item.BoxNo2,
                            BoxNo3 = item.BoxNo3,
                            PalletNo = item.PalletNo,
                            PalletNo2 = item.PalletNo2,
                            PalletNo3 = item.PalletNo3,
                            Qty = item.Qty,
                            FullQty = item.FullQty,
                            Status = "2",
                            LotNo = item.LotNo,
                            LotText = item.LotText,
                            SkuNo = item.SkuNo,
                            SkuName = item.SkuName,
                            Standard = sku.Standard,
                            ProductionTime = item.ProductionTime,
                            SupplierLot = item.SupplierLot,
                            InspectMark = item.InspectMark,
                            BitBoxMark = item.BitBoxMark,
                            InspectStatus = item.InspectStatus,
                            //InspectTime = item.,
                            IsDel = "0",
                            CreateUser = 0,
                            CreateTime = comTime
                        };
                        Db.Insertable(info).ExecuteCommand();
                    }
                    #endregion
                    var entryList = Db.Queryable<BllArrivalNoticeDetail>().Where(w => w.IsDel == "0" && w.ASNNo == notice.ASNNo && w.Id != noticeDetail.Id && w.Status != "2").ToList();
                    if (isFinsh && entryList.Count <= 0)//入库单明细全部完成
                    {
                        //修改入库单总单信息
                        notice.Status = "2";
                        notice.UpdateUser = model.CreateUser;
                        notice.UpdateTime = serverTime;
                        Db.Updateable(notice).ExecuteCommand();
                    }
                    else
                    {
                        //判断总单状态是否为正在执行
                        if (notice.Status == "0")
                        {
                            //修改入库单总单信息
                            notice.Status = "1";
                            notice.UpdateUser = model.CreateUser;
                            notice.UpdateTime = serverTime;
                            Db.Updateable(notice).ExecuteCommand();
                        }
                    }
                }
                else
                {
                    //修改库存明细信息
                    foreach (var item in stockDetail)
                    {
                        item.Status = "0"; //状态更改为待分配
                        item.WareHouseNo = "W02"; //所属仓库
                        item.LocatNo = model.LocatNo;//储位地址
                        item.UpdateTime = serverTime; //修改时间
                        item.UpdateUser = model.CreateUser; //修改人
                        //修改库存明细信息
                        Db.Updateable(item).ExecuteCommand();
                    }
                    //获取拣货信息
                    var alotr = Db.Queryable<BllExportAllot>().First(a => a.IsDel == "0" && a.PalletNo == model.PalletNo && a.Status == "4");
                    if (alotr != null)
                    {
                        alotr.Status = "5"; //5 已完成
                        alotr.UpdateUser = model.CreateUser; //修改人
                        alotr.UpdateTime = serverTime; //修改时间
                        //修改拣货信息
                        Db.Updateable(alotr).ExecuteCommand();
                    }
                    #region 任务及组托信息
                    //创建任务信息
                    var taskNo = new Common().GetMaxNo("TK");
                    var exTask = new LogTask    //入库任务
                    {
                        TaskNo = taskNo,
                        Sender = "WMS",
                        Receiver = "PDA",
                        IsSuccess = 1, //是否下发成功 0失败 1成功
                        SendDate = DateTime.Now,  //发送时间
                        BackDate = DateTime.Now,  //返回时间
                        StartLocat = "",//起始位置
                        EndLocat = "力诺平库",//目标位置
                        PalletNo = model.PalletNo,//托盘码
                        IsSend = 0,//是否可再次下发
                        IsCancel = 0,//是否可取消
                        IsFinish = 0,//是否可完成
                        Type = "0",//任务类型 0 入库任务 1 出库任务  2 移库任务
                        Status = "2",//任务状态0:等待执行1正在执行2执行完成
                        OrderType = "0",//0 入库单 1 出库单  2 盘点单  3 移库单
                        Msg = "力诺平库的回库任务",
                    };
                    Db.Insertable(exTask).ExecuteCommand();
                    #endregion
                }
                storageLocat.Status = "1";//状态已使用
                storageLocat.UpdateTime = serverTime; //修改时间
                storageLocat.UpdateUser = model.CreateUser; //修改人
                //修改储位信息
                Db.Updateable(storageLocat).ExecuteCommand();
                new OperationASNServer().AddLogOperationAsn("PDA模块", "平库入库", model.PalletNo, "完成", $"在PDA上完成单据号为:{model.ASNNo}的托盘码为:{model.PalletNo}的平库入库操作", (int)model.CreateUser);
                Db.CommitTran();
            }
            catch (Exception ex)
            {
                Db.RollbackTran();
                throw ex;
            }
        }
        #endregion
    }
}
Wms/WMS.Entity/DataEntity/DataStockDetail.cs
@@ -79,7 +79,7 @@
        /// Default:
        /// Nullable:True
        /// </summary>           
        public int? InspectQty { get; set; }
        public decimal? InspectQty { get; set; }
        /// <summary>
        /// Desc:入库单号
Wms/WMS.IBLL/IPdaServer/IPdaAsnServer.cs
@@ -66,5 +66,8 @@
        //根据单据号获取单据明细列表
        List<ArrivalNoticeDetailDto> GetBindArrivalNoticeDetails(ArrivalNoticeVm model);
        //平库确认入库
        void ConfirmInStock(PalletBindVm model);
    }
}
Wms/Wms/Controllers/PdaAsnController.cs
@@ -508,5 +508,38 @@
            }
        }
        #endregion
        #region 平库入库
        /// <summary>
        /// 平库确认入库
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult ConfirmInStock(PalletBindVm model)
        {
            try
            {
                var claimsIdentity = this.User.Identity as ClaimsIdentity;
                if (claimsIdentity == null)
                {
                    throw new Exception("未获取到用户信息");
                }
                string UserId = claimsIdentity.FindFirst(ClaimTypes.Name)?.Value;
                if (string.IsNullOrWhiteSpace(UserId))
                {
                    throw new Exception("未获取到用户信息");
                }
                model.CreateUser = int.Parse(UserId);
                _PdaAsnSvc.ConfirmInStock(model);
                return Ok(new { code = 0, msg = "入库成功!" });
            }
            catch (Exception e)
            {
                return Ok(new { code = 1, msg = e.Message });
            }
        }
        #endregion
    }
}