コード例 #1
0
 public ShareDataEntity()
 {
     FREQPCatcher   = new DB2DataCatcher <FREQPModel>("MMVIEW.FREQP");
     FHESCHSCatcher = new DB2DataCatcher <FHESCHSModel>("MMVIEW.FHESCHS");
     FRCodeCatcher  = new DB2DataCatcher <FRCodeModel>("MMVIEW.FRCODE");
     FRUserCatcher  = new DB2DataCatcher <FRUserModel>("MMVIEW.FRUSER");
     FHOPEHSCatcher = new DB2DataCatcher <FHOPEHSModel>("MMVIEW.FHOPEHS");
 }
コード例 #2
0
        //为RealTimeList赋值
        private void DoWork()
        {
            DBCatcher.Conditions  = string.Format("where lot_type='Production' and  Claim_time >='{0}' and Claim_Time < '{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            DBCatcher2.Conditions = string.Format("where lot_type='Production' and  Scrap_time >='{0}' and Scrap_Time < '{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var list  = DBCatcher.GetEntities().EntityList;
            var list2 = DBCatcher2.GetEntities().EntityList;

            if (list.Count() <= 0)
            {
                throw new Exception("ReqRpt025Translator.GetBaseList()没有获取符合条件的数据");
            }
            LotCatcher.Conditions = string.Format("where lot_type='Production' and Created_Time <='{0}' and (Completion_Time >='{1}' or Completion_Time='1901-01-01 00:00:00' )", End_Time.ToString("yyyy-MM-dd HH:mm:ss"), Start_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var lotList = LotCatcher.GetEntities().EntityList;

            OpehsCatcher.Conditions = string.Format("where lot_type='Production' and Ope_Category='OperationComplete' and PD_Type not in ('Dummy','Measurement') and Claim_Time between '{0}' and '{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"));
            var      OphesList = OpehsCatcher.GetEntities().EntityList;
            DateTime firstTime = Start_Time;

            while (firstTime < End_Time)
            {
                var rawList    = list.Where(w => w.Claim_Time >= firstTime && w.Claim_Time < firstTime.AddHours(12));
                var rawList2   = list2.Where(w => w.Scrap_Time >= firstTime && w.Scrap_Time < firstTime.AddHours(12));
                var rawLotList = lotList.Where(w => w.Created_Time <= firstTime && (w.Completion_Time >= firstTime || w.Completion_Time == DateTime.Parse("1901-01-01 00:00:00")));

                var rawOpehsList = OphesList.Where(w => w.Claim_Time >= firstTime && w.Claim_Time < firstTime.AddHours(12));

                if (rawList.Count() > 0)
                {
                    rawList.GroupBy(g => new { g.ProdSpec_ID, g.PartName }).Select(s => new { Product = s.Key, Qty = s.Sum(i => i.Cur_Wafer_Qty) }).ToList().ForEach(f => RealTimeList.Add(new RPT_RealTime_Lin()
                    {
                        Product_ID = f.Product.ProdSpec_ID, MoveQty = f.Qty, PartName = f.Product.PartName, Start_Time = firstTime, ScrappedQty = 0
                    }));
                    rawList.Select(s => new { s.Claim_Time, s.Cur_Wafer_Qty, EqpType = s.Eqp_ID.Substring(0, 6), s.ProdSpec_ID }).GroupBy(g => new { g.ProdSpec_ID, g.EqpType }).Select(s => new { Product = s.Key, Qty = s.Sum(i => i.Cur_Wafer_Qty) }).ToList().ForEach(f => MoveList.Add(new RPT_Move_By_EqpType()
                    {
                        Product_ID = f.Product.ProdSpec_ID, EqpType = f.Product.EqpType, Start_Time = firstTime, MoveQty = f.Qty
                    }));
                }
                if (rawList2.Count() > 0)
                {
                    rawList2.GroupBy(g => new { g.ProdSpec_ID, g.PartName }).Select(s => new { Product = s.Key, Qty = s.Sum(i => i.Qty) }).ToList().ForEach(f => RealTimeList.Where(w => w.Product_ID == f.Product.ProdSpec_ID && w.PartName == f.Product.PartName && w.Start_Time == firstTime).FirstOrDefault().ScrappedQty = f.Qty);
                }
                if (rawLotList.Count() > 0)
                {
                    var group = rawLotList.GroupBy(g => g.ProdSpec_ID);
                    foreach (var gp in group)
                    {
                        var entity = new RPT_Turn_Daily()
                        {
                            Product_ID     = gp.Key,
                            Start_Time     = firstTime,
                            WIP            = gp.Count(),
                            MoveQty        = RealTimeList.Where(w => w.Product_ID == gp.Key).Sum(s => s.MoveQty),
                            EffectiveSteps = rawOpehsList.Where(w => w.ProdSpec_ID == gp.Key).Count()
                        };
                        TurnDailyList.Add(entity);
                    }
                }
                firstTime = firstTime.AddHours(12);
            }

            //input or update
            var RealTimeCurrent = new DB2DataCatcher <RPT_RealTime_Lin>("ISTRPT.RPT_RealTime_Lin")
            {
                Conditions = string.Format("where Start_Time >='{0}' and Start_Time<='{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"))
            }.GetEntities().EntityList;
            var TurnDailyCurrent = new DB2DataCatcher <RPT_Turn_Daily>("ISTRPT.RPT_Turn_Daily")
            {
                Conditions = string.Format("where Start_Time >='{0}' and Start_Time<='{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"))
            }.GetEntities().EntityList;
            var MoveCurrent = new DB2DataCatcher <RPT_Move_By_EqpType>("ISTRPT.RPT_Move_By_EqpType")
            {
                Conditions = string.Format("where Start_Time >='{0}' and Start_Time<='{1}'", Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), End_Time.ToString("yyyy-MM-dd HH:mm:ss"))
            }.GetEntities().EntityList;

            foreach (var item in RealTimeList)
            {
                if (RealTimeCurrent.Where(w => w.Start_Time == item.Start_Time && w.Product_ID == item.Product_ID && w.PartName == item.PartName).Count() == 0)
                {
                    DBPusher.entities.EntityList.Add(item);
                }
                else
                {
                    UpdateSqlList.Add(string.Format("update ISTRPT.RPT_RealTime_Lin set MOVEQTY={0}, ScrappedQTY={4} where Start_Time='{1}' and Product_ID='{2}' and PartName='{3}'", item.MoveQty, item.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), item.Product_ID, item.PartName, item.ScrappedQty));
                }
            }

            foreach (var item in TurnDailyList)
            {
                if (TurnDailyCurrent.Where(w => w.Start_Time == item.Start_Time && w.Product_ID == item.Product_ID).Count() == 0)
                {
                    TurnPusher.entities.EntityList.Add(item);
                }
                else
                {
                    UpdateSqlList.Add(string.Format("update ISTRPT.RPT_Turn_Daily set MoveQty={0},EffectiveSteps={1},WIP={2} where Start_Time='{3}' and Product_ID='{4}'", item.MoveQty.ToString(), item.EffectiveSteps.ToString(), item.WIP.ToString(), item.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), item.Product_ID));
                }
            }

            foreach (var item in MoveList)
            {
                if (MoveCurrent.Where(w => w.Start_Time == item.Start_Time && w.Product_ID == item.Product_ID && w.EqpType == item.EqpType).Count() == 0)
                {
                    MovePusher.entities.EntityList.Add(item);
                }
                else
                {
                    UpdateSqlList.Add(string.Format("update ISTRPT.RPT_Move_By_EqpType set MOVEQTY={0} where Start_Time='{1}' and Product_ID='{2}' and EqpType='{3}' ", item.MoveQty, item.Start_Time.ToString("yyyy-MM-dd HH:mm:ss"), item.Product_ID, item.EqpType));
                }
            }
            if (DBPusher.entities.EntityList.Count() > 0)
            {
                DBPusher.PushEntities();
            }
            if (TurnPusher.entities.EntityList.Count() > 0)
            {
                TurnPusher.PushEntities();
            }
            if (MovePusher.entities.EntityList.Count() > 0)
            {
                MovePusher.PushEntities();
            }
            if (UpdateSqlList.Count > 0)
            {
                DB2Helper db2 = new DB2Helper();
                db2.UpdateBatchCommand(UpdateSqlList);
            }
        }