Ejemplo n.º 1
0
        public IList <SupplyChain> GenerateSupplyChain(string flowCode, string itemCode)
        {
            IList <SupplyChain> supplyChainList = new List <SupplyChain>();
            Flow flow = FlowMgr.LoadFlow(flowCode, true);

            if (flow.FlowDetails != null && flow.FlowDetails.Count > 0)
            {
                foreach (FlowDetail flowDetail in flow.FlowDetails)
                {
                    if (flowDetail.Item.Code == itemCode)
                    {
                        supplyChainList.Add(this.GenerateSupplyChain(flowDetail));
                    }
                }
            }
            else
            {
                if (flow.ReferenceFlow != null && flow.ReferenceFlow.Trim() != string.Empty)
                {
                    Flow refFlow = this.FlowMgr.LoadFlow(flow.ReferenceFlow, true);
                    if (refFlow.FlowDetails != null && refFlow.FlowDetails.Count > 0)
                    {
                        foreach (FlowDetail flowDetail in refFlow.FlowDetails)
                        {
                            if (flowDetail.Item.Code == itemCode)
                            {
                                supplyChainList.Add(this.GenerateSupplyChain(flow, flowDetail));
                            }
                        }
                    }
                }
            }

            return(supplyChainList);
        }
Ejemplo n.º 2
0
        public IList <FlowDetail> GetBindedFlowDetail(int orderDetailId, string slaveFlowCode)
        {
            OrderDetail        orderDetail = this.orderDetailMgr.LoadOrderDetail(orderDetailId);
            IList <FlowDetail> returnList  = new List <FlowDetail>();

            IList <OrderLocationTransaction> orderLocTransList =
                this.orderDetailMgr.LoadOrderDetail(orderDetail.Id, true).OrderLocationTransactions;

            Flow flow = flowMgr.LoadFlow(slaveFlowCode, true, true);
            IList <FlowDetail> flowDetailList = flow.FlowDetails;

            //记录已经被绑定的路线明细,避免采购绑定销售的时候重复累加数量
            //(因为百利得有内部销售的需求,所以现在双方都没有目的库位也可以绑定,这就造成采购绑定销售的时候重复累加数量)
            IDictionary <int, FlowDetail> bindedFlowDetail = new Dictionary <int, FlowDetail>();

            if (orderLocTransList != null && orderLocTransList.Count > 0 && flowDetailList.Count > 0)
            {
                foreach (OrderLocationTransaction orderLocTrans in orderLocTransList)
                {
                    //if (orderLocTrans.Location == null)
                    //{
                    //    continue;
                    //}

                    string itemCode     = orderLocTrans.Item.Code;
                    string locationCode = orderLocTrans.Location != null ? orderLocTrans.Location.Code : null;

                    foreach (FlowDetail flowDetail in flowDetailList)
                    {
                        if (bindedFlowDetail.ContainsKey(flowDetail.Id))
                        {
                            continue;
                        }

                        if (itemCode.Trim().ToUpper() != flowDetail.Item.Code.Trim().ToUpper())
                        {
                            continue;
                        }

                        Location fromLoc = null;
                        Location toLoc   = null;
                        if (flowDetail.Flow.Code.Trim().ToUpper() == slaveFlowCode.Trim().ToUpper())
                        {
                            fromLoc = flowDetail.DefaultLocationFrom;
                            toLoc   = flowDetail.DefaultLocationTo;
                        }
                        else
                        {
                            //reference flow
                            fromLoc = flow.LocationFrom;
                            toLoc   = flow.LocationTo;
                        }

                        if (orderLocTrans.IOType == BusinessConstants.IO_TYPE_IN)
                        {
                            //Master LocationTo == Slave LocationFrom
                            //if (fromLoc == null)
                            //{
                            //    continue;
                            //}

                            if ((fromLoc == null && locationCode == null) ||
                                (fromLoc != null && locationCode != null && fromLoc.Code.Trim().ToUpper() == locationCode.Trim().ToUpper()))
                            {
                                bindedFlowDetail.Add(flowDetail.Id, flowDetail);
                                decimal orderedQty = orderLocTrans.OrderedQty;
                                if (flowDetail.Uom.Code != orderLocTrans.Uom.Code)
                                {
                                    orderedQty = uomConversionMgr.ConvertUomQty(flowDetail.Item, orderLocTrans.Uom, orderLocTrans.OrderedQty, flowDetail.Uom);
                                }
                                flowDetail.OrderedQty += orderedQty;

                                if (!returnList.Contains(flowDetail))
                                {
                                    returnList.Add(flowDetail);
                                }
                            }
                        }
                        else
                        {
                            //Master LocationFrom == Slave LocationTo
                            //if (toLoc == null)
                            //{
                            //    continue;
                            //}

                            if ((toLoc == null && locationCode == null) ||
                                (toLoc != null && locationCode != null && toLoc.Code.Trim().ToUpper() == locationCode.Trim().ToUpper()))
                            {
                                bindedFlowDetail.Add(flowDetail.Id, flowDetail);
                                decimal orderedQty = orderLocTrans.OrderedQty;
                                if (flowDetail.Uom.Code != orderLocTrans.Uom.Code)
                                {
                                    orderedQty = uomConversionMgr.ConvertUomQty(flowDetail.Item, orderLocTrans.Uom, orderLocTrans.OrderedQty, flowDetail.Uom);
                                }
                                flowDetail.OrderedQty += orderedQty;

                                if (!returnList.Contains(flowDetail))
                                {
                                    returnList.Add(flowDetail);
                                }
                            }
                        }
                    }
                }
            }

            return(returnList);
        }