private static void AddBackflushInput(OrderMaster orderMaster, OrderDetail orderDetail, List<BackflushInput> backflushInputList, OrderBomDetail orderBomDetail, OrderDetailInput orderDetailInput, ReceiptDetail receiptDetail, decimal backFlushInputQty) { BackflushInput backFlushInput = new BackflushInput(); backFlushInput.ProductLine = orderMaster.Flow; backFlushInput.ProductLineFacility = orderMaster.ProductLineFacility; backFlushInput.CurrentProductLine = orderMaster.CurrentFlowMaster; backFlushInput.OrderNo = orderMaster.OrderNo; backFlushInput.OrderType = orderMaster.Type; backFlushInput.OrderSubType = orderMaster.SubType; backFlushInput.OrderDetailId = orderDetail.Id; backFlushInput.OrderDetailSequence = orderDetail.Sequence; backFlushInput.OrderBomDetail = orderBomDetail; backFlushInput.ReceiptNo = receiptDetail.ReceiptNo; backFlushInput.ReceiptDetailId = receiptDetail.Id; backFlushInput.ReceiptDetailSequence = receiptDetail.Sequence; backFlushInput.FGItem = orderDetail.Item; backFlushInput.Item = orderBomDetail.Item; backFlushInput.ItemDescription = orderBomDetail.ItemDescription; backFlushInput.ReferenceItemCode = orderBomDetail.ReferenceItemCode; backFlushInput.Uom = orderBomDetail.Uom; backFlushInput.BaseUom = orderBomDetail.BaseUom; backFlushInput.UnitQty = orderBomDetail.UnitQty; //基本单位转换率 = 订单单位/库存单位,转换为库存单位消耗 = 单位用量(订单单位) / 基本单位转换率 backFlushInput.TraceCode = orderDetailInput.TraceCode; //backFlushInput.QualityType = CodeMaster.QualityType.Qualified; backFlushInput.FGQualityType = orderDetailInput.QualityType; //收货成品的质量状态 //backFlushInput.HuId = orderDetailInput.HuId; //backFlushInput.LotNo = orderDetailInput.LotNo; backFlushInput.Qty = backFlushInputQty; backFlushInput.ReceivedQty = receiptDetail.ReceivedQty; if (orderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.GoodsReceive) { #region 按比例回冲 //backFlushInput.ProductLineLocationDetailList = productLineLocationDetailList.Where(p => p.Item == orderBomDetail.Item).ToList(); backFlushInput.Operation = orderBomDetail.Operation; backFlushInput.OpReference = orderBomDetail.OpReference; #endregion } backflushInputList.Add(backFlushInput); }
private List<BackflushInput> GetProductLineLocationDetailInOrder(OrderMaster orderMaster, IList<OrderDetail> nonZeroOrderDetailList, FlowMaster productLine) { var backflushInputList = new List<BackflushInput>(); #region 查询冲投料至工单的物料 string selectProductLineLocationDetailInOrderStatement = "from ProductLineLocationDetail where OrderNo = ?"; IList<object> selectProductLineLocationDetailInOrderPara = new List<object>(); selectProductLineLocationDetailInOrderPara.Add(orderMaster.OrderNo); #region 判断是否有追溯码 foreach (OrderDetail orderDetail in nonZeroOrderDetailList) { foreach (OrderDetailInput orderDetailInput in orderDetail.OrderDetailInputs) { if (!string.IsNullOrWhiteSpace(orderDetailInput.TraceCode)) { if (selectProductLineLocationDetailInOrderPara.Count == 1) { selectProductLineLocationDetailInOrderStatement += " and TraceCode in (?"; } else { selectProductLineLocationDetailInOrderStatement += ",?"; } selectProductLineLocationDetailInOrderPara.Add(orderDetailInput.TraceCode); } } } if (selectProductLineLocationDetailInOrderPara.Count > 1) { selectProductLineLocationDetailInOrderStatement += ")"; } #endregion IList<ProductLineLocationDetail> productLineLocationDetailInOrderList = this.genericMgr.FindAll<ProductLineLocationDetail>(selectProductLineLocationDetailInOrderStatement, selectProductLineLocationDetailInOrderPara.ToArray()); #endregion #region 投料至工单的在制品全部要回冲 var groupedProductLineLocationDetailList = from locDet in productLineLocationDetailInOrderList group locDet by new { OrderDetailId = locDet.OrderDetailId, Item = locDet.Item, } into gj select new { OrderDetailId = gj.Key.OrderDetailId, Item = gj.Key.Item, ProductLineLocationDetailList = gj.ToList() }; IList<Item> itemList = this.itemMgr.GetItems(groupedProductLineLocationDetailList.Select(d => d.Item).Distinct().ToList()); foreach (var groupedProductLineLocationDetail in groupedProductLineLocationDetailList) { //OrderDetail orderDetail = orderDetailList.Where(o => o.Id == groupedProductLineLocationDetail.OrderDetailId).Single(); //OrderDetail orderDetail = nonZeroOrderDetailList[0]; //OrderDetailInput orderDetailInput = orderDetail.OrderDetailInputs[0]; foreach (var orderDetail in nonZeroOrderDetailList) { foreach (var orderDetailInput in orderDetail.OrderDetailInputs) { foreach (var receiptDetail in orderDetailInput.ReceiptDetails) { Item item = itemList.Where(i => i.Code == groupedProductLineLocationDetail.Item).Single(); BackflushInput backFlushInput = new BackflushInput(); backFlushInput.ProductLine = orderMaster.Flow; backFlushInput.ProductLineFacility = orderMaster.ProductLineFacility; backFlushInput.CurrentProductLine = productLine; backFlushInput.OrderNo = orderMaster.OrderNo; backFlushInput.OrderType = orderMaster.Type; backFlushInput.OrderSubType = orderMaster.SubType; backFlushInput.OrderDetailId = orderDetail.Id; backFlushInput.OrderDetailSequence = orderDetail.Sequence; backFlushInput.ReceiptNo = receiptDetail.ReceiptNo; backFlushInput.ReceiptDetailId = receiptDetail.Id; backFlushInput.ReceiptDetailSequence = receiptDetail.Sequence; //backFlushInput.ReceiptDetailSequence = orderDetailInput.ReceiptDetail.Sequence; backFlushInput.FGItem = orderDetail.Item; backFlushInput.Item = item.Code; backFlushInput.ItemDescription = item.Description; backFlushInput.ReferenceItemCode = item.ReferenceCode; backFlushInput.Uom = item.Uom; backFlushInput.BaseUom = item.Uom; backFlushInput.UnitQty = 1; backFlushInput.TraceCode = orderDetailInput.TraceCode; //backFlushInput.QualityType = CodeMaster.QualityType.Qualified; backFlushInput.FGQualityType = orderDetailInput.QualityType; backFlushInput.Qty = groupedProductLineLocationDetail.ProductLineLocationDetailList.Sum(g => g.RemainBackFlushQty); backFlushInput.ProductLineLocationDetailList = groupedProductLineLocationDetail.ProductLineLocationDetailList; backflushInputList.Add(backFlushInput); } } } } #endregion return backflushInputList; }
private IList<InventoryTransaction> BackflushProductLineLocationDetail(BackflushInput backflushInput, DateTime effectiveDate) { IList<InventoryTransaction> inventoryTransactionList = new List<InventoryTransaction>(); if (backflushInput.ProductLineLocationDetailList != null && backflushInput.ProductLineLocationDetailList.Count > 0) { decimal remainQty = backflushInput.Qty * backflushInput.UnitQty; foreach (ProductLineLocationDetail productLineLocationDetail in backflushInput.ProductLineLocationDetailList) { if (productLineLocationDetail.RemainBackFlushQty == 0) { continue; } if (remainQty <= 0) { break; } SettleBillTransaction billTransaction = null; if (productLineLocationDetail.IsConsignment && productLineLocationDetail.PlanBill.HasValue) { var planBill = this.genericMgr.FindById<PlanBill>(productLineLocationDetail.PlanBill.Value); planBill.CurrentLocation = productLineLocationDetail.LocationFrom; billTransaction = this.billMgr.SettleBill(planBill, effectiveDate); } InventoryTransaction inventoryTransaction = new InventoryTransaction(); inventoryTransaction.LocationLotDetailId = productLineLocationDetail.Id; inventoryTransaction.Location = productLineLocationDetail.ProductLine; inventoryTransaction.Bin = productLineLocationDetail.ProductLineFacility; inventoryTransaction.Item = productLineLocationDetail.Item; inventoryTransaction.HuId = productLineLocationDetail.HuId; inventoryTransaction.LotNo = productLineLocationDetail.LotNo; if (remainQty >= productLineLocationDetail.RemainBackFlushQty) { remainQty -= productLineLocationDetail.RemainBackFlushQty; inventoryTransaction.Qty = -productLineLocationDetail.RemainBackFlushQty; productLineLocationDetail.BackFlushQty += productLineLocationDetail.RemainBackFlushQty; productLineLocationDetail.IsClose = true; } else { inventoryTransaction.Qty = -remainQty; productLineLocationDetail.BackFlushQty += remainQty; remainQty = 0; if (productLineLocationDetail.RemainBackFlushQty == 0) { productLineLocationDetail.IsClose = true; } } this.genericMgr.Update(productLineLocationDetail); inventoryTransaction.IsCreatePlanBill = false; inventoryTransaction.IsConsignment = false; inventoryTransaction.PlanBill = productLineLocationDetail.PlanBill; inventoryTransaction.PlanBillQty = 0; if (billTransaction != null) { inventoryTransaction.ActingBill = billTransaction.ActingBill; inventoryTransaction.ActingBillQty = billTransaction.BillQty; inventoryTransaction.BillTransactionId = billTransaction.Id; } inventoryTransaction.QualityType = productLineLocationDetail.QualityType; inventoryTransaction.IsFreeze = false; inventoryTransaction.IsATP = productLineLocationDetail.QualityType == com.Sconit.CodeMaster.QualityType.Qualified; inventoryTransaction.OccupyType = CodeMaster.OccupyType.None; inventoryTransaction.OccupyReferenceNo = null; inventoryTransaction.Operation = productLineLocationDetail.Operation; inventoryTransaction.OpReference = productLineLocationDetail.OpReference; inventoryTransaction.OrgLocation = productLineLocationDetail.LocationFrom; inventoryTransaction.ReserveNo = productLineLocationDetail.ReserveNo; inventoryTransaction.ReserveLine = productLineLocationDetail.ReserveLine; inventoryTransaction.AUFNR = productLineLocationDetail.AUFNR; inventoryTransaction.BWART = productLineLocationDetail.BWART; inventoryTransaction.ICHARG = productLineLocationDetail.ICHARG; inventoryTransaction.NotReport = productLineLocationDetail.NotReport; inventoryTransactionList.Add(inventoryTransaction); } } return inventoryTransactionList; }
private void RecordLocationTransaction(BackflushInput backflushInput, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isVoid) { if (inventoryTransactionList != null && inventoryTransactionList.Count > 0) { var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { QualityType = trans.QualityType, HuId = trans.HuId, LotNo = trans.LotNo, Location = trans.Location, ActingBill = trans.ActingBill, } into result select new { QualityType = result.Key.QualityType, HuId = result.Key.HuId, LotNo = result.Key.LotNo, Location = result.Key.Location, Qty = result.Sum(g => g.Qty), ActingBill = result.Key.ActingBill, ActingBillQty = result.Sum(g => g.ActingBillQty), TransList = result.ToList() }; DateTime dateTimeNow = DateTime.Now; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = backflushInput.OrderNo; locationTransaction.OrderType = backflushInput.OrderType; locationTransaction.OrderSubType = backflushInput.OrderSubType; locationTransaction.OrderDetailSequence = backflushInput.OrderDetailSequence; locationTransaction.OrderDetailId = backflushInput.OrderDetailId; if (backflushInput.OrderBomDetail != null) { locationTransaction.OrderBomDetailId = backflushInput.OrderBomDetail.Id; locationTransaction.OrderBomDetailSequence = backflushInput.OrderBomDetail.Sequence; } //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = locationTransaction.ReceiptNo = backflushInput.ReceiptNo; locationTransaction.ReceiptDetailId = backflushInput.ReceiptDetailId; locationTransaction.ReceiptDetailSequence = backflushInput.ReceiptDetailSequence; //locationTransaction.SequenceNo = locationTransaction.TraceCode = backflushInput.TraceCode; locationTransaction.Item = backflushInput.Item; locationTransaction.Uom = backflushInput.Uom; locationTransaction.BaseUom = backflushInput.BaseUom; locationTransaction.Qty = groupedInventoryTransaction.Qty / backflushInput.UnitQty; locationTransaction.UnitQty = backflushInput.UnitQty; locationTransaction.IsConsignment = false; //locationTransaction.PlanBill = locationTransaction.PlanBillQty = 0; if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / backflushInput.UnitQty; locationTransaction.QualityType = groupedInventoryTransaction.QualityType; locationTransaction.HuId = groupedInventoryTransaction.HuId; locationTransaction.LotNo = groupedInventoryTransaction.LotNo; if (!isVoid) { if (backflushInput.OrderType == CodeMaster.OrderType.Production) { if (backflushInput.OrderSubType == CodeMaster.OrderSubType.Return) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_WO_RTN; } else { locationTransaction.TransactionType = backflushInput.CurrentProductLine.Code != groupedInventoryTransaction.Location ? //如果回冲库位和生产线代码不一致,一定是回冲线旁的物料 com.Sconit.CodeMaster.TransactionType.ISS_WO : com.Sconit.CodeMaster.TransactionType.ISS_WO_BF; } } else if (backflushInput.OrderType == CodeMaster.OrderType.SubContract) { if (backflushInput.OrderSubType == CodeMaster.OrderSubType.Return) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_SWO_RTN; } else { locationTransaction.TransactionType = backflushInput.CurrentProductLine.Code != groupedInventoryTransaction.Location ? //如果回冲库位和生产线代码不一致,一定是回冲线旁的物料 com.Sconit.CodeMaster.TransactionType.ISS_SWO : com.Sconit.CodeMaster.TransactionType.ISS_SWO_BF; } } } else { if (backflushInput.OrderSubType == CodeMaster.OrderSubType.Return) { if (backflushInput.OrderType == CodeMaster.OrderType.Production) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_WO_RTN_VOID; } else if (backflushInput.OrderType == CodeMaster.OrderType.SubContract) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_SWO_RTN_VOID; } } else { if (backflushInput.OrderType == CodeMaster.OrderType.Production) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_WO_VOID; } else if (backflushInput.OrderType == CodeMaster.OrderType.SubContract) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_SWO_VOID; } } } locationTransaction.IOType = CodeMaster.TransactionIOType.Out; locationTransaction.PartyFrom = backflushInput.CurrentProductLine.Code != groupedInventoryTransaction.Location ? //如果回冲库位和生产线代码不一致,一定是回冲线旁的物料 this.genericMgr.FindById<Location>(groupedInventoryTransaction.Location).Region : backflushInput.CurrentProductLine.PartyFrom; locationTransaction.PartyTo = backflushInput.CurrentProductLine.PartyTo; locationTransaction.LocationFrom = groupedInventoryTransaction.Location; //记录投料入的生产线 //locationTransaction.LocationTo = locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; locationTransaction.IpNo = backflushInput.IpNo; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, groupedInventoryTransaction.TransList); } } }
public void BackFlushVanOrderOnline(int bomId, int version) { User user = SecurityContextHolder.Get(); log.DebugFormat("开始反冲CUST_OrderBomDetOnLine({0})。", bomId); int result = this.genericMgr.UpdateWithNativeQuery("update CUST_OrderBomDetOnLine set set Status = 2, LastModifyDate= GETDATE(),LastModifyUser = "******",LastModifyUserNm = '" + user.FullName + "', Version = Version + 1 where Id = " + bomId.ToString() + " and Version = " + version.ToString()); if (result == 1) { IList<object[]> resultList = this.genericMgr.FindAllWithNativeSql<object[]>(@"select bom.FGItem, bom.Item, bom.ItemDesc, bom.Uom, bom.Location, bom.ProdLine, sum(bom.Qty) as OrderQty from CUST_OrderBomDetOnLine as bom inner join SAP_ProdOpBackflush as bf on bom.AUFNR = bf.AUFNR and bf.PLNFL = bom.PLNFL and bf.VORNR = bom.VORNR and bf.AUFPL = bom.AUFPL where bom.Id = " + bomId.ToString() + @" and bf.ProdLine is null and (bf.Status = 0 or (bf.Status = 1 and bf.ErrorCount < 10)) group by bom.FGItem, bom.Item, bom.ItemDesc, bom.Uom, bom.Location, bom.ProdLine"); if (resultList != null && resultList.Count > 0) { DateTime dateTimeNow = DateTime.Now; IList<FlowMaster> prodLineList = this.genericMgr.FindAll<FlowMaster>("from FlowMaster where ProdLineType in (?,?,?,?,?)", new object[] { CodeMaster.ProdLineType.Cab, CodeMaster.ProdLineType.Chassis, CodeMaster.ProdLineType.Assembly, CodeMaster.ProdLineType.Special, CodeMaster.ProdLineType.Check }); IList<BackflushInput> backflushInputList = new List<BackflushInput>(); foreach (object[] rt in resultList) { BackflushInput backflushInput = new BackflushInput(); backflushInput.OrderType = CodeMaster.OrderType.Production; backflushInput.OrderSubType = CodeMaster.OrderSubType.Normal; backflushInput.FGItem = (string)rt[0]; backflushInput.Item = (string)rt[1]; backflushInput.ItemDescription = (string)rt[2]; backflushInput.Uom = (string)rt[3]; backflushInput.BaseUom = (string)rt[3]; backflushInput.UnitQty = 1; backflushInput.Location = (string)rt[4]; backflushInput.ProductLine = (string)rt[5]; backflushInput.Qty = (decimal)rt[6]; backflushInput.CurrentProductLine = prodLineList.Where(pl => pl.Code == (string)rt[5]).Single(); backflushInput.EffectiveDate = dateTimeNow; backflushInputList.Add(backflushInput); } log.DebugFormat("CUST_OrderBomDetOnLine({0})待反冲物料汇总条数{0},开始反冲物料。", backflushInputList.Count()); locationDetailMgr.BackflushVanProductMaterial(backflushInputList); log.DebugFormat("反冲CUST_OrderBomDetOnLine({0})结束。", bomId); } } else { log.WarnFormat("CUST_OrderBomDetOnLine({0})已经被更新。", bomId); } }
public void BackFlushVanOrder(string updateSuccessStatement, string selectBomStatement) { this.genericMgr.UpdateWithNativeQuery(updateSuccessStatement); IList<object[]> resultList = this.genericMgr.FindAllWithNativeSql<object[]>(selectBomStatement); if (resultList != null && resultList.Count > 0) { DateTime dateTimeNow = DateTime.Now; IList<FlowMaster> prodLineList = this.genericMgr.FindAll<FlowMaster>("from FlowMaster where ProdLineType in (?,?,?,?,?)", new object[] { CodeMaster.ProdLineType.Cab, CodeMaster.ProdLineType.Chassis, CodeMaster.ProdLineType.Assembly, CodeMaster.ProdLineType.Special, CodeMaster.ProdLineType.Check }); IList<BackflushInput> backflushInputList = new List<BackflushInput>(); foreach (object[] rt in resultList) { BackflushInput backflushInput = new BackflushInput(); backflushInput.OrderType = CodeMaster.OrderType.Production; backflushInput.OrderSubType = CodeMaster.OrderSubType.Normal; backflushInput.FGItem = (string)rt[0]; backflushInput.Item = (string)rt[1]; backflushInput.ItemDescription = (string)rt[2]; backflushInput.Uom = (string)rt[3]; backflushInput.BaseUom = (string)rt[3]; backflushInput.UnitQty = 1; backflushInput.Location = (string)rt[4]; backflushInput.ProductLine = (string)rt[5]; backflushInput.Qty = (decimal)rt[6]; backflushInput.CurrentProductLine = prodLineList.Where(pl => pl.Code == (string)rt[5]).Single(); backflushInput.EffectiveDate = dateTimeNow; backflushInputList.Add(backflushInput); } log.DebugFormat("整车生产单待回冲物料汇总条数{0},开始回冲物料。", backflushInputList.Count()); locationDetailMgr.BackflushVanProductMaterial(backflushInputList); log.DebugFormat("整车生产单物料回冲完成。"); } this.genericMgr.FlushSession(); this.genericMgr.CleanSession(); }
public void BackFlushVanOrderByOp() { log.Debug("整车物料回冲开始。"); DataSet dataSet = this.sqlDao.GetDatasetBySql(@"select mstr.OrderNo, op.Op, det.Item into #tempOrderOp from ORD_OrderOp as op WITH(NOLOCK) inner join ORD_OrderMstr_4 as mstr WITH(NOLOCK) on op.OrderNo = mstr.OrderNo inner join ORD_OrderDet_4 as det WITH(NOLOCK) on mstr.OrderNo = det.OrderNo where op.ReportQty = 1 and op.BackflushQty = 0 and mstr.ProdLineType in (1, 2, 3, 4, 9) group by mstr.OrderNo, op.Op, det.Item select det.Item as FGItem, bom.Item, bom.ItemDesc, bom.Uom, bom.Location, mstr.Flow as ProdLine, sum(bom.OrderQty) as OrderQty from ORD_OrderBomDet as bom WITH(NOLOCK) inner join #tempOrderOp as op on bom.OrderNo = op.OrderNo and bom.Op = op.Op inner join ORD_OrderMstr_4 as mstr WITH(NOLOCK) on bom.OrderNo = mstr.OrderNo inner join ORD_OrderDet_4 as det WITH(NOLOCK) on mstr.OrderNo = det.OrderNo group by det.Item, bom.Item, bom.ItemDesc, bom.Uom, bom.Location, mstr.Flow select OrderNo, Op, Item from #tempOrderOp ", null); if (dataSet != null && dataSet.Tables != null) { DateTime dateTimeNow = DateTime.Now; IList<FlowMaster> prodLineList = this.genericMgr.FindAll<FlowMaster>("from FlowMaster where ProdLineType in (?,?,?,?,?)", new object[] { CodeMaster.ProdLineType.Cab, CodeMaster.ProdLineType.Chassis, CodeMaster.ProdLineType.Assembly, CodeMaster.ProdLineType.Special, CodeMaster.ProdLineType.Check }); DataRowCollection orderBomDataRow = dataSet.Tables[0].Rows; IList<BackflushInput> backflushInputList = new List<BackflushInput>(); foreach (DataRow dr in orderBomDataRow) { BackflushInput backflushInput = new BackflushInput(); backflushInput.OrderType = CodeMaster.OrderType.Production; backflushInput.OrderSubType = CodeMaster.OrderSubType.Normal; backflushInput.FGItem = (string)dr[0]; backflushInput.Item = (string)dr[1]; backflushInput.ItemDescription = (string)dr[2]; backflushInput.Uom = (string)dr[3]; backflushInput.BaseUom = (string)dr[3]; backflushInput.UnitQty = 1; backflushInput.Location = (string)dr[4]; backflushInput.ProductLine = (string)dr[5]; backflushInput.Qty = (decimal)dr[6]; backflushInput.CurrentProductLine = prodLineList.Where(pl => pl.Code == (string)dr[5]).Single(); backflushInput.EffectiveDate = dateTimeNow; backflushInputList.Add(backflushInput); } DataRowCollection orderOpDataRow = dataSet.Tables[1].Rows; IList<object[]> orderOpList = new List<object[]>(); foreach (DataRow dr in orderOpDataRow) { object[] orderOp = new object[3]; orderOp[0] = dr[0]; orderOp[1] = dr[1]; orderOp[2] = dr[2]; orderOpList.Add(orderOp); } IList<string> fgItemList = (from op in orderOpList group op by (string)op[2] into result select result.Key).ToList(); foreach (string fgItem in fgItemList) { try { backflushVanOrderMgr.BackflushOp(orderOpList.Where(op => (string)op[2] == fgItem).ToList(), backflushInputList.Where(bom => bom.FGItem == fgItem).ToList()); } catch (Exception) { } //睡30秒 Thread.Sleep(30000); } } log.Debug("整车物料回冲结束。"); }
public void BackFlushVanOrder() { lock (BackFlushVanOrderLock) { log.Debug("整车物料回冲开始。"); User user = SecurityContextHolder.Get(); DateTime dateTimeNow = DateTime.Now; StringBuilder sql = new StringBuilder(); log.DebugFormat("开始更新生产单状态和工序回冲数量。"); DataSet dataSet = this.sqlDao.GetDatasetBySql(@"select OrderNo into #tempOrderNo from ORD_OrderMstr_4 WITH(NOLOCK) where ProdLineType in (1,2,3,4,9) and Status = 3 select det.Item as FGItem, bom.Item, bom.ItemDesc, bom.Uom, bom.Location, mstr.Flow as ProdLine, sum(bom.OrderQty) as OrderQty--, mstr.CompleteDate from ORD_OrderBomDet as bom WITH(NOLOCK) inner join ORD_OrderDet_4 as det WITH(NOLOCK) on bom.OrderDetId = det.Id inner join ORD_OrderMstr_4 as mstr WITH(NOLOCK) on bom.OrderNo = mstr.OrderNo inner join #tempOrderNo as t on mstr.OrderNo = t.OrderNo group by det.Item, bom.Item, bom.ItemDesc, bom.Uom, bom.Location, mstr.Flow, mstr.Type--, mstr.CompleteDate select OrderNo from #tempOrderNo", null); DataRowCollection orderNoDataRow = dataSet.Tables[1].Rows; IList<string> orderNoList = new List<string>(); foreach (DataRow dr in orderNoDataRow) { sql.Append("update ORD_OrderMstr_4 set Status = 4, LastModifyDate='" + dateTimeNow.ToString("yyyy-MM-dd HH:ss:mm") + "',LastModifyUser = "******",LastModifyUserNm = '" + user.FullName + "',CloseDate='" + dateTimeNow.ToString("yyyy-MM-dd HH:ss:mm") + "',CloseUser = "******",CloseUserNm = '" + user.FullName + "',Version=Version + 1 where OrderNo = '" + (string)dr[0] + "';"); sql.Append("update ORD_OrderOp set LastModifyDate='" + dateTimeNow.ToString("yyyy-MM-dd HH:ss:mm") + "',LastModifyUser = "******",LastModifyUserNm = '" + user.FullName + "',BackflushQty = ReportQty,Version=Version + 1 where OrderNo = '" + (string)dr[0] + "';"); sql.Append("update ORD_OrderOpReport set LastModifyDate='" + dateTimeNow.ToString("yyyy-MM-dd HH:ss:mm") + "',LastModifyUser = "******",LastModifyUserNm = '" + user.FullName + "',BackflushQty = ReportQty,Version=Version + 1 where OrderNo = '" + (string)dr[0] + "';"); } this.genericMgr.UpdateWithNativeQuery(sql.ToString()); log.DebugFormat("更新生产单状态和工序回冲数量完成。"); if (dataSet != null && dataSet.Tables != null && dataSet.Tables[0].Rows.Count > 0) { IList<FlowMaster> prodLineList = this.genericMgr.FindAll<FlowMaster>("from FlowMaster where ProdLineType in (?,?,?,?,?)", new object[] { CodeMaster.ProdLineType.Cab, CodeMaster.ProdLineType.Chassis, CodeMaster.ProdLineType.Assembly, CodeMaster.ProdLineType.Special, CodeMaster.ProdLineType.Check }); DataRowCollection orderBomDataRow = dataSet.Tables[0].Rows; IList<BackflushInput> backflushInputList = new List<BackflushInput>(); foreach (DataRow dr in orderBomDataRow) { BackflushInput backflushInput = new BackflushInput(); backflushInput.OrderType = CodeMaster.OrderType.Production; backflushInput.OrderSubType = CodeMaster.OrderSubType.Normal; backflushInput.FGItem = (string)dr[0]; backflushInput.Item = (string)dr[1]; backflushInput.ItemDescription = (string)dr[2]; backflushInput.Uom = (string)dr[3]; backflushInput.BaseUom = (string)dr[3]; backflushInput.UnitQty = 1; backflushInput.Location = (string)dr[4]; backflushInput.ProductLine = (string)dr[5]; backflushInput.Qty = (decimal)dr[6]; backflushInput.CurrentProductLine = prodLineList.Where(pl => pl.Code == (string)dr[5]).Single(); backflushInput.EffectiveDate = dateTimeNow; backflushInputList.Add(backflushInput); } log.DebugFormat("整车生产单待回冲物料汇总条数{0},开始回冲物料。", backflushInputList.Count()); locationDetailMgr.BackflushVanProductMaterial(backflushInputList); log.DebugFormat("整车生产单物料回冲完成。"); } log.Debug("整车物料回冲结束。"); } }
public void BackflushProductOrder(IList<OrderDetail> orderDetailList, DateTime effectiveDate) { #region 判断是否全0收货 if (orderDetailList == null || orderDetailList.Count == 0) { throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveDetailIsEmpty); } IList<OrderDetail> nonZeroOrderDetailList = orderDetailList.Where(o => o.ReceiveQtyInput != 0 || o.ScrapQtyInput != 0).ToList(); if (nonZeroOrderDetailList.Count == 0) { throw new BusinessException(Resources.ORD.OrderMaster.Errors_ReceiveDetailIsEmpty); } if (nonZeroOrderDetailList.Count > 1) { throw new BusinessException("收货明细大于1。"); } #endregion #region 查询生产单和生产线 //不能跨生产单同时收货 string orderNo = nonZeroOrderDetailList.Select(o => o.OrderNo).Distinct().Single(); OrderMaster orderMaster = this.genericMgr.FindById<OrderMaster>(orderNo); FlowMaster productLine = this.genericMgr.FindById<FlowMaster>(orderMaster.Flow); #endregion #region 查询订单Bom string selectOrderBomDetailStatement = string.Empty; IList<object> selectOrderBomDetailPara = new List<object>(); foreach (OrderDetail orderDetail in nonZeroOrderDetailList) { if (selectOrderBomDetailStatement == string.Empty) { selectOrderBomDetailStatement = "from OrderBomDetail where OrderDetailId in(?"; } else { selectOrderBomDetailStatement += ",?"; } selectOrderBomDetailPara.Add(orderDetail.Id); } selectOrderBomDetailStatement += ")"; IList<OrderBomDetail> orderBomDetailList = this.genericMgr.FindAll<OrderBomDetail>(selectOrderBomDetailStatement, selectOrderBomDetailPara.ToArray()); #endregion #region 查询待回冲物料 #region 查询冲投料至工单的物料 string selectProductLineLocationDetailInOrderStatement = "from ProductLineLocationDetail where OrderNo = ?"; IList<object> selectProductLineLocationDetailInOrderPara = new List<object>(); selectProductLineLocationDetailInOrderPara.Add(orderNo); #region 判断是否有Van号 foreach (OrderDetail orderDetail in nonZeroOrderDetailList) { foreach (OrderDetailInput orderDetailInput in orderDetail.OrderDetailInputs) { if (!string.IsNullOrWhiteSpace(orderDetailInput.TraceCode)) { if (selectProductLineLocationDetailInOrderPara.Count == 1) { selectProductLineLocationDetailInOrderStatement += " and TraceCode in (?"; } else { selectProductLineLocationDetailInOrderStatement += ",?"; } selectProductLineLocationDetailInOrderPara.Add(orderDetailInput.TraceCode); } } } if (selectProductLineLocationDetailInOrderPara.Count > 1) { selectProductLineLocationDetailInOrderStatement += ")"; } #endregion IList<ProductLineLocationDetail> productLineLocationDetailInOrderList = this.genericMgr.FindAll<ProductLineLocationDetail>(selectProductLineLocationDetailInOrderStatement, selectProductLineLocationDetailInOrderPara.ToArray()); #endregion #region 查询冲投料至生产线的物料 string selectProductLineLocationDetailStatement = "from ProductLineLocationDetail where ProductLine = ? and OrderNo is null and Item in (select Item from OrderBomDetail where OrderNo = ?)"; IList<object> selectProductLineLocationDetailPara = new List<object>(); selectProductLineLocationDetailPara.Add(orderMaster.Flow); selectProductLineLocationDetailPara.Add(orderNo); if (!string.IsNullOrWhiteSpace(orderMaster.ProductLineFacility)) { selectProductLineLocationDetailStatement += " and ProductLineFacility = ?"; selectProductLineLocationDetailPara.Add(orderMaster.ProductLineFacility); } IList<ProductLineLocationDetail> productLineLocationDetailList = this.genericMgr.FindAll<ProductLineLocationDetail>(selectProductLineLocationDetailStatement, selectProductLineLocationDetailPara.ToArray()); #endregion IList<BackflushInput> backflushInputList = new List<BackflushInput>(); #region 根据OrderBomDetail生成收货回冲和加权平均的回冲记录 foreach (OrderBomDetail orderBomDetail in orderBomDetailList.Where(bomDet => bomDet.BackFlushMethod != CodeMaster.BackFlushMethod.BackFlushOrder)) { //OrderDetail orderDetail = nonZeroOrderDetailList.Where(o => o.Id == orderBomDetail.OrderDetailId).Single(); OrderDetail orderDetail = nonZeroOrderDetailList[0]; OrderDetailInput orderDetailInput = orderDetail.OrderDetailInputs[0]; BackflushInput backFlushInput = new BackflushInput(); backFlushInput.ProductLine = orderMaster.Flow; backFlushInput.ProductLineFacility = orderMaster.ProductLineFacility; backFlushInput.CurrentProductLine = productLine; backFlushInput.OrderNo = orderMaster.OrderNo; backFlushInput.OrderType = orderMaster.Type; backFlushInput.OrderSubType = orderMaster.SubType; backFlushInput.OrderDetailId = orderDetail.Id; backFlushInput.OrderDetailSequence = orderDetail.Sequence; backFlushInput.OrderBomDetail = orderBomDetail; backFlushInput.ReceiptNo = orderDetailInput.ReceiptDetail.ReceiptNo; backFlushInput.ReceiptDetailId = orderDetailInput.ReceiptDetail.Id; backFlushInput.ReceiptDetailSequence = orderDetailInput.ReceiptDetail.Sequence; backFlushInput.FGItem = orderDetail.Item; backFlushInput.Item = orderBomDetail.Item; backFlushInput.ItemDescription = orderBomDetail.ItemDescription; backFlushInput.ReferenceItemCode = orderBomDetail.ReferenceItemCode; backFlushInput.Uom = orderBomDetail.Uom; backFlushInput.BaseUom = orderBomDetail.BaseUom; backFlushInput.UnitQty = orderBomDetail.UnitQty; //基本单位转换率 = 订单单位/库存单位,转换为库存单位消耗 = 单位用量(订单单位) / 基本单位转换率 backFlushInput.TraceCode = orderDetailInput.TraceCode; //backFlushInput.QualityType = CodeMaster.QualityType.Qualified; backFlushInput.FGQualityType = orderDetailInput.QualityType; //收货成品的质量状态 if (orderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.GoodsReceive) { #region 按比例回冲 backFlushInput.ProductLineLocationDetailList = productLineLocationDetailList.Where(p => p.Item == orderBomDetail.Item).ToList(); backFlushInput.Qty = (orderDetailInput.ReceiveQty + orderDetailInput.ScrapQty) * orderBomDetail.BomUnitQty; backFlushInput.Operation = orderBomDetail.Operation; backFlushInput.OpReference = orderBomDetail.OpReference; #endregion } else if (orderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.WeightAverage) { #region 加权平均回冲 backFlushInput.Qty = (orderDetailInput.ReceiveQty + orderDetailInput.ScrapQty) * orderBomDetail.BomUnitQty; #endregion } backflushInputList.Add(backFlushInput); } #endregion #region 投料至工单的在制品全部要回冲 var groupedProductLineLocationDetailList = from locDet in productLineLocationDetailInOrderList group locDet by new { OrderDetailId = locDet.OrderDetailId, Item = locDet.Item, } into gj select new { OrderDetailId = gj.Key.OrderDetailId, Item = gj.Key.Item, ProductLineLocationDetailList = gj.ToList() }; IList<Item> itemList = this.itemMgr.GetItems(groupedProductLineLocationDetailList.Select(d => d.Item).Distinct().ToList()); foreach (var groupedProductLineLocationDetail in groupedProductLineLocationDetailList) { //OrderDetail orderDetail = orderDetailList.Where(o => o.Id == groupedProductLineLocationDetail.OrderDetailId).Single(); OrderDetail orderDetail = nonZeroOrderDetailList[0]; OrderDetailInput orderDetailInput = orderDetail.OrderDetailInputs[0]; Item item = itemList.Where(i => i.Code == groupedProductLineLocationDetail.Item).Single(); BackflushInput backFlushInput = new BackflushInput(); backFlushInput.ProductLine = orderMaster.Flow; backFlushInput.ProductLineFacility = orderMaster.ProductLineFacility; backFlushInput.CurrentProductLine = productLine; backFlushInput.OrderNo = orderMaster.OrderNo; backFlushInput.OrderType = orderMaster.Type; backFlushInput.OrderSubType = orderMaster.SubType; backFlushInput.OrderDetailId = orderDetail.Id; backFlushInput.OrderDetailSequence = orderDetail.Sequence; backFlushInput.ReceiptNo = orderDetailInput.ReceiptDetail.ReceiptNo; backFlushInput.ReceiptDetailId = orderDetailInput.ReceiptDetail.Id; backFlushInput.ReceiptDetailSequence = orderDetailInput.ReceiptDetail.Sequence; //backFlushInput.ReceiptDetailSequence = orderDetailInput.ReceiptDetail.Sequence; backFlushInput.FGItem = orderDetail.Item; backFlushInput.Item = item.Code; backFlushInput.ItemDescription = item.Description; backFlushInput.ReferenceItemCode = item.ReferenceCode; backFlushInput.Uom = item.Uom; backFlushInput.BaseUom = item.Uom; backFlushInput.UnitQty = 1; backFlushInput.TraceCode = orderDetailInput.TraceCode; //backFlushInput.QualityType = CodeMaster.QualityType.Qualified; backFlushInput.FGQualityType = orderDetailInput.QualityType; backFlushInput.Qty = groupedProductLineLocationDetail.ProductLineLocationDetailList.Sum(g => g.RemainBackFlushQty); backFlushInput.ProductLineLocationDetailList = groupedProductLineLocationDetail.ProductLineLocationDetailList; backflushInputList.Add(backFlushInput); } #endregion #endregion #region 记录工单投料明细/旧 //DateTime dateTimeNow = DateTime.Now; //User currentUser = SecurityContextHolder.Get(); //#region 汇总收货回冲投料明细 //IList<OrderBackflushDetail> orderBackflushDetailList = (from input in backflushInputList // where input.OrderBomDetail != null && input.OrderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.GoodsReceive // select new OrderBackflushDetail // { // OrderNo = input.OrderNo, // OrderDetailId = input.OrderDetailId, // OrderDetailSequence = input.OrderDetailSequence, // OrderBomDetailId = input.OrderBomDetail.Id, // OrderBomDetailSequence = input.OrderBomDetail.Sequence, // ReceiptNo = input.ReceiptNo, // ReceiptDetailId = input.ReceiptDetailId, // ReceiptDetailSequence = input.ReceiptDetailSequence, // Bom = input.OrderBomDetail != null ? input.OrderBomDetail.Bom : null, // Item = input.Item, // ItemDescription = input.OrderBomDetail.ItemDescription, // ReferenceItemCode = input.OrderBomDetail.ReferenceItemCode, // Uom = input.Uom, // BaseUom = input.BaseUom, // UnitQty = input.UnitQty, // ManufactureParty = input.OrderBomDetail.ManufactureParty, // TraceCode = input.TraceCode, // //HuId = result.Key.HuId, // //LotNo = result.Key.LotNo, // Operation = input.Operation, // OpReference = input.OpReference, // BackflushedQty = input.FGQualityType == CodeMaster.QualityType.Qualified ? input.Qty : 0, //根据收货成品的质量状态记录至不同的回冲数量中 // BackflushedRejectQty = input.FGQualityType == CodeMaster.QualityType.Reject ? input.Qty : 0, // //BackflushedScrapQty = input.BackflushedQty, // LocationFrom = input.OrderBomDetail.Location, // ProductLine = input.ProductLine, // ProductLineFacility = input.ProductLineFacility, // ReserveNo = input.OrderBomDetail.ReserveNo, // ReserveLine = input.OrderBomDetail.ReserveLine, // AUFNR = input.OrderBomDetail.AUFNR, // EffectiveDate = effectiveDate, // CreateUserId = currentUser.Id, // CreateUserName = currentUser.FullName, // CreateDate = dateTimeNow, // }).ToList(); //#endregion //#region 汇总工单在制品投料明细 //foreach (BackflushInput backflushInput in backflushInputList.Where(i => i.OrderBomDetail == null // || i.OrderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.BackFlushOrder)) //{ // ((List<OrderBackflushDetail>)orderBackflushDetailList).AddRange(from p in backflushInput.ProductLineLocationDetailList // group p by new // { // HuId = p.HuId, // LotNo = p.LotNo, // Operation = p.Operation, // OpReference = p.OpReference, // LocationFrom = p.LocationFrom // } into result // select new OrderBackflushDetail // { // OrderNo = backflushInput.OrderNo, // OrderDetailId = backflushInput.OrderDetailId, // OrderDetailSequence = backflushInput.OrderDetailSequence, // OrderBomDetailId = backflushInput.OrderBomDetail != null ? (int?)backflushInput.OrderBomDetail.Id : null, // OrderBomDetailSequence = backflushInput.OrderBomDetail != null ? (int?)backflushInput.OrderBomDetail.Sequence : null, // ReceiptNo = backflushInput.ReceiptNo, // ReceiptDetailId = backflushInput.ReceiptDetailId, // ReceiptDetailSequence = backflushInput.ReceiptDetailSequence, // Bom = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.Bom : null, // Item = backflushInput.Item, // ItemDescription = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.ItemDescription : null, // ReferenceItemCode = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.ReferenceItemCode : null, // Uom = backflushInput.Uom, // BaseUom = backflushInput.BaseUom, // UnitQty = backflushInput.UnitQty, // ManufactureParty = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.ManufactureParty : null, // TraceCode = backflushInput.TraceCode, // HuId = result.Key.HuId, // LotNo = result.Key.LotNo, // Operation = result.Key.Operation, // OpReference = result.Key.OpReference, // BackflushedQty = backflushInput.FGQualityType == CodeMaster.QualityType.Qualified ? result.Sum(p => p.Qty) : 0, //根据收货成品的质量状态记录至不同的回冲数量中 // BackflushedRejectQty = backflushInput.FGQualityType == CodeMaster.QualityType.Reject ? result.Sum(p => p.Qty) : 0, // //BackflushedScrapQty = input.BackflushedQty, // LocationFrom = result.Key.LocationFrom, // ProductLine = backflushInput.ProductLine, // ProductLineFacility = backflushInput.ProductLineFacility, // ReserveNo = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.ReserveNo : null, // ReserveLine = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.ReserveLine : null, // AUFNR = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.AUFNR : orderMaster.ExternalOrderNo, //如果OrderBomDetail为空,说明是强制投料,用ExternalOrderNo作为SAP生产单号 // EffectiveDate = effectiveDate, // CreateUserId = currentUser.Id, // CreateUserName = currentUser.FullName, // CreateDate = dateTimeNow, // }); //} //#endregion //foreach (OrderBackflushDetail orderBackflushDetail in orderBackflushDetailList) //{ // this.genericMgr.Create(orderBackflushDetail); //} #endregion #region 回冲物料 this.locationDetailMgr.BackflushProductMaterial(backflushInputList); #endregion #region 记录工单投料明细/新 DateTime dateTimeNow = DateTime.Now; User currentUser = SecurityContextHolder.Get(); IList<OrderBackflushDetail> orderBackflushDetailList = new List<OrderBackflushDetail>(); #region 汇总收货回冲投料明细 foreach (BackflushInput input in backflushInputList.Where(input => input.OrderBomDetail != null && input.OrderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.GoodsReceive)) { ((List<OrderBackflushDetail>)orderBackflushDetailList).AddRange(from trans in input.InventoryTransactionList group trans by (trans.IsConsignment ? trans.PlanBill : null) into g select new OrderBackflushDetail { OrderNo = input.OrderNo, OrderDetailId = input.OrderDetailId, OrderDetailSequence = input.OrderDetailSequence, OrderBomDetailId = input.OrderBomDetail.Id, OrderBomDetailSequence = input.OrderBomDetail.Sequence, ReceiptNo = input.ReceiptNo, ReceiptDetailId = input.ReceiptDetailId, ReceiptDetailSequence = input.ReceiptDetailSequence, Bom = input.OrderBomDetail != null ? input.OrderBomDetail.Bom : null, FGItem = input.FGItem, Item = input.Item, ItemDescription = input.ItemDescription, ReferenceItemCode = input.ReferenceItemCode, Uom = input.Uom, BaseUom = input.BaseUom, UnitQty = input.UnitQty, ManufactureParty = input.OrderBomDetail.ManufactureParty, TraceCode = input.TraceCode, //HuId = result.Key.HuId, //LotNo = result.Key.LotNo, Operation = input.Operation, OpReference = input.OpReference, BackflushedQty = input.FGQualityType == CodeMaster.QualityType.Qualified ? g.Sum(trans => trans.Qty) / input.UnitQty : 0, //根据收货成品的质量状态记录至不同的回冲数量中 BackflushedRejectQty = input.FGQualityType == CodeMaster.QualityType.Reject ? g.Sum(trans => trans.Qty) / input.UnitQty : 0, //BackflushedScrapQty = input.BackflushedQty, LocationFrom = input.OrderBomDetail.Location, ProductLine = input.ProductLine, ProductLineFacility = input.ProductLineFacility, ReserveNo = input.OrderBomDetail.ReserveNo, ReserveLine = input.OrderBomDetail.ReserveLine, AUFNR = input.OrderBomDetail.AUFNR, ICHARG = input.OrderBomDetail.ICHARG, BWART = input.OrderBomDetail.BWART, NotReport = false, //理论都需要汇报 PlanBill = g.Key, EffectiveDate = effectiveDate, CreateUserId = currentUser.Id, CreateUserName = currentUser.FullName, CreateDate = dateTimeNow, IsVoid = false, }); } #endregion #region 汇总工单在制品投料明细 foreach (BackflushInput backflushInput in backflushInputList.Where(i => i.OrderBomDetail == null || i.OrderBomDetail.BackFlushMethod == CodeMaster.BackFlushMethod.BackFlushOrder)) { ((List<OrderBackflushDetail>)orderBackflushDetailList).AddRange(from p in backflushInput.InventoryTransactionList group p by new { HuId = p.HuId, LotNo = p.LotNo, Operation = p.Operation, OpReference = p.OpReference, LocationFrom = p.OrgLocation, PlanBill = p.IsConsignment ? p.PlanBill : null, ReserveNo = p.ReserveNo, ReserveLine = p.ReserveLine, AUFNR = p.AUFNR, ICHARG = p.ICHARG, BWART = p.BWART, NotReport = p.NotReport, } into result select new OrderBackflushDetail { OrderNo = backflushInput.OrderNo, OrderDetailId = backflushInput.OrderDetailId, OrderDetailSequence = backflushInput.OrderDetailSequence, OrderBomDetailId = backflushInput.OrderBomDetail != null ? (int?)backflushInput.OrderBomDetail.Id : null, OrderBomDetailSequence = backflushInput.OrderBomDetail != null ? (int?)backflushInput.OrderBomDetail.Sequence : null, ReceiptNo = backflushInput.ReceiptNo, ReceiptDetailId = backflushInput.ReceiptDetailId, ReceiptDetailSequence = backflushInput.ReceiptDetailSequence, Bom = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.Bom : null, FGItem = backflushInput.FGItem, Item = backflushInput.Item, ItemDescription = backflushInput.ItemDescription, ReferenceItemCode = backflushInput.ReferenceItemCode, Uom = backflushInput.Uom, BaseUom = backflushInput.BaseUom, UnitQty = backflushInput.UnitQty, ManufactureParty = backflushInput.OrderBomDetail != null ? backflushInput.OrderBomDetail.ManufactureParty : null, TraceCode = backflushInput.TraceCode, HuId = result.Key.HuId, LotNo = result.Key.LotNo, Operation = result.Key.Operation, OpReference = result.Key.OpReference, BackflushedQty = backflushInput.FGQualityType == CodeMaster.QualityType.Qualified ? result.Sum(p => p.Qty / backflushInput.UnitQty) : 0, //根据收货成品的质量状态记录至不同的回冲数量中 BackflushedRejectQty = backflushInput.FGQualityType == CodeMaster.QualityType.Reject ? result.Sum(p => p.Qty / backflushInput.UnitQty) : 0, //BackflushedScrapQty = input.BackflushedQty, LocationFrom = result.Key.LocationFrom, ProductLine = backflushInput.ProductLine, ProductLineFacility = backflushInput.ProductLineFacility, ReserveNo = result.Key.ReserveNo, ReserveLine = result.Key.ReserveLine, AUFNR = result.Key.AUFNR, ICHARG = result.Key.ICHARG, BWART = result.Key.BWART, NotReport = result.Key.NotReport, //过滤掉驾驶室和底盘总成 PlanBill = result.Key.PlanBill, EffectiveDate = effectiveDate, CreateUserId = currentUser.Id, CreateUserName = currentUser.FullName, CreateDate = dateTimeNow, IsVoid = false, }); } #endregion foreach (OrderBackflushDetail orderBackflushDetail in orderBackflushDetailList) { this.genericMgr.Create(orderBackflushDetail); } #endregion }