public Dictionary <string, PlanningItem> GetPlanningReport(List <OrderVariable> orders)
        {
            Dictionary <string, PlanningItem> keyValuePairs = new Dictionary <string, PlanningItem>();
            List <List <OrderVariable> >      listOders     = new List <List <OrderVariable> >();

            listOders = ListOrdervariables(orders);
            List <SettingBOM>         listSettingBoms        = LoadingSettingBOMs();
            List <SettingManufacture> lisSettingManufactures = LoadingSettingManufacture();
            SFT_WIP sFT_WIP = new SFT_WIP();

            try
            {
                foreach (var order in listOders)
                {
                    PlanningItem pLanning = new PlanningItem();
                    pLanning.KeyProduct = order[0].Product;
                    // base on product to defind Dept

                    if (order[0].Product.Contains("BMH"))
                    {
                        pLanning.Client = "MH";
                    }
                    else
                    {
                        pLanning.Client = order[0].Product.Replace(order[0].ProductName, "").Substring(1);
                    }
                    // Define Shiment Plan of production
                    pLanning.shipmentPlans    = new List <ShipmentPlan>();
                    pLanning.needProduceQties = new List <NeedProduceQty>();
                    foreach (var or in order)
                    {
                        ShipmentPlan shipment = new ShipmentPlan();
                        shipment.ClientRequestDate = or.ClientRequestDate;
                        shipment.ClientCode        = or.ClientOrder;
                        shipment.DeliveryPlanQty   = or.ClientOrderQty;
                        shipment.NeedQty           = or.ClientOrderQty;
                        shipment.RemainDay         = (or.ClientRequestDate - DateTime.Now.Date).Days;
                        shipment.NeedQtyPerDay     = shipment.NeedQty / shipment.RemainDay;
                        shipment.OrderCode         = or.DDH;
                        pLanning.shipmentPlans.Add(shipment);

                        NeedProduceQty need = new NeedProduceQty();
                        need.ClientRequestDate = or.ClientRequestDate;
                        need.NeedQty           = or.ClientOrderQty;
                        need.RemainDay         = (or.ClientRequestDate - DateTime.Now.Date).Days;
                        need.NeedQtyPerDay     = need.NeedQty / need.RemainDay;
                        pLanning.needProduceQties.Add(need);
                    }
                    pLanning.TotalQty = pLanning.shipmentPlans.Select(d => d.DeliveryPlanQty).Sum();
                    pLanning._bom     = new BOM();
                    List <string> ListHENN = ListHENNofProduct(pLanning.KeyProduct);
                    if (ListHENN != null)
                    {
                        pLanning._bom.HEN         = new string[ListHENN.Count];
                        pLanning._bom.HENStock    = new double[ListHENN.Count];
                        pLanning._bom.StrHENStock = new string[ListHENN.Count];

                        for (int i = 0; i < ListHENN.Count; i++)
                        {
                            pLanning._bom.HEN [i] = ListHENN[i];

                            pLanning._bom.HENStock[i] = StockOfHENN(ListHENN[i]);
                        }
                    }
                    else
                    {
                        pLanning._bom.HEN         = new string[1];
                        pLanning._bom.HENStock    = new double[1];
                        pLanning._bom.StrHENStock = new string[1];
                    }
                    var _bom = listSettingBoms.Where(d => d.ProductName == pLanning.KeyProduct).ToList();
                    if (_bom.Count > 0)
                    {
                        pLanning._bom.QtyUnit = _bom[0].QtyInBox;
                        pLanning._bom.ToolQty = _bom[0].QtyTool;
                    }
                    pLanning.wip           = new Wip();
                    pLanning.wip.Warehouse = StockOfProduct(order[0].Product);

                    pLanning.production = new Production();
                    var _productItem = lisSettingManufactures.Where(d => d.ProductName == pLanning.KeyProduct).ToList();
                    if (_productItem.Count > 0)
                    {
                        pLanning.production.ProductionQty = _productItem[0].PlanQty;
                        pLanning.production.targetPeople  = _productItem[0].Workertarget;
                        pLanning.production.PeopleQty     = (pLanning.production.targetPeople == 0) ? 0: pLanning.production.ProductionQty / pLanning.production.targetPeople;
                    }
                    sFT_WIP = GetSFT_WIPofProducts(order[0].Product);

                    pLanning.wip.MQCQty       = sFT_WIP.MQC_Out_Available;
                    pLanning.wip.PQCQty       = sFT_WIP.PQC_In_Available + sFT_WIP.PQC_Out_Available;
                    pLanning.wip.StockInWHQTy = sFT_WIP.StockIntoWH;
                    pLanning.wip.TotalInWip   = pLanning.wip.MQCQty + pLanning.wip.PQCQty + pLanning.wip.StockInWHQTy;
                    pLanning.TotalShortage    = pLanning.TotalQty - pLanning.wip.Warehouse - pLanning.wip.TotalInWip;

                    Production pro = new Production();
                    pro = GetProductionFromProduct(pLanning.KeyProduct);

                    if (pro != null)
                    {
                        pLanning.production.QtyOld       = pro.QtyOld;
                        pLanning.production.targetShiftA = pro.targetShiftA;
                        pLanning.production.targetShiftB = pro.targetShiftB;
                    }
                    else

                    {
                        pLanning.production.QtyOld       = 0;
                        pLanning.production.targetShiftA = 0;
                        pLanning.production.targetShiftB = 0;
                    }
                    keyValuePairs.Add(pLanning.KeyProduct, pLanning);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(keyValuePairs);
        }
        public Dictionary <string, PlanningItem> GetPlanningReportbyDept(string dept, List <OrderVariable> orders)
        {
            Dictionary <string, PlanningItem> keyValuePairs = new Dictionary <string, PlanningItem>();
            List <List <OrderVariable> >      listOders     = new List <List <OrderVariable> >();

            listOders = ListOrdervariables(orders);

            try
            {
                foreach (var order in listOders)
                {
                    PlanningItem pLanning = new PlanningItem();

                    GetSemiFinishedgoods getSemiFinishedgoods = new GetSemiFinishedgoods();
                    pLanning.KeyProduct = order[0].Product;
                    pLanning.Unit       = order[0].Unit;
                    //  List<Accessory> ListAccessories = getAccessory.GetAccessories(pLanning.KeyProduct);

                    // base on product to defind Dept

                    if (order[0].Product.Contains("BMH") && order[0].DDH.Contains("B"))
                    {
                        pLanning.Client = "MH";
                    }
                    else if (order[0].Product.Contains("BWT") && order[0].DDH.Contains("B"))
                    {
                        pLanning.Client = "WT";
                    }
                    else if (order[0].Product.Contains("BFF") && order[0].DDH.Contains("B"))
                    {
                        pLanning.Client = "FF";
                    }
                    else if (order[0].Product.Contains("P25") || order[0].Product.Contains("P40") || order[0].Product.Contains("P259"))
                    {
                        pLanning.Client = "JAMAK";
                    }
                    else if (order[0].Product.Contains("P05") || order[0].Product.Contains("P111"))
                    {
                        pLanning.Client = "MH";
                    }
                    else if (order[0].Product.Contains("P117"))
                    {
                        pLanning.Client = "PTC";
                    }
                    else if (order[0].DDH.Contains("A"))
                    {
                        pLanning.Client = order[0].Product.Split('-').Count() > 0 ? order[0].Product.Split('-')[1] : "";
                    }
                    else
                    {
                        pLanning.Client = order[0].Product.Replace(order[0].ProductName, "").Substring(1);
                    }
                    // Define Shiment Plan of production
                    pLanning.shipmentPlans    = new List <ShipmentPlan>();
                    pLanning.needProduceQties = new List <NeedProduceQty>();
                    foreach (var or in order)
                    {
                        ShipmentPlan shipment = new ShipmentPlan();
                        shipment.ClientRequestDate = or.ClientRequestDate;
                        shipment.ClientCode        = or.ClientOrder;
                        shipment.DeliveryPlanQty   = or.DeliveryQty;
                        shipment.NeedQty           = or.ClientOrderQty;
                        shipment.RemainDay         = (or.ClientRequestDate - DateTime.Now.Date).Days;
                        shipment.NeedQtyPerDay     = shipment.NeedQty / shipment.RemainDay;
                        shipment.OrderCode         = or.DDH;
                        pLanning.shipmentPlans.Add(shipment);

                        NeedProduceQty need = new NeedProduceQty();
                        need.ClientRequestDate = or.ClientRequestDate;
                        need.NeedQty           = or.ClientOrderQty;
                        need.RemainDay         = (or.ClientRequestDate - DateTime.Now.Date).Days;
                        need.NeedQtyPerDay     = need.NeedQty / need.RemainDay;
                        pLanning.needProduceQties.Add(need);
                    }
                    pLanning.TotalQty = pLanning.shipmentPlans.Select(d => d.NeedQty).Sum();

                    pLanning.SemiFinishedGoods = new List <SemiFinishedGoods>();
                    if (dept == "B01-MH")
                    {
                        var StockSFT = getSemiFinishedgoods.GetStockGoodsONSFT(dept, pLanning.KeyProduct);
                        pLanning.SemiFinishedGoods.Add(StockSFT);
                    }
                    else if (dept == "B01-FF")
                    {
                        var StockSFT = getSemiFinishedgoods.GetStockGoodsONSFT(dept, pLanning.KeyProduct);
                        pLanning.SemiFinishedGoods.Add(StockSFT);
                    }
                    else if (dept == "A01-Gia Dung")
                    {
                        pLanning.SemiFinishedGoods = getSemiFinishedgoods.ListGetSemiFinishedGoods(dept, pLanning.KeyProduct, pLanning.TotalQty);
                    }
                    else if (dept == "A01-PTC")
                    {
                        pLanning.SemiFinishedGoods = getSemiFinishedgoods.ListGetSemiFinishedGoods(dept, pLanning.KeyProduct, pLanning.TotalQty);
                    }

                    keyValuePairs.Add(pLanning.KeyProduct, pLanning);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            return(keyValuePairs);
        }
示例#3
0
        public Dictionary <string, PlanningItem> GetPlanningReport(List <OrderVariable> orders)
        {
            Dictionary <string, PlanningItem> keyValuePairs = new Dictionary <string, PlanningItem>();
            List <List <OrderVariable> >      listOders     = new List <List <OrderVariable> >();

            listOders = ListOrdervariables(orders);
            List <SettingBOM>         listSettingBoms        = LoadingSettingBOMs();
            List <SettingManufacture> lisSettingManufactures = LoadingSettingManufacture();
            SFT_WIP sFT_WIP = new SFT_WIP();

            try
            {
                foreach (var order in listOders)
                {
                    PlanningItem pLanning = new PlanningItem();
                    pLanning.KeyProduct = order[0].ProductName;
                    // base on product to defind Dept
                    pLanning.Client = "";
                    // Define Shiment Plan of production
                    pLanning.shipmentPlans    = new List <ShipmentPlan>();
                    pLanning.needProduceQties = new List <NeedProduceQty>();
                    foreach (var or in order)
                    {
                        ShipmentPlan shipment = new ShipmentPlan();
                        shipment.ClientRequestDate = or.ClientRequestDate;
                        shipment.DeliveryPlanQty   = or.ClientOrderQty;
                        pLanning.shipmentPlans.Add(shipment);

                        NeedProduceQty need = new NeedProduceQty();
                        need.ClientRequestDate = or.ClientRequestDate;
                        need.NeedQty           = or.ClientOrderQty;
                        need.RemainDay         = (or.ClientRequestDate - DateTime.Now.Date).Days;
                        need.NeedQtyPerDay     = need.NeedQty / need.RemainDay;
                        pLanning.needProduceQties.Add(need);
                    }
                    pLanning.TotalQty = pLanning.shipmentPlans.Select(d => d.DeliveryPlanQty).Sum();
                    pLanning._bom     = new BOM();
                    List <string> ListHENN = ListHENNofProduct(pLanning.KeyProduct);
                    if (ListHENN != null)
                    {
                        pLanning._bom.HEN = ListHENN[0];
                    }
                    else
                    {
                        pLanning._bom.HEN = "";
                    }
                    var _bom = listSettingBoms.Where(d => d.ProductNo == pLanning.KeyProduct).ToList();
                    if (_bom.Count > 0)
                    {
                        pLanning._bom.QtyUnit = _bom[0].QtyInBox;
                        pLanning._bom.ToolQty = _bom[0].QtyTool;
                    }
                    pLanning.wip           = new Wip();
                    pLanning.wip.Warehouse = StockOfProduct(order[0].Product);
                    pLanning.TotalShortage = pLanning.TotalQty - pLanning.wip.Warehouse;

                    pLanning.production = new Production();
                    var _productItem = lisSettingManufactures.Where(d => d.ProductNo == pLanning.KeyProduct).ToList();
                    if (_productItem.Count > 0)
                    {
                        pLanning.production.PeopleQty     = _productItem[0].WorkerQty;
                        pLanning.production.targetPeople  = _productItem[0].Workertarget;
                        pLanning.production.ProductionQty = pLanning.production.PeopleQty * pLanning.production.targetPeople;
                    }
                    sFT_WIP = GetSFT_WIPofProducts(order[0].Product);

                    pLanning.wip.MQCQty       = sFT_WIP.MQC_Out_Available;
                    pLanning.wip.PQCQty       = sFT_WIP.PQC_In_Available + sFT_WIP.PQC_Out_Available;
                    pLanning.wip.StockInWHQTy = sFT_WIP.StockIntoWH;
                    pLanning.wip.TotalInWip   = pLanning.wip.MQCQty + pLanning.wip.PQCQty + pLanning.wip.StockInWHQTy + pLanning.wip.Warehouse;
                    keyValuePairs.Add(pLanning.KeyProduct, pLanning);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(keyValuePairs);
        }