Exemplo n.º 1
0
        void FormProducts()
        {
            var lot_list  = LotCatcher.entities.EntityList;
            var plan_list = PlanCatcher.entities.EntityList;

            foreach (string prod in Prods)
            {
                var lot_prod  = lot_list.Where(w => w.ProdSpec_ID == prod).Select(s => new { s.Lot_ID, s.Out_Type, s.ProdSpec_ID, s.Qty, Date = s.Completion_Time.ToString("yyyy-MM-dd") });
                var plan_prod = plan_list.Where(w => w.ProdSpec_ID == prod);
                ReqRpt011ProductEntity shipEntity = new ReqRpt011ProductEntity()
                {
                    ProductID = prod
                };
                ReqRpt011ProductEntity wipEntity = new ReqRpt011ProductEntity()
                {
                    ProductID = prod
                };
                for (int i = 0; i < _items.Count; i++)
                {
                    var lot_i    = lot_prod.Where(w => w.Date == _items[i]);
                    var lot_ship = lot_i.Where(w => w.Out_Type == "Ship");
                    var lot_wip  = lot_i.Where(w => w.Out_Type == "Wip");
                    var plan_i   = plan_prod.Where(w => w.Plan_Date == _items[i]);
                    var plan_wip = new ReqRpt011PlanEntity()
                    {
                        Actual = lot_wip.Sum(s => s.Qty),
                        Target = plan_i.Sum(s => s.Plan_Wip_Pcs),
                    };
                    plan_wip.Gap = plan_wip.Actual - plan_wip.Target + (i > 0 ? wipEntity.Plans.Last().Gap : 0);
                    var plan_ship = new ReqRpt011PlanEntity
                    {
                        Actual = lot_ship.Sum(s => s.Qty),
                        Target = plan_i.Sum(s => s.Plan_Ship_Pcs)
                    };
                    plan_ship.Gap  = plan_ship.Actual - plan_ship.Target + (i > 0 ? shipEntity.Plans.Last().Gap : 0);
                    plan_ship.Lots = plan_ship.Actual > 0 ? lot_ship.Select(s => s.Lot_ID).ToList():new List <string>();
                    plan_wip.Lots  = plan_wip.Actual > 0 ? lot_wip.Select(s => s.Lot_ID).ToList() : new List <string>();
                    shipEntity.Plans.Add(plan_ship);
                    wipEntity.Plans.Add(plan_wip);
                }
                var ship_total_act = shipEntity.Plans.Sum(s => s.Actual);
                var ship_total_tar = shipEntity.Plans.Sum(s => s.Target);
                var wip_total_act  = wipEntity.Plans.Sum(s => s.Actual);
                var wip_total_tar  = wipEntity.Plans.Sum(s => s.Target);
                shipEntity.Plans.Add(new ReqRpt011PlanEntity()
                {
                    Actual = ship_total_act, Target = ship_total_tar, Gap = ship_total_act - ship_total_tar
                });
                wipEntity.Plans.Add(new ReqRpt011PlanEntity()
                {
                    Actual = wip_total_act, Target = wip_total_tar, Gap = wip_total_act - wip_total_tar
                });
                var lot_ship_prod            = lot_prod.Where(w => w.Out_Type == "Ship");
                var lot_wip_prod             = lot_prod.Where(w => w.Out_Type == "Wip");
                shipEntity.Plans.Last().Lots = lot_ship_prod.Any() ? lot_ship_prod.Select(s => s.Lot_ID).ToList() : new List <string>();
                wipEntity.Plans.Last().Lots  = lot_wip_prod.Any() ? lot_wip_prod.Select(s => s.Lot_ID).ToList() : new List <string>();
                ShipEntities.Add(shipEntity);
                WipEntities.Add(wipEntity);
            }
        }
Exemplo n.º 2
0
        private void Initialize()
        {
            GetDBDatas();
            var list = WipCatcher.entities.EntityList;

            if (!list.Any())
            {
                return;
            }
            List <RPT__WIP_ByDepartmentModel> list_nrpt = new List <RPT__WIP_ByDepartmentModel>();

            list_nrpt.Add(list[0]);
            //list去重
            for (int i = 1; i < list.Count(); i++)
            {
                if (list[i].Lot_ID == list_nrpt.Last().Lot_ID)
                {
                    list_nrpt.RemoveAt(list_nrpt.Count - 1);
                }
                list_nrpt.Add(list[i]);
            }
            var list_outsource = list_nrpt.Where(w => w.Ope_Name == "CL BANK INOUT");
            var list_insource  = list_nrpt.Where(w => w.Ope_Name != "CL BANK INOUT");
            var list_bank      = list_insource.Where(w => w.Bank_ID != "");
            var list_deptlots  = list_insource.Where(w => w.Bank_ID == "" && w.Department != "");
            var list_dept      = list_deptlots.Select(s => s.Department).Distinct();

            foreach (var dept in list_dept)
            {
                var list_wip  = list_deptlots.Where(w => w.Department == dept);
                var list_hold = list_wip.Where(w => w.Hold_State == "ONHOLD");
                var wip       = new ReqRpt002WipEntity
                {
                    Department      = dept,
                    HoldWafers      = list_hold.Sum(s => s.Cur_Wafer_Qty),
                    HoldLots        = list_hold.Count(),
                    Lots            = list_wip.Count(),
                    Wafers          = list_wip.Sum(s => s.Cur_Wafer_Qty),
                    HoldLotOverTime = list_wip.Where(w => (DaDateTime - w.Hold_Time).TotalDays > 1).Count()
                };
                WipEntities.Add(wip);
            }

            WipEntities.Add(new ReqRpt002WipEntity()
            {
                Department      = "OutSource",
                HoldWafers      = list_outsource.Where(w => w.Hold_State == "ONHOLD").Sum(s => s.Cur_Wafer_Qty),
                Lots            = list_outsource.Count(),
                Wafers          = list_outsource.Sum(s => s.Cur_Wafer_Qty),
                HoldLots        = list_outsource.Where(w => w.Hold_State == "ONHOLD").Count(),
                HoldLotOverTime = list_outsource.Where(w => (DaDateTime - w.Hold_Time).TotalDays > 1).Count()
            });

            WipEntities.Add(new ReqRpt002WipEntity()
            {
                Department      = "Bank",
                HoldWafers      = list_bank.Where(w => w.Hold_State == "ONHOLD").Sum(s => s.Cur_Wafer_Qty),
                Lots            = list_bank.Count(),
                Wafers          = list_bank.Sum(s => s.Cur_Wafer_Qty),
                HoldLots        = list_bank.Where(w => w.Hold_State == "ONHOLD").Count(),
                HoldLotOverTime = list_bank.Where(w => (DaDateTime - w.Hold_Time).TotalDays > 1).Count()
            });
        }