예제 #1
0
        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))
            {
                //
            }
        }
예제 #2
0
        public void DoAnDon(List<AnDonInput> anDonInputList)
        {
            List<string> flowCodeList = anDonInputList.Select(a => a.Flow).Distinct().ToList();
            foreach (var flowCode in flowCodeList)
            {
                //string flowCode = anDonInputList.Select(a => a.Flow).Distinct().Single();

                Entity.SCM.FlowMaster flowMaster = this.genericMgr.FindById<Entity.SCM.FlowMaster>(flowCode);
                Entity.ORD.OrderMaster orderMaster = orderMgr.TransferFlow2Order(flowMaster, anDonInputList.Select(a => a.Item).Distinct().ToList());
                orderMaster.StartTime = DateTime.Now;

                FlowStrategy flowStrategy = genericMgr.FindById<FlowStrategy>(flowCode);
                orderMaster.WindowTime = orderMaster.StartTime.AddHours((double)flowStrategy.LeadTime);
                orderMaster.IsAutoRelease = true;

                foreach (AnDonInput anDonInput in anDonInputList)
                {
                    Entity.ORD.OrderDetail orderDetail = orderMaster.OrderDetails != null ?
                        orderMaster.OrderDetails.Where(f => (f.LocationTo == anDonInput.LocationTo || (string.IsNullOrWhiteSpace(f.LocationTo) && flowMaster.LocationTo == anDonInput.LocationTo))
                        && f.Item == anDonInput.Item && f.UnitCount == anDonInput.UnitCount
                        && f.Uom == anDonInput.Uom && f.ManufactureParty == anDonInput.ManufactureParty).OrderBy(f => f.Sequence).FirstOrDefault() : null;

                    if (orderDetail != null)
                    {
                        orderDetail.RequiredQty += anDonInput.UnitCount;
                        orderDetail.OrderedQty += anDonInput.UnitCount;
                    }
                    else
                    {
                        orderDetail = new Entity.ORD.OrderDetail();
                        orderDetail.OrderType = orderMaster.Type;
                        orderDetail.OrderSubType = orderMaster.SubType;
                        //orderDetail.Sequence  = ;
                        Entity.MD.Item item = this.genericMgr.FindById<Entity.MD.Item>(anDonInput.Item);
                        orderDetail.Item = item.Code;
                        orderDetail.ItemDescription = item.Description;
                        orderDetail.ReferenceItemCode = item.ReferenceCode;
                        orderDetail.BaseUom = item.Uom;
                        orderDetail.Uom = anDonInput.Uom;
                        //orderDetail.PartyFrom=
                        orderDetail.UnitCount = anDonInput.UnitCount;
                        //orderDetail.UnitCountDescription=
                        //orderDetail.MinUnitCount=
                        orderDetail.QualityType = CodeMaster.QualityType.Qualified;
                        orderDetail.ManufactureParty = anDonInput.ManufactureParty;
                        orderDetail.RequiredQty += anDonInput.UnitCount;
                        orderDetail.OrderedQty += anDonInput.UnitCount;
                        //orderDetail.ShippedQty = ;
                        //orderDetail.ReceivedQty = ;
                        //orderDetail.RejectedQty = ;
                        //orderDetail.ScrapQty = ;
                        //orderDetail.PickedQty = ;
                        if (orderDetail.BaseUom != orderDetail.Uom)
                        {
                            orderDetail.UnitQty = this.itemMgr.ConvertItemUomQty(orderDetail.Item, orderDetail.BaseUom, 1, orderDetail.Uom);
                        }
                        else
                        {
                            orderDetail.UnitQty = 1;
                        }
                        //public string LocationFrom { get; set; }
                        //public string LocationFromName { get; set; }
                        Entity.MD.Location locationTo = this.genericMgr.FindById<Entity.MD.Location>(anDonInput.LocationTo);
                        orderDetail.LocationTo = locationTo.Code;
                        orderDetail.LocationToName = locationTo.Name;
                        orderDetail.IsInspect = false;
                        //public string Container { get; set; }
                        //public string ContainerDescription { get; set; }
                        //public Boolean IsScanHu { get; set; }
                        orderDetail.BinTo = anDonInput.Note;

                        orderMaster.AddOrderDetail(orderDetail);
                    }
                }

                this.orderMgr.CreateOrder(orderMaster);
            }
        }
예제 #3
0
        //生产线退库,把数量变为条码移库
        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);
        }
예제 #4
0
        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);
            }
        }