| | |
| | | && 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(); |
| | |
| | | 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)) |
| | | //{ |
| | |
| | | && 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) == |
| | |
| | | "]物料不存在,请同步给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) |