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 KitOrderOfflineAndFeed(string kitOrderNo) { IList<OrderDetail> orderDetailList = this.genericMgr.FindAll<OrderDetail>("from OrderDetail where OrderNo = ?", kitOrderNo); foreach (OrderDetail orderDetail in orderDetailList) { if (orderDetail.IsScanHu) { throw new BusinessException("分装生产单{0}含有关键件,不能下线并投料。", kitOrderNo); } else { Entity.ORD.OrderDetailInput orderDetailInput = new Entity.ORD.OrderDetailInput(); orderDetailInput.ReceiveQty = orderDetail.OrderedQty; orderDetail.AddOrderDetailInput(orderDetailInput); } } IList<string> orderNoList = this.genericMgr.FindAll<string>("select OrderNo from OrderBinding where BindOrderNo = ?", kitOrderNo); if (orderNoList != null && orderNoList.Count > 0) { if (orderNoList.Count > 1) { throw new BusinessException("分装生产单{0}的母生产单数量大于1。", kitOrderNo); } else { DateTime dateTimeNow = DateTime.Now; KitOrderOffline(orderDetailList, null, false, dateTimeNow); this.productionLineMgr.FeedKitOrder(orderNoList[0], kitOrderNo, false, dateTimeNow); } } else { throw new BusinessException("分装生产单{0}没有要投料的母生产单。", kitOrderNo); } }
public void DoRepackAndShipOrder(List<Entity.SD.INV.Hu> huList, DateTime? effDate) { List<Entity.SD.ORD.OrderDetailInput> orderDetailInputList = new List<OrderDetailInput>(); foreach (var hu in huList) { var orderDetailInput = new OrderDetailInput(); orderDetailInput.HuId = hu.HuId; orderDetailInput.LotNo = hu.LotNo; orderDetailInput.ShipQty = hu.Qty; orderDetailInput.Id = hu.OrderDetId; orderDetailInputList.Add(orderDetailInput); } IList<Entity.ORD.OrderDetail> baseOrderDetailList = new List<Entity.ORD.OrderDetail>(); var ids = orderDetailInputList.Select(o => o.Id).Distinct(); foreach (var id in ids) { var baseOrderDatail = genericMgr.FindById<Entity.ORD.OrderDetail>(id); var selectedOrderDetailInputList = orderDetailInputList.Where(o => o.Id == id); if (selectedOrderDetailInputList != null) { baseOrderDatail.OrderDetailInputs = new List<Entity.ORD.OrderDetailInput>(); foreach (var orderDetailInput in selectedOrderDetailInputList) { Entity.ORD.OrderDetailInput baseOrderDetailInput = new Entity.ORD.OrderDetailInput(); baseOrderDetailInput.HuId = orderDetailInput.HuId; //翻包 HuMapping huMapping = this.genericMgr.FindAll<HuMapping>("select h from HuMapping as h where HuId = ?", orderDetailInput.HuId).SingleOrDefault(); if (huMapping.IsEffective == false) { IList<HuMapping> huMappingList = this.genericMgr.FindAll<HuMapping>("select h from HuMapping as h where OldHus = ?", huMapping.OldHus); var inventoryPackList = new List<Entity.INV.InventoryRePack>(); foreach (var huId in huMappingList.Select(h => h.HuId)) { var inventoryUnPack = new Entity.INV.InventoryRePack(); inventoryUnPack.HuId = huId; inventoryUnPack.Type = CodeMaster.RePackType.In; inventoryPackList.Add(inventoryUnPack); } foreach (var huId in huMappingList.FirstOrDefault().OldHus.Split(new char[] { ';' })) { if (!string.IsNullOrEmpty(huId)) { var inventoryUnPack = new Entity.INV.InventoryRePack(); inventoryUnPack.HuId = huId; inventoryUnPack.Type = CodeMaster.RePackType.Out; inventoryPackList.Add(inventoryUnPack); } } foreach (var hum in huMappingList) { hum.IsEffective = true; this.genericMgr.Update(hum); } locationDetailMgr.InventoryRePack(inventoryPackList, false, effDate.HasValue ? effDate.Value : DateTime.Now); //else //{ // var inventoryPackList = new List<Entity.INV.InventoryRePack>(); // var inventoryPacked = new Entity.INV.InventoryRePack(); // inventoryPacked.HuId = huMapping.HuId; // inventoryPacked.Type = CodeMaster.RePackType.Out; // inventoryPackList.Add(inventoryPacked); // var inventoryUnPack = new Entity.INV.InventoryRePack(); // inventoryUnPack.HuId = huMapping.OldHus; // inventoryUnPack.Type = CodeMaster.RePackType.In; // inventoryPackList.Add(inventoryUnPack); // locationDetailMgr.InventoryRePack(inventoryPackList); //} } baseOrderDetailInput.ShipQty = orderDetailInput.ShipQty; baseOrderDetailInput.LotNo = orderDetailInput.LotNo; baseOrderDatail.OrderDetailInputs.Add(baseOrderDetailInput); } } baseOrderDetailList.Add(baseOrderDatail); } if (effDate.HasValue) { this.orderMgr.ShipOrder(baseOrderDetailList, effDate.Value); } else { this.orderMgr.ShipOrder(baseOrderDetailList); } }
//[Transaction(TransactionMode.Requires)] //public IList<IpDetailInput> GetIpDetailInputByPickHu(string pickHu) //{ // IList<com.Sconit.Entity.ORD.IpLocationDetail> ipLocationDetail = genericMgr.FindAll<com.Sconit.Entity.ORD.IpLocationDetail>("select i from IpLocationDetail where i.WMSSeq = ?", pickHu); // if (ipLocationDetail != null && ipLocationDetail.Count == 1) // { // com.Sconit.Entity.ORD.IpDetail ipDetail = genericMgr.FindById<com.Sconit.Entity.ORD.IpDetail>(ipLocationDetail[0].IpDetailId); // var sdIpDetail = Mapper.Map<Entity.ORD.IpDetail, Entity.SD.ORD.IpDetail>(ipDetail); // } //} public void DoReceiveOrder(List<Entity.SD.ORD.OrderDetailInput> orderDetailInputList, DateTime? effDate) { if (orderDetailInputList == null || orderDetailInputList.Count == 0) { throw new com.Sconit.Entity.Exception.BusinessException("没有要收货的明细"); } IList<Entity.ORD.OrderDetail> orderDetailList = new List<Entity.ORD.OrderDetail>(); var ids = orderDetailInputList.Select(o => o.Id).Distinct(); foreach (var id in ids) { var baseOrderDatail = genericMgr.FindById<Entity.ORD.OrderDetail>(id); var selectedrderDetailInputList = orderDetailInputList.Where(o => o.Id == id); if (selectedrderDetailInputList != null) { baseOrderDatail.OrderDetailInputs = new List<Entity.ORD.OrderDetailInput>(); foreach (var orderDetailInput in selectedrderDetailInputList) { Entity.ORD.OrderDetailInput baseOrderDetailInput = new Entity.ORD.OrderDetailInput(); baseOrderDetailInput.HuId = orderDetailInput.HuId; baseOrderDetailInput.ReceiveQty = orderDetailInput.ReceiveQty; baseOrderDetailInput.LotNo = orderDetailInput.LotNo; baseOrderDetailInput.Bin = orderDetailInput.Bin; baseOrderDatail.OrderDetailInputs.Add(baseOrderDetailInput); } } orderDetailList.Add(baseOrderDatail); } if (effDate.HasValue) { this.orderMgr.ReceiveOrder(orderDetailList, effDate.Value); } else { this.orderMgr.ReceiveOrder(orderDetailList); } }
//生产线退库,把数量变为条码移库 public void DoReturnOrder(string flowCode, List<string> huIdList, DateTime? effectiveDate) { if (huIdList == null || huIdList.Count == 0) { throw new BusinessException("退库条码不能为空。"); } IList<com.Sconit.Entity.VIEW.HuStatus> huStatusList = this.huMgr.GetHuStatus(huIdList); FlowMaster flowMaster = this.genericMgr.FindById<FlowMaster>(flowCode); FlowMaster returnflowMaster = this.flowMgr.GetReverseFlow(flowMaster, huStatusList.Select(h => h.Item).Distinct().ToList()); com.Sconit.Entity.ORD.OrderMaster orderMaster = this.orderMgr.TransferFlow2Order(returnflowMaster, null); orderMaster.StartTime = DateTime.Now; orderMaster.WindowTime = DateTime.Now; orderMaster.EffectiveDate = effectiveDate.HasValue ? effectiveDate : DateTime.Now; orderMaster.IsQuick = true; //orderMaster.IsAutoRelease = true; //orderMaster.IsAutoShip = false; //orderMaster.IsAutoReceive = true; orderMaster.IsShipScanHu = true; orderMaster.IsReceiveScanHu = true; IList<InventoryPack> inventoryPackList = new List<InventoryPack>(); BusinessException businessException = new BusinessException(); foreach (com.Sconit.Entity.VIEW.HuStatus huStatus in huStatusList) { if (huStatus.Status == CodeMaster.HuStatus.Ip) { businessException.AddMessage("条码{0}为库位{1}至库位{2}的在途库存,不能退库。", huStatus.HuId, huStatus.LocationFrom, huStatus.LocationTo); } else if (huStatus.Status == CodeMaster.HuStatus.Location) { businessException.AddMessage("条码{0}已经在库位{1}中,不能装箱。", huStatus.HuId, huStatus.Location); } else { InventoryPack inventoryPack = new InventoryPack(); inventoryPack.Location = returnflowMaster.LocationFrom; inventoryPack.HuId = huStatus.HuId; inventoryPack.OccupyType = CodeMaster.OccupyType.None; inventoryPack.OccupyReferenceNo = null; inventoryPackList.Add(inventoryPack); } } if (businessException.HasMessage) { throw businessException; } //先装箱 this.locationDetailMgr.InventoryPack(inventoryPackList); var groupedHuList = from hu in huStatusList group hu by new { Item = hu.Item, ItemDescription = hu.ItemDescription, ReferenceItemCode = hu.ReferenceItemCode, Uom = hu.Uom, BaseUom = hu.BaseUom, UnitQty = hu.UnitQty, UnitCount = hu.UnitCount } into gj select new { Item = gj.Key.Item, ItemDescription = gj.Key.ItemDescription, ReferenceItemCode = gj.Key.ReferenceItemCode, Uom = gj.Key.Uom, BaseUom = gj.Key.BaseUom, UnitQty = gj.Key.UnitQty, UnitCount = gj.Key.UnitCount, Qty = gj.Sum(hu => hu.Qty), List = gj.ToList() }; foreach (var groupedHu in groupedHuList) { Entity.ORD.OrderDetail orderDetail = new Entity.ORD.OrderDetail(); orderDetail.OrderNo = orderMaster.OrderNo; orderDetail.OrderType = orderMaster.Type; orderDetail.OrderSubType = orderMaster.SubType; orderDetail.Item = groupedHu.Item; orderDetail.ItemDescription = groupedHu.ItemDescription; orderDetail.ReferenceItemCode = groupedHu.ReferenceItemCode; orderDetail.Uom = groupedHu.Uom; orderDetail.BaseUom = groupedHu.BaseUom; orderDetail.UnitQty = groupedHu.UnitQty; orderDetail.UnitCount = groupedHu.UnitCount; orderDetail.QualityType = CodeMaster.QualityType.Qualified; orderDetail.RequiredQty = groupedHu.Qty; orderDetail.OrderedQty = groupedHu.Qty; orderMaster.AddOrderDetail(orderDetail); foreach (com.Sconit.Entity.VIEW.HuStatus huStatus in groupedHu.List) { Entity.ORD.OrderDetailInput orderDetailInput = new Entity.ORD.OrderDetailInput(); orderDetailInput.HuId = huStatus.HuId; orderDetailInput.ReceiveQty = huStatus.Qty; orderDetailInput.LotNo = huStatus.LotNo; orderDetail.AddOrderDetailInput(orderDetailInput); } } this.orderMgr.CreateOrder(orderMaster); }
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); } }
public void DoReceiveProdOrder(List<string> huIdList) { var huStatusList = huMgr.GetHuStatus(huIdList); foreach (var huStatus in huStatusList) { if (huStatus.Status == CodeMaster.HuStatus.Location || huStatus.Status == CodeMaster.HuStatus.Ip) { throw new BusinessException("此条码已在库存中"); } if (string.IsNullOrWhiteSpace(huStatus.OrderNo)) { throw new BusinessException("此条码没有带生产单号,不能收货"); } } var orderMasters = this.genericMgr.FindEntityWithNativeSqlIn<Entity.ORD.OrderMaster> ("select * from ORD_OrderMstr_4 where OrderNo in(? ", huStatusList.Select(p => p.OrderNo).Distinct()); if (orderMasters == null || orderMasters.Count() == 0) { throw new BusinessException("没有找到生产单"); } foreach (var orderMaster in orderMasters) { if (orderMaster.Status != CodeMaster.OrderStatus.InProcess) { throw new BusinessException("状态不是执行中的生产单{0}不能收货", orderMaster.OrderNo); } else if (!Utility.SecurityHelper.HasPermission(orderMaster.Type, orderMaster.IsCheckPartyFromAuthority, orderMaster.IsCheckPartyToAuthority, orderMaster.PartyFrom, orderMaster.PartyTo, false, false)) { throw new BusinessException("没有此生产单{0}的权限", orderMaster.OrderNo); } } foreach (var orderMaster in orderMasters) { var huStatusList_OrderNo = huStatusList.Where(p => p.OrderNo == orderMaster.OrderNo); var orderDetails = this.genericMgr.FindEntityWithNativeSqlIn<Entity.ORD.OrderDetail> ("select * from ORD_OrderDet_4 where OrderNo=? and Item in(? ", huStatusList_OrderNo.Select(p => p.Item).Distinct(), new object[] { orderMaster.OrderNo }); foreach (var huStatus in huStatusList_OrderNo) { var orderDetail = orderDetails.FirstOrDefault(o => o.Item == huStatus.Item && o.Uom == huStatus.Uom && o.UnitCount == huStatus.UnitCount); if (orderDetail == null) { orderDetail = orderDetails.FirstOrDefault(o => o.Item == huStatus.Item && o.Uom == huStatus.Uom); } if (orderDetail == null) { throw new BusinessException("没有找到条码{0}对应的生产单明细", huStatus.HuId); } else { if (orderDetail.RemainReceivedQty == 0 && !orderMaster.IsReceiveExceed) { throw new BusinessException("此生产单{0}不允许超收", orderMaster.OrderNo); } } var orderDetailInput = new Entity.ORD.OrderDetailInput(); orderDetailInput.HuId = huStatus.HuId; orderDetailInput.ReceiveQty = huStatus.Qty; orderDetailInput.LotNo = huStatus.LotNo; orderDetail.AddOrderDetailInput(orderDetailInput); } var receiptMaster = this.orderMgr.ReceiveOrder(orderDetails); var huList = this.genericMgr.FindAllIn<Entity.INV.Hu> (" from Hu where HuId in(? ", huStatusList_OrderNo.Select(p => p.HuId)); foreach (var hu in huList) { hu.ReceiptNo = receiptMaster.ReceiptNo; this.genericMgr.Update(hu); } } }
public Entity.SI.SD_INV.Hu DoReceiveProdOrder(string huId) { HuStatus huStatus = huMgr.GetHuStatus(huId); if (huStatus.Status == CodeMaster.HuStatus.Location || huStatus.Status == CodeMaster.HuStatus.Ip) { throw new BusinessException("此条码已在库存中"); } if (string.IsNullOrWhiteSpace(huStatus.OrderNo)) { throw new BusinessException("此条码没有带生产单号,不能收货"); } var orderMasters = this.genericMgr.FindEntityWithNativeSql<Entity.ORD.OrderMaster> ("select * from ORD_OrderMstr_4 where OrderNo = ? ", huStatus.OrderNo); var order = orderMasters.First(); if (orderMasters == null || orderMasters.Count == 0) { throw new BusinessException("没有找到此生产单"); } else if (orderMasters.First().Status != CodeMaster.OrderStatus.InProcess) { throw new BusinessException("状态不是执行中的生产单不能收货"); } else if (!Utility.SecurityHelper.HasPermission(order.Type, order.IsCheckPartyFromAuthority, order.IsCheckPartyToAuthority, order.PartyFrom, order.PartyTo, false, false)) { throw new BusinessException("没有此生产单的权限"); } var orderDetails = this.genericMgr.FindAllWithNativeSql<Entity.ORD.OrderDetail> ("select * from ORD_OrderDet_4 where OrderNo = ? ", huStatus.OrderNo); Entity.ORD.OrderDetail orderDetail = null; if (orderDetails != null && orderDetails.Count() > 0) { var orderDetail_1 = orderDetails.FirstOrDefault(o => o.Item == huStatus.Item && o.Uom == huStatus.Uom && o.UnitCount == huStatus.UnitCount); if (orderDetail == null) { orderDetail = orderDetails.FirstOrDefault(o => o.Item == huStatus.Item && o.Uom == huStatus.Uom); } else { orderDetail = orderDetail_1; } } if (orderDetail == null) { throw new BusinessException("没有找到对应的生产单明细"); } else { if (orderDetail.RemainReceivedQty == 0 && !orderMasters.First().IsReceiveExceed) { throw new BusinessException("此生产单不允许超收"); } } var orderDetailInput = new Entity.ORD.OrderDetailInput(); orderDetailInput.HuId = huStatus.HuId; orderDetailInput.ReceiveQty = huStatus.Qty; orderDetailInput.LotNo = huStatus.LotNo; orderDetail.AddOrderDetailInput(orderDetailInput); var receiptMaster = this.orderMgr.ReceiveOrder(new List<Entity.ORD.OrderDetail>() { orderDetail }); Entity.INV.Hu baseHu = this.genericMgr.FindById<Entity.INV.Hu>(huStatus.HuId); baseHu.ReceiptNo = receiptMaster.ReceiptNo; this.genericMgr.Update(baseHu); var hu = Mapper.Map<Entity.INV.Hu, Entity.SI.SD_INV.Hu>(baseHu); return hu; }
public void KitOrderOffline(string kitOrderNo, List<Entity.SI.SD_ORD.OrderDetailInput> orderDetailInputList, IList<string> feedKitOrderNoList, DateTime? effectiveDate) { //if (orderDetailInputList == null || orderDetailInputList.Count == 0) //{ // //} IList<Entity.ORD.OrderDetail> orderDetailList = this.genericMgr.FindAll<Entity.ORD.OrderDetail>("from OrderDetail where OrderNo = ?", kitOrderNo); var ids = orderDetailInputList.Select(o => o.Id).Distinct(); foreach (Entity.ORD.OrderDetail orderDetail in orderDetailList) { if (orderDetail.IsScanHu) { IList<Entity.SI.SD_ORD.OrderDetailInput> matchedOrderDetailInputList = orderDetailInputList.Where(input => input.Id == orderDetail.Id).ToList(); if (matchedOrderDetailInputList != null && matchedOrderDetailInputList.Count > 0) { foreach (Entity.SI.SD_ORD.OrderDetailInput matchedOrderDetailInput in matchedOrderDetailInputList) { if (!matchedOrderDetailInput.IsHuInLocation) { TryPackBarcode(matchedOrderDetailInput.HuId, orderDetail.LocationFrom); } Entity.ORD.OrderDetailInput orderDetailInput = new Entity.ORD.OrderDetailInput(); orderDetailInput.HuId = matchedOrderDetailInput.HuId; orderDetailInput.LotNo = matchedOrderDetailInput.LotNo; orderDetailInput.ReceiveQty = matchedOrderDetailInput.ReceiveQty; orderDetail.AddOrderDetailInput(orderDetailInput); } } else { throw new com.Sconit.Entity.Exception.BusinessException("没有扫描关键件{0}。", orderDetail.Item); } } else { Entity.ORD.OrderDetailInput orderDetailInput = new Entity.ORD.OrderDetailInput(); orderDetailInput.ReceiveQty = orderDetail.OrderedQty; orderDetail.AddOrderDetailInput(orderDetailInput); } } this.genericMgr.FlushSession(); this.orderMgr.KitOrderOffline(orderDetailList, feedKitOrderNoList, effectiveDate.HasValue ? effectiveDate.Value : DateTime.Now); }