private void RecordLocationTransactionDetail(LocationTransaction locationTransaction, IList<InventoryTransaction> inventoryTransactionList) { if (bool.Parse(systemMgr.GetEntityPreferenceValue(EntityPreference.CodeEnum.IsRecordLocatoinTransactionDetail))) { foreach (InventoryTransaction inventoryTransaction in inventoryTransactionList) { LocationTransactionDetail locationTransactionDetail = Mapper.Map<LocationTransaction, LocationTransactionDetail>(locationTransaction); locationTransactionDetail.Qty = inventoryTransaction.Qty; //库存单位 locationTransactionDetail.PlanBillQty = inventoryTransaction.PlanBillQty; locationTransactionDetail.ActingBillQty = inventoryTransaction.ActingBillQty; locationTransactionDetail.BillTransactionId = inventoryTransaction.BillTransactionId; locationTransactionDetail.LocationLotDetailId = inventoryTransaction.LocationLotDetailId; locationTransactionDetail.Bin = inventoryTransaction.Bin; locationTransactionDetail.PlanBackflushId = inventoryTransaction.PlanBackflushId; this.genericMgr.Create(locationTransactionDetail); } } }
public void SettleLocaitonLotDetail(List<Int64> locationLotDetIdList) { var datetimeNow = DateTime.Now; var user = SecurityContextHolder.Get(); var locationLotDetailList = this.genericMgr.FindAllIn<LocationLotDetail>(" from LocationLotDetail where Id in(?", locationLotDetIdList.Select(p => (object)p)); if (locationLotDetailList.Any(p => !p.IsConsignment || !p.PlanBill.HasValue)) { throw new BusinessException("不是寄售库存不能结算"); } var planBillDic = this.genericMgr.FindAllIn<PlanBill>(" from PlanBill where Id in(?", locationLotDetailList.Select(p => (object)p.PlanBill.Value)) .ToDictionary(d => d.Id); var locationDic = this.genericMgr.FindAllIn<Location>(" from Location where Code in(?", locationLotDetailList.Select(p => p.Location).Distinct()) .ToDictionary(d => d.Code); foreach (var locationLotDetail in locationLotDetailList) { //结算 var planBill = planBillDic[locationLotDetail.PlanBill.Value]; planBill.CurrentActingQty = -locationLotDetail.Qty / planBill.UnitQty; //按负数结算 planBill.CurrentLocation = locationLotDetail.Location; planBill.CurrentHuId = locationLotDetail.HuId; var settleBillTrans = billMgr.SettleBill(planBill, datetimeNow); //记录库存事务 //出库 var location = locationDic[locationLotDetail.Location]; if (string.IsNullOrWhiteSpace(locationLotDetail.BaseUom)) { locationLotDetail.BaseUom = itemMgr.GetCacheItem(locationLotDetail.Item).Uom; } LocationTransaction locationTransactionOut = new LocationTransaction(); locationTransactionOut.OrderNo = locationLotDetail.Id.ToString(); locationTransactionOut.Item = locationLotDetail.Item; locationTransactionOut.Uom = locationLotDetail.BaseUom; locationTransactionOut.BaseUom = locationLotDetail.BaseUom; locationTransactionOut.Qty = -locationLotDetail.Qty; locationTransactionOut.UnitQty = 1; locationTransactionOut.IsConsignment = true; locationTransactionOut.PlanBill = locationLotDetail.PlanBill.Value; locationTransactionOut.PlanBillQty = locationLotDetail.Qty; locationTransactionOut.ActingBill = 0; locationTransactionOut.ActingBillQty = 0; locationTransactionOut.QualityType = locationLotDetail.QualityType; locationTransactionOut.HuId = locationLotDetail.HuId; locationTransactionOut.LotNo = locationLotDetail.LotNo; locationTransactionOut.LocationIOReason = "寄售出"; locationTransactionOut.TransactionType = CodeMaster.TransactionType.ISS_IIC; locationTransactionOut.IOType = CodeMaster.TransactionIOType.Out; locationTransactionOut.PartyFrom = location.Region; locationTransactionOut.PartyTo = location.Region; locationTransactionOut.LocationFrom = locationLotDetail.Location; locationTransactionOut.LocationTo = locationLotDetail.Location; locationTransactionOut.EffectiveDate = datetimeNow; locationTransactionOut.CreateUserId = user.Id; locationTransactionOut.CreateDate = datetimeNow; this.genericMgr.Create(locationTransactionOut); //入库 LocationTransaction locationTransactionIn = new LocationTransaction(); locationTransactionIn.OrderNo = locationLotDetail.Id.ToString(); locationTransactionIn.Item = locationLotDetail.Item; locationTransactionIn.Uom = locationLotDetail.BaseUom; locationTransactionIn.BaseUom = locationLotDetail.BaseUom; locationTransactionIn.Qty = locationLotDetail.Qty; locationTransactionIn.UnitQty = 1; locationTransactionIn.IsConsignment = false; locationTransactionIn.PlanBill = 0; locationTransactionIn.PlanBillQty = 0; locationTransactionIn.ActingBill = settleBillTrans.ActingBill; locationTransactionIn.ActingBillQty = locationLotDetail.Qty; locationTransactionIn.QualityType = locationLotDetail.QualityType; locationTransactionIn.HuId = locationLotDetail.HuId; locationTransactionIn.LotNo = locationLotDetail.LotNo; locationTransactionIn.LocationIOReason = "自有入"; locationTransactionIn.TransactionType = CodeMaster.TransactionType.RCT_IIC; locationTransactionIn.IOType = CodeMaster.TransactionIOType.In; locationTransactionIn.PartyFrom = location.Region; locationTransactionIn.PartyTo = location.Region; locationTransactionIn.LocationFrom = locationLotDetail.Location; locationTransactionIn.LocationTo = locationLotDetail.Location; locationTransactionIn.EffectiveDate = datetimeNow; locationTransactionIn.CreateUserId = user.Id; locationTransactionIn.CreateDate = datetimeNow; this.genericMgr.Create(locationTransactionIn); //更新库存 locationLotDetail.IsConsignment = false; locationLotDetail.PlanBill = null; this.genericMgr.Update(locationLotDetail); } }
private void RecordLocationTransaction(ItemExchange itemExchange, IList<InventoryTransaction> inventoryTransactionList, bool isIssue, bool isVoid) { //OutQty,OutUom,OutBaseUom,OutUnitQty,InHu,OutHu,OrderType DateTime dateTimeNow = DateTime.Now; LocationTransaction locationTransaction = new LocationTransaction(); //locationTransaction.OrderNo = ; //locationTransaction.OrderType = itemExchange.OrderType; //locationTransaction.OrderSubType = ; //locationTransaction.OrderDetailSequence = ; locationTransaction.OrderDetailId = itemExchange.Id; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = //locationTransaction.TraceCode = ; locationTransaction.Item = isIssue ? itemExchange.ItemFrom : itemExchange.ItemTo; locationTransaction.Uom = isIssue ? itemExchange.Uom : itemExchange.NewUom; locationTransaction.BaseUom = isIssue ? itemExchange.BaseUom : itemExchange.NewBaseUom; locationTransaction.Qty = isIssue ? (-itemExchange.Qty / itemExchange.UnitQty) : (itemExchange.NewQty / itemExchange.NewUnitQty); //转为订单单位 locationTransaction.UnitQty = isIssue ? itemExchange.UnitQty : itemExchange.NewUnitQty; locationTransaction.IsConsignment = false; //locationTransaction.PlanBill = null; //locationTransaction.ActingBill = null; //locationTransaction.ActingBillQty = 0; //转为订单单位 locationTransaction.QualityType = itemExchange.QualityType; locationTransaction.HuId = isIssue ? itemExchange.OldHu : itemExchange.NewHu; locationTransaction.LotNo = itemExchange.LotNo; #region 库存事务类型 locationTransaction.LocationIOReason = itemExchange.ItemExchangeType.ToString(); if (isIssue) { if (isVoid) { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_IIC_VOID; } else { locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_IIC; } } else { if (isVoid) { locationTransaction.TransactionType = CodeMaster.TransactionType.RCT_IIC_VOID; } else { locationTransaction.TransactionType = CodeMaster.TransactionType.RCT_IIC; } } #endregion locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = itemExchange.RegionFrom; locationTransaction.PartyTo = itemExchange.RegionTo; locationTransaction.LocationFrom = itemExchange.LocationFrom; locationTransaction.LocationTo = itemExchange.LocationTo; if (itemExchange.ItemExchangeType == CodeMaster.ItemExchangeType.Aging) { locationTransaction.LocationIOReason = "老化"; } else if (itemExchange.ItemExchangeType == CodeMaster.ItemExchangeType.Filter) { locationTransaction.LocationIOReason = "过滤"; } locationTransaction.EffectiveDate = itemExchange.EffectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); }
private void RecordLocationTransaction(IpDetail ipDetail, IpDetailInput ipDetailInput, DateTime effectiveDate, com.Sconit.CodeMaster.TransactionType transType, IList<InventoryTransaction> inventoryTransactionList) { DateTime dateTimeNow = DateTime.Now; //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开 var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, Qty = result.Sum(trans => trans.Qty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = ipDetail.OrderNo; locationTransaction.OrderType = ipDetail.OrderType; locationTransaction.OrderSubType = ipDetail.OrderSubType; locationTransaction.OrderDetailSequence = ipDetail.OrderDetailSequence; locationTransaction.OrderDetailId = ipDetail.OrderDetailId.Value; //locationTransaction.OrderBomDetId = locationTransaction.IpNo = ipDetail.IpNo; locationTransaction.IpDetailId = ipDetail.Id; locationTransaction.IpDetailSequence = ipDetail.Sequence; locationTransaction.ReceiptNo = string.Empty; //locationTransaction.RecDetSeq = locationTransaction.SequenceNo = ipDetailInput.SequenceNo; //locationTransaction.TraceCode = locationTransaction.Item = ipDetail.Item; locationTransaction.Uom = ipDetail.Uom; locationTransaction.BaseUom = ipDetail.BaseUom; locationTransaction.Qty = groupedInventoryTransaction.Qty / ipDetail.UnitQty; locationTransaction.UnitQty = ipDetail.UnitQty; locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment; if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value; } locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / ipDetail.UnitQty; if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / ipDetail.UnitQty; locationTransaction.QualityType = ipDetail.QualityType; locationTransaction.HuId = ipDetailInput.HuId; locationTransaction.LotNo = ipDetailInput.LotNo; locationTransaction.TransactionType = transType; locationTransaction.IOType = CodeMaster.TransactionIOType.Out; locationTransaction.PartyFrom = ipDetail.CurrentPartyFrom; locationTransaction.PartyTo = ipDetail.CurrentPartyTo; locationTransaction.LocationFrom = ipDetail.LocationFrom; locationTransaction.LocationTo = ipDetail.LocationTo; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, groupedInventoryTransaction.InventoryTransactionList); } }
private void RecordLocationTransaction(StockTakeMaster stockTakeMaster, StockTakeResult stockTakeResult, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList) { DateTime dateTimeNow = DateTime.Now; LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = stockTakeResult.StNo; //locationTransaction.OrderType = ; //locationTransaction.OrderSubType = ; //locationTransaction.OrderDetailSequence =; //locationTransaction.OrderDetailId =; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = //locationTransaction.TraceCode = ; locationTransaction.Item = stockTakeResult.Item; locationTransaction.Uom = stockTakeResult.Uom; locationTransaction.BaseUom = stockTakeResult.Uom; locationTransaction.Qty = stockTakeResult.DifferenceQty; locationTransaction.UnitQty = 1; locationTransaction.ActingBillQty = inventoryTransactionList.Sum(i => i.ActingBillQty); locationTransaction.QualityType = stockTakeResult.QualityType; locationTransaction.HuId = stockTakeResult.HuId; locationTransaction.LotNo = stockTakeResult.LotNo; locationTransaction.TransactionType = CodeMaster.TransactionType.CYC_CNT; locationTransaction.IOType = stockTakeResult.DifferenceQty < 0 ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = stockTakeMaster.Region; locationTransaction.PartyTo = stockTakeMaster.Region; locationTransaction.LocationFrom = stockTakeResult.Location; locationTransaction.LocationTo = stockTakeResult.Location; locationTransaction.LocationIOReason = stockTakeMaster.CostCenter; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); }
private void RecordLocationTransaction(MiscOrderMaster miscOrderMaster, MiscOrderDetail miscOrderDetail, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isVoid) { DateTime dateTimeNow = DateTime.Now; if (miscOrderMaster.IsScanHu) { //按条码出入库只可能有一条 InventoryTransaction inventoryTransaction = inventoryTransactionList[0]; LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = miscOrderMaster.MiscOrderNo; //locationTransaction.OrderType = ipDetail.OrderType; //locationTransaction.OrderSubType = ipDetail.OrderSubType; locationTransaction.OrderDetailSequence = miscOrderDetail.Sequence; locationTransaction.OrderDetailId = miscOrderDetail.Id; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = ipDetail.IpNo; //locationTransaction.IpDetailId = ipDetail.Id; //locationTransaction.IpDetailSequence = ipDetail.Sequence; //locationTransaction.ReceiptNo = string.Empty; //locationTransaction.RecDetSeq = //locationTransaction.SequenceNo = ipDetailInput.SequenceNo; //locationTransaction.TraceCode = locationTransaction.Item = miscOrderDetail.Item; locationTransaction.Uom = miscOrderDetail.Uom; locationTransaction.BaseUom = miscOrderDetail.BaseUom; locationTransaction.Qty = inventoryTransaction.Qty / miscOrderDetail.UnitQty; //转为订单单位 locationTransaction.UnitQty = miscOrderDetail.UnitQty; locationTransaction.IsConsignment = inventoryTransaction.IsConsignment; if (inventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = inventoryTransaction.PlanBill.Value; } locationTransaction.PlanBillQty = inventoryTransaction.PlanBillQty / miscOrderDetail.UnitQty; //转为订单单位 if (inventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = inventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = inventoryTransaction.ActingBillQty / miscOrderDetail.UnitQty; //转为订单单位 locationTransaction.QualityType = inventoryTransaction.QualityType; locationTransaction.HuId = inventoryTransaction.HuId; locationTransaction.LotNo = inventoryTransaction.LotNo; if (!isVoid) { locationTransaction.TransactionType = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? CodeMaster.TransactionType.ISS_UNP : CodeMaster.TransactionType.RCT_UNP; } else { locationTransaction.TransactionType = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? CodeMaster.TransactionType.ISS_UNP_VOID : CodeMaster.TransactionType.RCT_UNP_VOID; } locationTransaction.IOType = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? miscOrderMaster.Region : null; locationTransaction.PartyTo = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? null : miscOrderMaster.Region; locationTransaction.LocationFrom = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? (!string.IsNullOrWhiteSpace(miscOrderDetail.Location) ? miscOrderDetail.Location : miscOrderMaster.Location) : null; locationTransaction.LocationTo = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? null : (!string.IsNullOrWhiteSpace(miscOrderDetail.Location) ? miscOrderDetail.Location : miscOrderMaster.Location); locationTransaction.LocationIOReason = miscOrderMaster.MoveType; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); } else { //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开 var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, Qty = result.Sum(trans => trans.Qty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = miscOrderMaster.MiscOrderNo; //locationTransaction.OrderType = ipDetail.OrderType; //locationTransaction.OrderSubType = ipDetail.OrderSubType; locationTransaction.OrderDetailSequence = miscOrderDetail.Sequence; locationTransaction.OrderDetailId = miscOrderDetail.Id; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = ipDetail.IpNo; //locationTransaction.IpDetailId = ipDetail.Id; //locationTransaction.IpDetailSequence = ipDetail.Sequence; //locationTransaction.ReceiptNo = string.Empty; //locationTransaction.RecDetSeq = //locationTransaction.SequenceNo = ipDetailInput.SequenceNo; //locationTransaction.TraceCode = locationTransaction.Item = miscOrderDetail.Item; locationTransaction.Uom = miscOrderDetail.Uom; locationTransaction.BaseUom = miscOrderDetail.BaseUom; locationTransaction.Qty = groupedInventoryTransaction.Qty / miscOrderDetail.UnitQty; //转为订单单位 locationTransaction.UnitQty = miscOrderDetail.UnitQty; locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment; if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value; } locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / miscOrderDetail.UnitQty; //转为订单单位 if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / miscOrderDetail.UnitQty; //转为订单单位 locationTransaction.QualityType = miscOrderMaster.QualityType; //locationTransaction.HuId = ipDetailInput.HuId; //locationTransaction.LotNo = ipDetailInput.LotNo; if (!isVoid) { locationTransaction.TransactionType = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? CodeMaster.TransactionType.ISS_UNP : CodeMaster.TransactionType.RCT_UNP; } else { locationTransaction.TransactionType = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? CodeMaster.TransactionType.ISS_UNP_VOID : CodeMaster.TransactionType.RCT_UNP_VOID; } locationTransaction.IOType = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? miscOrderMaster.Region : null; locationTransaction.PartyTo = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? null : miscOrderMaster.Region; locationTransaction.LocationFrom = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? (!string.IsNullOrWhiteSpace(miscOrderDetail.Location) ? miscOrderDetail.Location : miscOrderMaster.Location) : null; locationTransaction.LocationTo = miscOrderMaster.Type == CodeMaster.MiscOrderType.GI ? null : !string.IsNullOrWhiteSpace(miscOrderDetail.Location) ? miscOrderDetail.Location : miscOrderMaster.Location; locationTransaction.LocationIOReason = miscOrderMaster.MoveType; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, groupedInventoryTransaction.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); } } }
private void RecordLocationTransaction(InventoryRePack inventoryRePack, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isIssue) { DateTime dateTimeNow = DateTime.Now; //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开 var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, //Qty = result.Sum(trans => isIssue ? -trans.Qty : trans.Qty), Qty = result.Sum(trans => trans.Qty), //PlanBillQty = result.Sum(trans => isIssue ? -trans.PlanBillQty : trans.PlanBillQty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), //ActingBillQty = result.Sum(trans => isIssue ? -trans.ActingBillQty : trans.ActingBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); //locationTransaction.OrderNo = ; //locationTransaction.OrderType = ; //locationTransaction.OrderSubType = ; //locationTransaction.OrderDetailSequence = ; //locationTransaction.OrderDetailId = ; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = //locationTransaction.TraceCode = ; locationTransaction.Item = inventoryRePack.CurrentHu.Item; locationTransaction.Uom = inventoryRePack.CurrentHu.Uom; locationTransaction.BaseUom = inventoryRePack.CurrentHu.BaseUom; locationTransaction.Qty = groupedInventoryTransaction.Qty / inventoryRePack.CurrentHu.UnitQty; locationTransaction.UnitQty = inventoryRePack.CurrentHu.UnitQty; locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment; if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value; } locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / inventoryRePack.CurrentHu.UnitQty; if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / inventoryRePack.CurrentHu.UnitQty; locationTransaction.QualityType = inventoryRePack.CurrentHu.QualityType; locationTransaction.HuId = inventoryRePack.CurrentHu.HuId; locationTransaction.LotNo = inventoryRePack.CurrentHu.LotNo; locationTransaction.TransactionType = isIssue ? CodeMaster.TransactionType.ISS_REP : CodeMaster.TransactionType.RCT_REP; locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = inventoryRePack.CurrentLocation.Region; locationTransaction.PartyTo = inventoryRePack.CurrentLocation.Region; locationTransaction.LocationFrom = inventoryRePack.CurrentLocation.Code; locationTransaction.LocationTo = inventoryRePack.CurrentLocation.Code; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, groupedInventoryTransaction.InventoryTransactionList); } }
private void RecordLocationTransaction(IList<WeightAverageBackflushResult> weightAverageBackflushResultList, DateTime effectiveDate) { DateTime dateTimeNow = DateTime.Now; foreach (var trans in from w in weightAverageBackflushResultList group w by new { OrderNo = w.PlanBackflush.OrderNo, OrderType = w.PlanBackflush.OrderType, OrderSubType = w.PlanBackflush.OrderSubType, OrderDetailSequence = w.PlanBackflush.OrderDetailSequence, OrderDetailId = w.PlanBackflush.OrderDetailId, OrderBomDetailId = w.PlanBackflush.OrderBomDetailId, OrderBomDetailSequence = w.PlanBackflush.OrderBomDetailSequence, ReceiptNo = w.PlanBackflush.ReceiptNo, ReceiptDetailId = w.PlanBackflush.ReceiptDetailId, ReceiptDetailSequence = w.PlanBackflush.ReceiptDetailSequence, FGItem = w.PlanBackflush.FGItem, Item = w.PlanBackflush.Item, Uom = w.PlanBackflush.Uom, BaseUom = w.PlanBackflush.BaseUom, UnitQty = w.PlanBackflush.UnitQty, ActingBill = w.InventoryTransaction.ActingBill, QualityType = w.ProductLineLocationDetail.QualityType, PartyFrom = w.CurrentProductLine.PartyFrom, PartyTo = w.CurrentProductLine.PartyTo, LocationFrom = w.ProductLineLocationDetail.ProductLine, } into result select new { OrderNo = result.Key.OrderNo, OrderType = result.Key.OrderType, OrderSubType = result.Key.OrderSubType, OrderDetailSequence = result.Key.OrderDetailSequence, OrderDetailId = result.Key.OrderDetailId, OrderBomDetailId = result.Key.OrderBomDetailId, OrderBomDetailSequence = result.Key.OrderBomDetailSequence, ReceiptNo = result.Key.ReceiptNo, ReceiptDetailId = result.Key.ReceiptDetailId, ReceiptDetailSequence = result.Key.ReceiptDetailSequence, FGItem = result.Key.FGItem, Item = result.Key.Item, Uom = result.Key.Uom, BaseUom = result.Key.BaseUom, UnitQty = result.Key.UnitQty, Qty = result.Sum(q => q.Qty), //订单单位 PlanBillQty = 0, //订单单位 ActingBill = result.Key.ActingBill, ActingBillQty = result.Sum(q => q.ActingQty), //订单单位 QualityType = result.Key.QualityType, PartyFrom = result.Key.PartyFrom, PartyTo = result.Key.PartyTo, LocationFrom = result.Key.LocationFrom, List = result.ToList() }) { LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = trans.OrderNo; locationTransaction.OrderType = trans.OrderType; locationTransaction.OrderSubType = trans.OrderSubType; locationTransaction.OrderDetailSequence = trans.OrderDetailSequence; locationTransaction.OrderDetailId = trans.OrderDetailId; locationTransaction.OrderBomDetailId = trans.OrderBomDetailId; locationTransaction.OrderBomDetailSequence = trans.OrderBomDetailSequence; locationTransaction.ReceiptNo = trans.ReceiptNo; locationTransaction.ReceiptDetailId = trans.ReceiptDetailId; locationTransaction.ReceiptDetailSequence = trans.ReceiptDetailSequence; //locationTransaction.SequenceNo = locationTransaction.Item = trans.Item; locationTransaction.Uom = trans.Uom; locationTransaction.BaseUom = trans.BaseUom; locationTransaction.UnitQty = trans.UnitQty; locationTransaction.Qty = trans.Qty; locationTransaction.IsConsignment = false; //locationTransaction.PlanBill = locationTransaction.PlanBillQty = trans.PlanBillQty; if (trans.ActingBill.HasValue) { locationTransaction.ActingBill = trans.ActingBill.Value; } locationTransaction.ActingBillQty = trans.ActingBillQty; locationTransaction.QualityType = trans.QualityType; locationTransaction.PartyFrom = trans.PartyFrom; locationTransaction.PartyTo = trans.PartyTo; locationTransaction.LocationFrom = trans.LocationFrom; locationTransaction.TransactionType = CodeMaster.TransactionType.ISS_WO_BF; locationTransaction.IOType = CodeMaster.TransactionIOType.Out; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); #region 记录库存事务明细,待验证是否正确 IList<InventoryTransaction> inventoryTransactionList = new List<InventoryTransaction>(); foreach (WeightAverageBackflushResult result in trans.List) { inventoryTransactionList.Add(result.InventoryTransaction); } RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); #endregion } }
private void RecordLocationTransaction(ReturnInput returnInput, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isIssue) //isIssue区分是退料出生产线还是退料入库 { var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { //为了能够退料回原投料库位,要对LocationTo分组,如果指定了退料的出库库位则按照出库库位分组。 LocationTo = !string.IsNullOrWhiteSpace(returnInput.LocationTo) ? returnInput.LocationTo : (isIssue ? trans.OrgLocation : trans.Location), IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { LocationTo = result.Key.LocationTo, IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, //Qty = result.Sum(trans => isIssue ? -trans.Qty : trans.Qty), Qty = result.Sum(trans => trans.Qty), //PlanBillQty = result.Sum(trans => isIssue ? -trans.PlanBillQty : trans.PlanBillQty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), //ActingBillQty = result.Sum(trans => isIssue ? -trans.ActingBillQty : trans.ActingBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; DateTime dateTimeNow = DateTime.Now; foreach (var trans in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); if (returnInput.OrderNo != null) { locationTransaction.OrderNo = returnInput.OrderNo; locationTransaction.OrderType = returnInput.OrderType; locationTransaction.OrderSubType = returnInput.OrderSubType; //locationTransaction.OrderDetailSequence = //locationTransaction.OrderDetailId = //locationTransaction.OrderBomDetId = } //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = locationTransaction.TraceCode = returnInput.TraceCode; locationTransaction.Item = returnInput.Item; locationTransaction.Uom = returnInput.Uom; locationTransaction.BaseUom = returnInput.BaseUom; locationTransaction.Qty = trans.Qty / returnInput.UnitQty; locationTransaction.UnitQty = returnInput.UnitQty; locationTransaction.IsConsignment = trans.IsConsignment; if (trans.IsConsignment && trans.PlanBill.HasValue) { locationTransaction.PlanBill = trans.PlanBill.Value; } locationTransaction.PlanBillQty = trans.PlanBillQty / returnInput.UnitQty; if (trans.ActingBill.HasValue) { locationTransaction.ActingBill = trans.ActingBill.Value; } locationTransaction.ActingBillQty = trans.ActingBillQty / returnInput.UnitQty; locationTransaction.QualityType = returnInput.QualityType; locationTransaction.HuId = returnInput.HuId; locationTransaction.LotNo = returnInput.LotNo; locationTransaction.TransactionType = isIssue ? com.Sconit.CodeMaster.TransactionType.ISS_MIN_RTN : com.Sconit.CodeMaster.TransactionType.RCT_MIN_RTN; locationTransaction.IOType = isIssue ? com.Sconit.CodeMaster.TransactionIOType.Out : com.Sconit.CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = returnInput.CurrentProductLine.PartyFrom; //如果指定了退料库位,直接取缓存的退料区域。如果没有指定,则查找原来投料的库位区域 locationTransaction.PartyTo = !string.IsNullOrWhiteSpace(returnInput.LocationTo) ? returnInput.CurrentLocationTo.Region : this.genericMgr.FindById<Location>(trans.LocationTo).Region; locationTransaction.LocationFrom = returnInput.ProductLine; //记录投料入的生产线 locationTransaction.LocationTo = trans.LocationTo; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, trans.InventoryTransactionList); } }
private void RecordLocationTransaction(FeedInput feedInput, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList, bool isIssue) //isIssue区分是投料出库还是投料入生产线 { DateTime dateTimeNow = DateTime.Now; //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开 var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, //Qty = result.Sum(trans => isIssue ? -trans.Qty : trans.Qty), Qty = result.Sum(trans => trans.Qty), //PlanBillQty = result.Sum(trans => isIssue ? -trans.PlanBillQty : trans.PlanBillQty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), //ActingBillQty = result.Sum(trans => isIssue ? -trans.ActingBillQty : trans.ActingBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); if (feedInput.OrderNo != null) { locationTransaction.OrderNo = feedInput.OrderNo; locationTransaction.OrderType = feedInput.OrderType; locationTransaction.OrderSubType = feedInput.OrderSubType; //locationTransaction.OrderDetailSequence = //locationTransaction.OrderDetailId = //locationTransaction.OrderBomDetId = } //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = locationTransaction.TraceCode = feedInput.TraceCode; locationTransaction.Item = feedInput.Item; locationTransaction.Uom = feedInput.Uom; locationTransaction.BaseUom = feedInput.BaseUom; locationTransaction.Qty = groupedInventoryTransaction.Qty / feedInput.UnitQty;//isIssue ? -feedInput.Qty : feedInput.Qty; locationTransaction.UnitQty = feedInput.UnitQty; locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment;//isIssue ? -feedInput.Qty : feedInput.Qty; if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value;//inventoryTransactionList.Sum(i => (isIssue ? -i.PlanBillQty : i.PlanBillQty) / feedInput.UnitQty); } locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty / feedInput.UnitQty;//inventoryTransactionList.Sum(i => (isIssue ? -i.PlanBillQty : i.PlanBillQty) / feedInput.UnitQty); if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value;//inventoryTransactionList.Sum(i => (isIssue ? -i.PlanBillQty : i.PlanBillQty) / feedInput.UnitQty); } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty / feedInput.UnitQty; //inventoryTransactionList.Sum(i => (isIssue ? -i.ActingBillQty : i.ActingBillQty) / feedInput.UnitQty); locationTransaction.QualityType = feedInput.QualityType; locationTransaction.HuId = feedInput.HuId; locationTransaction.LotNo = feedInput.LotNo; locationTransaction.TransactionType = isIssue ? com.Sconit.CodeMaster.TransactionType.ISS_WO : com.Sconit.CodeMaster.TransactionType.RCT_MIN; locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = feedInput.CurrentLocationFrom.Region; locationTransaction.PartyTo = feedInput.CurrentProductLine.PartyFrom; locationTransaction.LocationFrom = feedInput.LocationFrom; //locationTransaction.LocationTo = feedInput.ProductLine; //记录投料入的生产线 locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, groupedInventoryTransaction.InventoryTransactionList); } }
private void RecordLocationTransaction(ItemExchange itemExchange, IList<InventoryTransaction> inventoryTransactionList, bool isIssue, bool isVoid) { DateTime dateTimeNow = DateTime.Now; LocationTransaction locationTransaction = new LocationTransaction(); //locationTransaction.OrderNo = ; //locationTransaction.OrderType = ; //locationTransaction.OrderSubType = ; //locationTransaction.OrderDetailSequence = ; locationTransaction.OrderDetailId = itemExchange.Id; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = //locationTransaction.TraceCode = ; locationTransaction.Item = isIssue ? itemExchange.ItemFrom : itemExchange.ItemTo; locationTransaction.Uom = itemExchange.Uom; locationTransaction.BaseUom = itemExchange.BaseUom; locationTransaction.Qty = itemExchange.Qty / itemExchange.UnitQty; //转为订单单位 locationTransaction.UnitQty = itemExchange.UnitQty; locationTransaction.IsConsignment = false; //locationTransaction.PlanBill = null; //locationTransaction.ActingBill = null; //locationTransaction.ActingBillQty = 0; //转为订单单位 locationTransaction.QualityType = itemExchange.QualityType; //locationTransaction.HuId = //locationTransaction.LotNo = if (!isVoid) { locationTransaction.TransactionType = isIssue ? CodeMaster.TransactionType.ISS_IIC : CodeMaster.TransactionType.RCT_IIC; } else { locationTransaction.TransactionType = isIssue ? CodeMaster.TransactionType.ISS_IIC_VOID : CodeMaster.TransactionType.RCT_IIC_VOID; } locationTransaction.IOType = isIssue ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = itemExchange.RegionFrom; locationTransaction.PartyTo = itemExchange.RegionTo; locationTransaction.LocationFrom = itemExchange.LocationFrom; locationTransaction.LocationTo = itemExchange.LocationTo; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = itemExchange.EffectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); }
private void RecordLocationTransaction(StockTakeMaster stockTakeMaster, StockTakeResult stockTakeResult, DateTime effectiveDate, IList<InventoryTransaction> inventoryTransactionList) { DateTime dateTimeNow = DateTime.Now; //根据PlanBill和ActingBill分组,为了不同供应商的库存事务分开 var groupedInventoryTransactionList = from trans in inventoryTransactionList group trans by new { IsConsignment = trans.IsConsignment, PlanBill = trans.PlanBill, ActingBill = trans.ActingBill } into result select new { IsConsignment = result.Key.IsConsignment, PlanBill = result.Key.PlanBill, ActingBill = result.Key.ActingBill, Qty = result.Sum(trans => trans.Qty), PlanBillQty = result.Sum(trans => trans.PlanBillQty), ActingBillQty = result.Sum(trans => trans.ActingBillQty), InventoryTransactionList = result.ToList() }; foreach (var groupedInventoryTransaction in groupedInventoryTransactionList) { LocationTransaction locationTransaction = new LocationTransaction(); locationTransaction.OrderNo = stockTakeResult.StNo; //locationTransaction.OrderType = ; //locationTransaction.OrderSubType = ; //locationTransaction.OrderDetailSequence =; //locationTransaction.OrderDetailId =; //locationTransaction.OrderBomDetId = //locationTransaction.IpNo = //locationTransaction.IpDetailId = //locationTransaction.IpDetailSequence = //locationTransaction.ReceiptNo = //locationTransaction.ReceiptDetailId = //locationTransaction.ReceiptDetailSequence = //locationTransaction.SequenceNo = //locationTransaction.TraceCode = ; locationTransaction.Item = stockTakeResult.Item; locationTransaction.Uom = stockTakeResult.Uom; locationTransaction.BaseUom = stockTakeResult.Uom; locationTransaction.Qty = groupedInventoryTransaction.Qty; locationTransaction.UnitQty = 1; locationTransaction.IsConsignment = groupedInventoryTransaction.IsConsignment; if (groupedInventoryTransaction.IsConsignment && groupedInventoryTransaction.PlanBill.HasValue) { locationTransaction.PlanBill = groupedInventoryTransaction.PlanBill.Value; } locationTransaction.PlanBillQty = groupedInventoryTransaction.PlanBillQty; if (groupedInventoryTransaction.ActingBill.HasValue) { locationTransaction.ActingBill = groupedInventoryTransaction.ActingBill.Value; } locationTransaction.ActingBillQty = groupedInventoryTransaction.ActingBillQty; locationTransaction.QualityType = stockTakeResult.QualityType; locationTransaction.HuId = stockTakeResult.HuId; locationTransaction.LotNo = stockTakeResult.LotNo; locationTransaction.TransactionType = CodeMaster.TransactionType.CYC_CNT; locationTransaction.IOType = stockTakeResult.DifferenceQty < 0 ? CodeMaster.TransactionIOType.Out : CodeMaster.TransactionIOType.In; locationTransaction.PartyFrom = stockTakeMaster.Region; locationTransaction.PartyTo = stockTakeMaster.Region; locationTransaction.LocationFrom = stockTakeResult.Location; locationTransaction.LocationTo = stockTakeResult.Location; locationTransaction.LocationIOReason = string.Empty; locationTransaction.EffectiveDate = effectiveDate; locationTransaction.CreateUserId = SecurityContextHolder.Get().Id; locationTransaction.CreateDate = dateTimeNow; this.genericMgr.Create(locationTransaction); RecordLocationTransactionDetail(locationTransaction, inventoryTransactionList); } }