zjh
4 天以前 72594e721deaa9f1485836923184c048cafe8270
采购退货单支持无源单退
已修改2个文件
180 ■■■■■ 文件已修改
StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs 179 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardPda/MES.Service/service/Warehouse/WomdaaManager.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
StandardPda/MES.Service/service/Warehouse/MesInvItemOutsManager.cs
@@ -112,10 +112,10 @@
                        && s.Id == Convert.ToInt32(from.MesNo)
            ).First();
        if (mesInvItemIns == null)
        {
            throw new NotImplementedException("采购入库不存在");
        }
        //if (mesInvItemIns == null)
        //{
        //    throw new NotImplementedException("采购入库不存在");
        //}
        var mesDepots = Db.Queryable<MesDepots>()
            .Where(s => s.DepotId == Decimal.Parse(from.DepotId)).First();
@@ -187,15 +187,15 @@
        foreach (var itemOutList in items)
        {
            // 检查必要字段是否为空
            if (string.IsNullOrEmpty(itemOutList.SrcDocNo))
            {
                throw new NotImplementedException("采购订单号不能为空");
            }
            //if (string.IsNullOrEmpty(itemOutList.SrcDocNo))
            //{
            //    throw new NotImplementedException("采购订单号不能为空");
            //}
            if (string.IsNullOrEmpty(itemOutList.SrcDocLineNo))
            {
                throw new NotImplementedException("采购订单行号不能为空");
            }
            //if (string.IsNullOrEmpty(itemOutList.SrcDocLineNo))
            //{
            //    throw new NotImplementedException("采购订单行号不能为空");
            //}
            //if (string.IsNullOrEmpty(itemOutList.AsnLineNo))
            //{
@@ -212,10 +212,10 @@
                            && s.OrderLineId == itemOutList.SrcDocLineNo)
                .First();
            if (mesRohInData == null)
            {
                throw new NotImplementedException("采购订单不存在");
            }
            //if (mesRohInData == null)
            //{
            //    throw new NotImplementedException("采购订单不存在");
            //}
            //var deliveryDetail = Db.Queryable<DeliveryDetail>()
            //    .Where(a =>  Int32.Parse(a.ZzitemId) ==
@@ -248,54 +248,113 @@
                                                  "]物料不存在,请同步给MES");
            }
            var mesInvItemInCItems = Db.Queryable<MesInvItemInCItems>()
                .Where(s => s.ItemInId == mesInvItemIns.Id
                            && s.ItemNo == mesItems.ItemNo
                            && s.Ebeln == itemOutList.SrcDocNo
                            && s.EbelnLineNo ==
                            Decimal.Parse(itemOutList.SrcDocLineNo)
                            && s.SuppNo == mesSupplier.SuppNo
                            ).First();
            if (mesInvItemInCItems == null)
            if (itemOutList.SrcDocNo!=null&& itemOutList.SrcDocNo!="")
            {
                throw new NotImplementedException("没有对应的入库明细");
                var mesInvItemInCItems = Db.Queryable<MesInvItemInCItems>()
              .Where(s => s.ItemInId == mesInvItemIns.Id
                          && s.ItemNo == mesItems.ItemNo
                          && s.Ebeln == itemOutList.SrcDocNo
                          && s.EbelnLineNo ==
                          Decimal.Parse(itemOutList.SrcDocLineNo)
                          && s.SuppNo == mesSupplier.SuppNo
                          ).First();
                if (mesInvItemInCItems == null)
                {
                    throw new NotImplementedException("没有对应的入库明细");
                }
                // 确保CbillNo不为空
                if (string.IsNullOrEmpty(mesInvItemIns.CbillNo))
                {
                    throw new NotImplementedException("入库单关联的采购单号不能为空");
                }
                mesInvItemOutItems.Add(new MesInvItemOutItems
                {
                    ItemOutId = nextSequenceValue,
                    ItemNo = mesItems.ItemNo,
                    Quantity = Decimal.Parse(itemOutList.qty),
                    CreateBy = "PL017",
                    CreateDate = DateTime.Now,
                    Factory = "1000",
                    Company = "1000",
                    DepotCode = mesDepots.DepotCode,
                    WorkNo = itemOutList.SrcDocNo, // 确保WorkNo有值
                    WorkLine =
                        Decimal.Parse(itemOutList.SrcDocLineNo), // 确保WorkLine有值
                    EbelnK3id = Decimal.Parse(mesRohInData.ErpId),
                    LineK3id = Decimal.Parse(mesRohInData.EbelnK3id),
                    FType = 0,
                    Status = 0,
                    PbillNo = mesInvItemIns.CbillNo, // 确保PbillNo有值
                    RkNo = from.MesNo, // 确保RkNo有值
                    RkLine = mesInvItemInCItems.Id, // 确保RkLine有值
                    RkQty = mesInvItemInCItems.Quantity,
                    TlQty = 0,
                    ItemId = Decimal.Parse(itemIdLinkU9.MesId), // 确保ItemId有值
                    SqNo = itemOutList.SqNo, // 确保ItemId有值
                                             //ZzitemId = itemOutList.AsnLineNo, // 确保ItemId有值
                                             // Unit = item.Unit,
                });
            }
            // 确保CbillNo不为空
            if (string.IsNullOrEmpty(mesInvItemIns.CbillNo))
            else
            {
                throw new NotImplementedException("入库单关联的采购单号不能为空");
              //  var mesInvItemInCItems = Db.Queryable<MesInvItemInCItems>()
              //.Where(s => s.ItemInId == mesInvItemIns.Id
              //            && s.ItemNo == mesItems.ItemNo
              //            && s.Ebeln == itemOutList.SrcDocNo
              //            && s.EbelnLineNo ==
              //            Decimal.Parse(itemOutList.SrcDocLineNo)
              //            && s.SuppNo == mesSupplier.SuppNo
              //            ).First();
              //  if (mesInvItemInCItems == null)
              //  {
              //      throw new NotImplementedException("没有对应的入库明细");
              //  }
                //// 确保CbillNo不为空
                //if (string.IsNullOrEmpty(mesInvItemIns.CbillNo))
                //{
                //    throw new NotImplementedException("入库单关联的采购单号不能为空");
                //}
                mesInvItemOutItems.Add(new MesInvItemOutItems
                {
                    ItemOutId = nextSequenceValue,
                    ItemNo = mesItems.ItemNo,
                    Quantity = Decimal.Parse(itemOutList.qty),
                    CreateBy = "PL017",
                    CreateDate = DateTime.Now,
                    Factory = "1000",
                    Company = "1000",
                    DepotCode = mesDepots.DepotCode,
                    WorkNo = itemOutList.SrcDocNo, // 确保WorkNo有值
                    WorkLine =
                        Decimal.Parse(itemOutList.SrcDocLineNo), // 确保WorkLine有值
                    //EbelnK3id = Decimal.Parse(mesRohInData.ErpId),
                    //LineK3id = Decimal.Parse(mesRohInData.EbelnK3id),
                    FType = 0,
                    Status = 0,
                    //PbillNo = mesInvItemIns.CbillNo, // 确保PbillNo有值
                    RkNo = from.MesNo, // 确保RkNo有值
                    RkLine = null, // 确保RkLine有值
                    RkQty = null,
                    TlQty = 0,
                    ItemId = Decimal.Parse(itemIdLinkU9.MesId), // 确保ItemId有值
                    SqNo = itemOutList.SqNo, // 确保ItemId有值
                                             //ZzitemId = itemOutList.AsnLineNo, // 确保ItemId有值
                                             // Unit = item.Unit,
                });
            }
            mesInvItemOutItems.Add(new MesInvItemOutItems
            {
                ItemOutId = nextSequenceValue,
                ItemNo = mesItems.ItemNo,
                Quantity = Decimal.Parse(itemOutList.qty),
                CreateBy = "PL017",
                CreateDate = DateTime.Now,
                Factory = "1000",
                Company = "1000",
                DepotCode = mesDepots.DepotCode,
                WorkNo = itemOutList.SrcDocNo, // 确保WorkNo有值
                WorkLine =
                    Decimal.Parse(itemOutList.SrcDocLineNo), // 确保WorkLine有值
                EbelnK3id = Decimal.Parse(mesRohInData.ErpId),
                LineK3id = Decimal.Parse(mesRohInData.EbelnK3id),
                FType = 0,
                Status = 0,
                PbillNo = mesInvItemIns.CbillNo, // 确保PbillNo有值
                RkNo = from.MesNo, // 确保RkNo有值
                RkLine = mesInvItemInCItems.Id, // 确保RkLine有值
                RkQty = mesInvItemInCItems.Quantity,
                TlQty = 0,
                ItemId = Decimal.Parse(itemIdLinkU9.MesId), // 确保ItemId有值
                SqNo = itemOutList.SqNo, // 确保ItemId有值
                //ZzitemId = itemOutList.AsnLineNo, // 确保ItemId有值
                // Unit = item.Unit,
            });
        }
        var outItemCommand = Db.Insertable(mesInvItemOutItems)
StandardPda/MES.Service/service/Warehouse/WomdaaManager.cs
@@ -417,6 +417,7 @@
                // 解绑
                else if (mesPalletBinding.Type.ToUpper() == "F")
                {
                    // 解绑前,检查该栈板码是否已经在MES入库
                    string sql1 = $"SELECT COUNT(*) COUNT FROM MES_PALLET_BINDING WHERE STACKCODE = '{mesPalletBinding.StackCode}' and IS_INBOUND=1";
                    DataTable data = sqlHelper.ExecuteQuery(sql1);