Пример #1
0
        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);
            }
        }
Пример #2
0
 public void DoRePack(List<string> oldHuList, List<string> newHuList, DateTime? effDate)
 {
     if (oldHuList == null || newHuList.Count == 0)
     {
         throw new Entity.Exception.BusinessException("没有翻箱前的明细");
     }
     if (newHuList == null || newHuList.Count == 0)
     {
         throw new Entity.Exception.BusinessException("没有翻箱后的明细");
     }
     var inventoryPackList = new List<Entity.INV.InventoryRePack>();
     foreach (var huId in oldHuList)
     {
         var inventoryUnPack = new Entity.INV.InventoryRePack();
         inventoryUnPack.HuId = huId;
         inventoryUnPack.Type = CodeMaster.RePackType.Out;
         inventoryPackList.Add(inventoryUnPack);
     }
     foreach (var huId in newHuList)
     {
         var inventoryUnPack = new Entity.INV.InventoryRePack();
         inventoryUnPack.HuId = huId;
         inventoryUnPack.Type = CodeMaster.RePackType.In;
         inventoryPackList.Add(inventoryUnPack);
     }
     if (effDate.HasValue)
     {
         locationDetailMgr.InventoryRePack(inventoryPackList, effDate.Value);
     }
     else
     {
         locationDetailMgr.InventoryRePack(inventoryPackList);
     }
 }