public void DoTransfer(Entity.SD.SCM.FlowMaster flowMaster, List<Entity.SD.ORD.OrderDetailInput> orderDetailInputList) { var orderMaster = new Entity.ORD.OrderMaster(); var locationFrom = this.genericMgr.FindById<Entity.MD.Location>(flowMaster.LocationFrom); var locationTo = this.genericMgr.FindById<Entity.MD.Location>(flowMaster.LocationTo); var partyFrom = this.genericMgr.FindById<Entity.MD.Party>(flowMaster.PartyFrom); var partyTo = this.genericMgr.FindById<Entity.MD.Party>(flowMaster.PartyTo); orderMaster.LocationFrom = locationFrom.Code; orderMaster.IsShipScanHu = (flowMaster != null ? flowMaster.IsShipScanHu : true); orderMaster.IsReceiveScanHu = (flowMaster != null ? flowMaster.IsReceiveScanHu : true); orderMaster.IsAutoReceive = true; orderMaster.LocationFromName = locationFrom.Name; orderMaster.LocationTo = locationTo.Code; orderMaster.LocationToName = locationTo.Name; orderMaster.PartyFrom = partyFrom.Code; orderMaster.PartyFromName = partyFrom.Name; orderMaster.PartyTo = partyTo.Code; orderMaster.PartyToName = partyTo.Name; orderMaster.Type = CodeMaster.OrderType.Transfer; orderMaster.StartTime = DateTime.Now; orderMaster.WindowTime = DateTime.Now; orderMaster.EffectiveDate = flowMaster.EffectiveDate; orderMaster.Flow = flowMaster != null ? flowMaster.Code : null; orderMaster.IsQuick = true; orderMaster.OrderDetails = new List<Entity.ORD.OrderDetail>(); int seq = 1; var ids = orderDetailInputList.Select(o => o.Id).Distinct(); foreach (var id in ids) { var selectedOrderDetailInputList = orderDetailInputList.Where(o => o.Id == id); if (selectedOrderDetailInputList != null && selectedOrderDetailInputList.Count() > 0) { var firstInput = selectedOrderDetailInputList.First(); var hu = this.genericMgr.FindById<Entity.INV.Hu>(firstInput.HuId); var item = this.genericMgr.FindById<Entity.MD.Item>(hu.Item); var baseOrderDetail = new Entity.ORD.OrderDetail(); baseOrderDetail.BaseUom = item.Uom; baseOrderDetail.Item = item.Code; baseOrderDetail.ItemDescription = item.Description; baseOrderDetail.OrderType = flowMaster.Type; baseOrderDetail.QualityType = orderMaster.QualityType; baseOrderDetail.Sequence = seq++; baseOrderDetail.UnitCount = item.UnitCount; baseOrderDetail.Uom = hu.Uom; baseOrderDetail.OrderDetailInputs = new List<Entity.ORD.OrderDetailInput>(); foreach (Entity.SD.ORD.OrderDetailInput orderDetailInput in selectedOrderDetailInputList) { var baseOrderDetailInput = new Entity.ORD.OrderDetailInput(); //支持新的条码逻辑 if (flowMaster.IsShipScanHu) baseOrderDetailInput.HuId = orderDetailInput.HuId; baseOrderDetailInput.ReceiveQty = orderDetailInput.Qty; baseOrderDetailInput.Bin = orderDetailInput.Bin; baseOrderDetailInput.LotNo = orderDetailInput.LotNo; baseOrderDetail.OrderDetailInputs.Add(baseOrderDetailInput); baseOrderDetail.RequiredQty += orderDetailInput.Qty; baseOrderDetail.OrderedQty += orderDetailInput.Qty; } orderMaster.OrderDetails.Add(baseOrderDetail); } } this.orderMgr.CreateOrder(orderMaster); //todo上架 if (!string.IsNullOrWhiteSpace(flowMaster.Bin)) { // } }
public void CreateInspectTransfer(Location location, IList<InspectDetail> inspectDetailList) { var orderMaster = new Entity.ORD.OrderMaster(); var inspectNoList = (from inp in inspectDetailList select inp.InspectNo).Distinct().ToList(); if (inspectNoList.Count() > 1) { throw new BusinessException("多个报验单待验明细不能合并移库。"); } InspectMaster inspectMaster = genericMgr.FindById<InspectMaster>(inspectNoList[0]); var locationFrom = this.genericMgr.FindById<Entity.MD.Location>(inspectDetailList[0].LocationFrom); var partyFrom = this.genericMgr.FindById<Entity.MD.Party>(locationFrom.Region); var partyTo = this.genericMgr.FindById<Entity.MD.Party>(location.Region); orderMaster.LocationFrom = locationFrom.Code; orderMaster.IsShipScanHu = inspectMaster.Type == com.Sconit.CodeMaster.InspectType.Barcode; orderMaster.IsReceiveScanHu = inspectMaster.Type == com.Sconit.CodeMaster.InspectType.Barcode; orderMaster.LocationFromName = locationFrom.Name; orderMaster.LocationTo = location.Code; orderMaster.LocationToName = location.Name; orderMaster.PartyFrom = partyFrom.Code; orderMaster.PartyFromName = partyFrom.Name; orderMaster.PartyTo = partyTo.Code; orderMaster.PartyToName = partyTo.Name; orderMaster.Type = CodeMaster.OrderType.Transfer; orderMaster.StartTime = DateTime.Now; orderMaster.WindowTime = DateTime.Now; orderMaster.EffectiveDate = DateTime.Now; orderMaster.QualityType = com.Sconit.CodeMaster.QualityType.Inspect; orderMaster.IsQuick = true; orderMaster.OrderDetails = new List<OrderDetail>(); int seq = 1; var groupInspectDetailList = from d in inspectDetailList group d by new { d.Item, d.CurrentLocation } into result select result; foreach (var inspectDetail in groupInspectDetailList) { var currentInspectDetailList = inspectDetailList.Where(p => p.Item == inspectDetail.Key.Item && p.CurrentLocation == inspectDetail.Key.CurrentLocation).ToList(); var orderDetail = new OrderDetail(); var orderDetailInputList = new List<OrderDetailInput>(); Mapper.Map(currentInspectDetailList[0], orderDetail); orderDetail.OrderType = com.Sconit.CodeMaster.OrderType.Transfer; orderDetail.QualityType = com.Sconit.CodeMaster.QualityType.Inspect; orderDetail.LocationFrom = inspectDetail.Key.CurrentLocation; orderDetail.LocationFromName = genericMgr.FindById<Location>(inspectDetail.Key.CurrentLocation).Name; orderDetail.LocationTo = location.Code; orderDetail.LocationToName = location.Name; orderDetail.Sequence = seq++; foreach (InspectDetail insp in currentInspectDetailList) { var orderDetailInput = new OrderDetailInput(); if (inspectMaster.Type == com.Sconit.CodeMaster.InspectType.Barcode) { orderDetailInput.HuId = insp.HuId; orderDetailInput.LotNo = insp.LotNo; } orderDetailInput.QualityType = com.Sconit.CodeMaster.QualityType.Inspect; orderDetailInput.OccupyType = com.Sconit.CodeMaster.OccupyType.Inspect; orderDetailInput.OccupyReferenceNo = inspectMaster.InspectNo; orderDetailInput.ReceiveQty = insp.CurrentTransferQty; orderDetail.RequiredQty += insp.CurrentTransferQty; orderDetail.OrderedQty += insp.CurrentTransferQty; orderDetailInputList.Add(orderDetailInput); } orderDetail.OrderDetailInputs = orderDetailInputList; orderMaster.OrderDetails.Add(orderDetail); } CreateOrder(orderMaster); #region 更新检验明细 foreach (InspectDetail insp in inspectDetailList) { insp.CurrentLocation = location.Code; genericMgr.Update(insp); } #endregion }
public void DoTransfer(Entity.SI.SD_SCM.FlowMaster flowMaster, List<Entity.SI.SD_SCM.FlowDetailInput> flowDetailInputList) { if (flowDetailInputList == null || flowDetailInputList.Count == 0) { throw new BusinessException("没有可以移库的明细"); } if (flowDetailInputList.GroupBy(p => p.QualityType).Count() > 1) { throw new BusinessException("不同质量状态的条码不能合并成一张订单移库"); } var orderMaster = new Entity.ORD.OrderMaster(); var locationFrom = this.genericMgr.FindById<Entity.MD.Location>(flowMaster.LocationFrom); var locationTo = this.genericMgr.FindById<Entity.MD.Location>(flowMaster.LocationTo); var partyFrom = this.genericMgr.FindById<Entity.MD.Party>(flowMaster.PartyFrom); var partyTo = this.genericMgr.FindById<Entity.MD.Party>(flowMaster.PartyTo); orderMaster.LocationFrom = locationFrom.Code; orderMaster.IsShipScanHu = true; orderMaster.IsReceiveScanHu = true; orderMaster.LocationFromName = locationFrom.Name; orderMaster.LocationTo = locationTo.Code; orderMaster.LocationToName = locationTo.Name; orderMaster.PartyFrom = partyFrom.Code; orderMaster.PartyFromName = partyFrom.Name; orderMaster.PartyTo = partyTo.Code; orderMaster.PartyToName = partyTo.Name; orderMaster.Type = !locationTo.Region.StartsWith("S", StringComparison.OrdinalIgnoreCase) ? CodeMaster.OrderType.Transfer : CodeMaster.OrderType.SubContractTransfer; orderMaster.StartTime = DateTime.Now; orderMaster.WindowTime = DateTime.Now; orderMaster.EffectiveDate = flowMaster.EffectiveDate; orderMaster.Flow = flowMaster.Code; orderMaster.IsShipFulfillUC = false; orderMaster.IsQuick = true; orderMaster.IsPrintReceipt = true; orderMaster.QualityType = flowDetailInputList.First().QualityType; orderMaster.OrderTemplate = "ORD_Transfer.xls"; orderMaster.AsnTemplate = "ASN_Transfer.xls"; orderMaster.ReceiptTemplate = "REC_InvIn.xls"; orderMaster.IsAsnUniqueReceive = true; if (!string.IsNullOrWhiteSpace(flowMaster.Code)) { var baseFlowMaster = this.genericMgr.FindById<FlowMaster>(flowMaster.Code); orderMaster.IsQuick = false; orderMaster.IsShipScanHu = baseFlowMaster.IsShipScanHu; orderMaster.IsReceiveScanHu = baseFlowMaster.IsReceiveScanHu; orderMaster.IsAutoReceive = baseFlowMaster.IsAutoReceive; orderMaster.IsAutoRelease = true;//baseFlowMaster.IsAutoRelease; orderMaster.IsAutoStart = true;//baseFlowMaster.IsAutoStart; orderMaster.IsAutoShip = true;//baseFlowMaster.IsAutoShip; orderMaster.IsInspect = baseFlowMaster.IsInspect; orderMaster.IsPrintAsn = baseFlowMaster.IsPrintAsn; orderMaster.IsPrintOrder = baseFlowMaster.IsPrintOrder; orderMaster.IsPrintReceipt = baseFlowMaster.IsPrintRceipt; orderMaster.IsShipByOrder = baseFlowMaster.IsShipByOrder; orderMaster.OrderTemplate = baseFlowMaster.OrderTemplate; orderMaster.AsnTemplate = baseFlowMaster.AsnTemplate; orderMaster.ReceiptTemplate = baseFlowMaster.ReceiptTemplate; orderMaster.IsShipFifo = baseFlowMaster.IsShipFifo; orderMaster.IsAsnUniqueReceive = baseFlowMaster.IsAsnUniqueReceive; if (!string.IsNullOrWhiteSpace(baseFlowMaster.ShipFrom)) { var shipFrom = this.genericMgr.FindById<Address>(baseFlowMaster.ShipFrom); orderMaster.ShipFrom = shipFrom.Code; orderMaster.ShipFromAddress = shipFrom.AddressContent; orderMaster.ShipFromCell = shipFrom.MobilePhone; orderMaster.ShipFromTel = shipFrom.TelPhone; orderMaster.ShipFromFax = shipFrom.Fax; orderMaster.ShipFromContact = shipFrom.ContactPersonName; } if (!string.IsNullOrWhiteSpace(baseFlowMaster.ShipTo)) { var shipTo = this.genericMgr.FindById<Address>(baseFlowMaster.ShipTo); orderMaster.ShipTo = shipTo.Code; orderMaster.ShipToAddress = shipTo.AddressContent; orderMaster.ShipToCell = shipTo.MobilePhone; orderMaster.ShipToTel = shipTo.TelPhone; orderMaster.ShipToFax = shipTo.Fax; orderMaster.ShipToContact = shipTo.ContactPersonName; } } else { var shipFrom = (this.genericMgr.FindAll<Address>( " select a from PartyAddress p join p.Address as a where p.Party = ? and p.Type =?", new object[] {orderMaster.PartyFrom, (int)CodeMaster.AddressType.ShipAddress }, 0, 1) ?? new List<Address>()).FirstOrDefault(); if (shipFrom != null) { orderMaster.ShipFrom = shipFrom.Code; orderMaster.ShipFromAddress = shipFrom.AddressContent; orderMaster.ShipFromCell = shipFrom.MobilePhone; orderMaster.ShipFromTel = shipFrom.TelPhone; orderMaster.ShipFromFax = shipFrom.Fax; orderMaster.ShipFromContact = shipFrom.ContactPersonName; } var shipTo = (this.genericMgr.FindAll<Address>( " select a from PartyAddress p join p.Address as a where p.Party = ? and p.Type =? ", new object[]{ orderMaster.PartyTo, (int)CodeMaster.AddressType.ShipAddress }, 0, 1) ?? new List<Address>()).FirstOrDefault(); if (shipTo != null) { orderMaster.ShipTo = shipTo.Code; orderMaster.ShipToAddress = shipTo.AddressContent; orderMaster.ShipToCell = shipTo.MobilePhone; orderMaster.ShipToTel = shipTo.TelPhone; orderMaster.ShipToFax = shipTo.Fax; orderMaster.ShipToContact = shipTo.ContactPersonName; } } orderMaster.OrderDetails = new List<Entity.ORD.OrderDetail>(); int seq = 1; var groupHus = this.genericMgr.FindAllIn<Hu>(" from Hu where HuId in(?", flowDetailInputList.Select(p => p.HuId)) .GroupBy(r => new { r.Item, r.Uom, r.Direction, r.UnitCount, r.BaseUom }); foreach (var groupHu in groupHus) { var baseOrderDetail = new Entity.ORD.OrderDetail(); baseOrderDetail.BaseUom = groupHu.Key.BaseUom; baseOrderDetail.Item = groupHu.Key.Item; baseOrderDetail.UnitCount = groupHu.Key.UnitCount; baseOrderDetail.Uom = groupHu.Key.Uom; baseOrderDetail.Direction = groupHu.Key.Direction; baseOrderDetail.ItemDescription = groupHu.First().ItemDescription; baseOrderDetail.OrderType = orderMaster.Type; baseOrderDetail.QualityType = orderMaster.QualityType; baseOrderDetail.Sequence = seq++; baseOrderDetail.OrderDetailInputs = new List<Entity.ORD.OrderDetailInput>(); foreach (var hu in groupHu) { var baseOrderDetailInput = new Entity.ORD.OrderDetailInput(); baseOrderDetailInput.HuId = hu.HuId; baseOrderDetailInput.ReceiveQty = hu.Qty; baseOrderDetailInput.Bin = flowMaster.Bin; baseOrderDetailInput.LotNo = hu.LotNo; baseOrderDetailInput.ShipQty = hu.Qty; baseOrderDetail.OrderDetailInputs.Add(baseOrderDetailInput); baseOrderDetail.RequiredQty += baseOrderDetailInput.ShipQty; baseOrderDetail.OrderedQty += baseOrderDetailInput.ShipQty; } orderMaster.OrderDetails.Add(baseOrderDetail); } this.orderMgr.CreateOrder(orderMaster); if (!string.IsNullOrWhiteSpace(flowMaster.Bin) && orderMaster.Status == CodeMaster.OrderStatus.Close) { var inventoryPutList = flowDetailInputList.Where(p => !string.IsNullOrWhiteSpace(p.HuId)) .Select(p => new InventoryPut { HuId = p.HuId, Bin = flowMaster.Bin }).ToList(); locationDetailMgr.InventoryPut(inventoryPutList); } }