示例#1
0
        public SupplyChain GenerateSupplyChain(Flow flow, FlowDetail flowDetail)
        {
            SupplyChain supplyChain = new SupplyChain();

            supplyChain.Flow       = flow;
            supplyChain.FlowDetail = flowDetail;

            SupplyChainDetail supplyChainDetail = new SupplyChainDetail();

            supplyChainDetail.SupplyChain = supplyChain;
            supplyChainDetail.Id          = 1;
            supplyChainDetail.ParentId    = 0;
            supplyChainDetail.Flow        = flow;
            supplyChainDetail.FlowDetail  = flowDetail;
            supplyChainDetail.LocationTo  = flowDetail.DefaultLocationTo == null ? null : flowDetail.DefaultLocationTo;
            supplyChainDetail.QuantityPer = 1;

            IList <SupplyChainDetail> supplyChainDetailList = new List <SupplyChainDetail>();

            supplyChainDetailList.Add(supplyChainDetail);
            this.GetSupplyChainDetail(supplyChainDetailList, supplyChainDetail);

            supplyChain.AddRangeSupplyChainDetail(supplyChainDetailList);
            return(supplyChain);
        }
示例#2
0
        private void FillSupplyChainDetail(IList <SupplyChainDetail> supplyChainDetailList, SupplyChainDetail parentSupplyChainDetail, IList <FlowDetail> flowDetailList, decimal QtyPer, string locFrom)
        {
            SupplyChainDetail supplyChainDetail = new SupplyChainDetail();

            if (flowDetailList != null && flowDetailList.Count > 0)
            {
                foreach (FlowDetail flowDetail in flowDetailList)
                {
                    supplyChainDetail             = new SupplyChainDetail();
                    supplyChainDetail.SupplyChain = parentSupplyChainDetail.SupplyChain;
                    supplyChainDetail.Id          = supplyChainDetailList.Count + 1;
                    supplyChainDetail.ParentId    = parentSupplyChainDetail.Id;
                    supplyChainDetail.Flow        = flowDetail.Flow;
                    supplyChainDetail.FlowDetail  = flowDetail;
                    supplyChainDetail.LocationTo  = flowDetail.DefaultLocationTo == null ? null : flowDetail.DefaultLocationTo;
                    supplyChainDetail.QuantityPer = QtyPer;

                    if (supplyChainDetailList.Contains(supplyChainDetail))
                    {
                        return;
                    }
                    else
                    {
                        supplyChainDetailList.Add(supplyChainDetail);
                        this.GetSupplyChainDetail(supplyChainDetailList, supplyChainDetail);
                    }

                    IList <Flow> flowList = this.GetReferenceFlow(flowDetail, locFrom);
                    if (flowList != null && flowList.Count > 0)
                    {
                        //ReferenceFlow
                        foreach (Flow flow in flowList)
                        {
                            if (flow.ReferenceFlow != null && flow.ReferenceFlow == flowDetail.Flow.Code)
                            {
                                supplyChainDetail             = new SupplyChainDetail();
                                supplyChainDetail.SupplyChain = parentSupplyChainDetail.SupplyChain;
                                supplyChainDetail.Id          = supplyChainDetailList.Count + 1;
                                supplyChainDetail.ParentId    = parentSupplyChainDetail.Id;
                                supplyChainDetail.Flow        = flow;
                                supplyChainDetail.FlowDetail  = flowDetail;
                                supplyChainDetail.LocationTo  = flowDetail.DefaultLocationTo == null ? null : flowDetail.DefaultLocationTo;
                                supplyChainDetail.QuantityPer = QtyPer;

                                if (supplyChainDetailList.Contains(supplyChainDetail))
                                {
                                    return;
                                }
                                else
                                {
                                    supplyChainDetailList.Add(supplyChainDetail);
                                    this.GetSupplyChainDetail(supplyChainDetailList, supplyChainDetail);
                                }
                            }
                        }
                    }
                }
            }
        }
示例#3
0
    private void GenChildOrgNode(MyOrgNode RootNode)
    {
        SupplyChainDetail supplyChainDetail = supplyChainDetailList[0];

        RootNode.Code         = supplyChainDetail.Flow.PartyTo.Name;
        RootNode.Name         = supplyChainDetail.LocationTo == null ? string.Empty : supplyChainDetail.LocationTo.Name;
        RootNode.Memo1        = supplyChainDetail.FlowDetail.Item.Code;
        RootNode.Memo1Tooltip = supplyChainDetail.FlowDetail.Item.Description;
        RootNode.Memo2        = supplyChainDetail.Flow.Description;
        RootNode.Memo2Tooltip = supplyChainDetail.Flow.Code;
        createChildNode(RootNode, supplyChainDetail.Id);
    }
示例#4
0
        private bool CheckSupplyChainDetailEnd(SupplyChainDetail supplyChainDetail, IList <SupplyChainDetail> supplyChainDetailList)
        {
            if (supplyChainDetailList != null && supplyChainDetailList.Count > 0)
            {
                foreach (SupplyChainDetail scd in supplyChainDetailList)
                {
                    if (scd.ParentId == supplyChainDetail.Id)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#5
0
        private bool CheckSupplyChainDetailItemExist(SupplyChainDetail supplyChainDetail, IList <SupplyChainDetail> supplyChainDetailList)
        {
            if (supplyChainDetailList != null && supplyChainDetailList.Count > 0)
            {
                foreach (SupplyChainDetail scd in supplyChainDetailList)
                {
                    if (scd.FlowDetail.Item.Code.ToLower() == supplyChainDetail.FlowDetail.Item.Code.ToLower())
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#6
0
        private string GetLocFrom(SupplyChainDetail supplyChainDetail)
        {
            string locFrom = null;

            if (supplyChainDetail.Flow.Code == supplyChainDetail.FlowDetail.Flow.Code)
            {
                locFrom = supplyChainDetail.FlowDetail.DefaultLocationFrom == null ? null : supplyChainDetail.FlowDetail.DefaultLocationFrom.Code;
            }
            else
            {
                //ReferenceFlow
                locFrom = supplyChainDetail.Flow.LocationFrom == null ? null : supplyChainDetail.Flow.LocationFrom.Code;
            }

            return(locFrom);
        }
示例#7
0
        private void GetSupplyChainDetail(IList <SupplyChainDetail> supplyChainDetailList, SupplyChainDetail parentSupplyChainDetail)
        {
            if (parentSupplyChainDetail.Flow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)
            {
                string            bomCode       = this.GetBomCode(parentSupplyChainDetail.FlowDetail);
                IList <BomDetail> bomDetailList = BomDetailMgr.GetFlatBomDetail(bomCode, DateTime.Now);
                if (bomDetailList != null && bomDetailList.Count > 0)
                {
                    foreach (BomDetail bomDetail in bomDetailList)
                    {
                        string itemCode = bomDetail.Item.Code;
                        string locFrom  = string.Empty;
                        if (bomDetail.Location != null)
                        {
                            locFrom = bomDetail.Location.Code;
                        }
                        else
                        {
                            if (parentSupplyChainDetail.FlowDetail.DefaultLocationFrom == null)
                            {
                                //end
                                continue;
                            }
                            else
                            {
                                locFrom = parentSupplyChainDetail.FlowDetail.DefaultLocationFrom.Code;
                            }
                        }
                        decimal QtyPer = bomDetail.RateQty * (1 + bomDetail.ScrapPercentage);

                        IList <FlowDetail> flowDetailList = this.GetFlowDetailList(itemCode, locFrom);
                        this.FillSupplyChainDetail(supplyChainDetailList, parentSupplyChainDetail, flowDetailList, QtyPer, locFrom);
                    }
                }
            }
            else
            {
                string locFrom = this.GetLocFrom(parentSupplyChainDetail);
                if (locFrom != null)
                {
                    decimal            QtyPer         = 1;
                    IList <FlowDetail> flowDetailList = this.GetFlowDetailList(parentSupplyChainDetail.FlowDetail.Item.Code, locFrom);
                    this.FillSupplyChainDetail(supplyChainDetailList, parentSupplyChainDetail, flowDetailList, QtyPer, locFrom);
                }
            }
        }