Пример #1
0
        //private void GetLastUpdateTimeFromFile()
        //{
        //    DateTime dt = DateTime.Now.Date;
        //    string json = System.IO.File.ReadAllText(DirPath + LastTimeKeepFileName);
        //    DateTime.TryParseExact(JsonConvert.DeserializeObject<CycleTimeRunningConfig>(json).LastUpdateTime, "yyyy-MM-dd-HH.mm.ss.ffffff", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt);
        //    StartTime = dt;
        //}

        private void HandleDBData()
        {
            Db2.GetSomeData(DelNotExistOpeStepAtSMSql);
            Db2.GetSomeData(CmpSmOpeWithRptFlowSql);
            FlowSumCatcher = new DB2OperDataCatcher <RPT_FLOW_SUM>("MMVIEW.RPT_FLOW_SUM", Db2);
            FlowEqpCatcher = new DB2OperDataCatcher <RPT_FLOW_SUM_EQPBASE>("ISTRPT.RPT_FLOW_SUM_EQPBASE", Db2);
            // LRcpCatcher = new DB2OperDataCatcher<RPT_FLOW_SUM_LRCP>("ISTRPT.RPT_FLOW_SUM_LRCP",Db2);
            SETCatcher        = new DB2OperDataCatcher <FBLRCP_SSET_M>("SMVIEW.FBLRCP_SSET_M", Db2);
            MR_LRCatcher      = new DB2OperDataCatcher <RPT_FLOW_SUM_MR_LR_MAPPING>("ISTRPT.RPT_FLOW_SUM_MR_LR_MAPPING", Db2);
            EQPType_LRCatcher = new DB2OperDataCatcher <RPT_FLOW_SUM_EQPT_LR_MAPPING>("ISTRPT.RPT_FLOW_SUM_EQPT_LR_MAPPING", Db2);
            var FlowSumList = FlowSumCatcher.GetEntities().EntityList;
            var FlowEqpList = FlowEqpCatcher.GetEntities().EntityList;
            //var LRcpList = LRcpCatcher.GetEntities().EntityList;
            //var SetList = SETCatcher.GetEntities().EntityList;
            IList <FBLRCP_SSET_M> SetList = null;
            //var MR_LRList = MR_LRCatcher.GetEntities().EntityList;
            IList <RPT_FLOW_SUM_MR_LR_MAPPING> MR_LRList = null;
            //var EqpType_LRList = EQPType_LRCatcher.GetEntities().EntityList;
            IList <RPT_FLOW_SUM_EQPT_LR_MAPPING> EqpType_LRList = null;
            //重置待更新的字段,并在该遍历中获取EqpType、EqpList、Logic Recipe
            var newFlowList = FlowSumList.Select(s => new RPT_FLOW_SUM()
            {
                ProdSpec_ID = s.ProdSpec_ID, MainPD_ID = s.MainPD_ID, Ope_No = s.Ope_No, PD_ID = s.PD_ID, LRecipe = s.LRecipe
            });
            List <RPT_FLOW_SUM> UpdateList = new List <RPT_FLOW_SUM>();

            foreach (var item in newFlowList)
            {
                try
                {
                    SetEqpInfo(item, FlowEqpList);
                    // SetLRcpInfo(item, LRcpList);
                    bool hasGet = SetMRcpInfoBySset(item, SetList);
                    if (!hasGet)
                    {
                        SetMRcpInfoByDset(item, MR_LRList);
                    }
                    if (item.Eqp_Type == "")
                    {
                        SetEqpType(item, EqpType_LRList);
                    }

                    var rawFlow = FlowSumList.Where(w => w.ProdSpec_ID == item.ProdSpec_ID && w.MainPD_ID == item.MainPD_ID && w.Ope_No == item.Ope_No).First();
                    if (!(rawFlow.Eqp_Type == item.Eqp_Type && rawFlow.LRecipe == item.LRecipe && rawFlow.MRecipe_List == item.MRecipe_List && rawFlow.Eqp_List == item.Eqp_List))
                    {
                        UpdateList.Add(item);
                    }
                }
                catch (Exception e)
                {
                    LogHelper.ErrorLog(string.Format("RPTFlowSumTranslator>HandleDBData>foreach模块,ProdSpec_ID={0},MainPD_ID={1},Ope_NO={2}", item.ProdSpec_ID, item.MainPD_ID, item.Ope_No), e);
                }
            }

            List <string> sqlList = UpdateList.Select(s => string.Format("UPDATE MMVIEW.RPT_FLOW_SUM SET EQP_TYPE ='{0}',EQP_LIST='{1}',MRECIPE_LIST='{3}',LAST_UPDATE_TIME=CURRENT TIMESTAMP WHERE PRODSPEC_ID='{4}' AND MAINPD_ID='{5}' AND OPE_NO='{6}'", s.Eqp_Type, s.Eqp_List, s.LRecipe, s.MRecipe_List, s.ProdSpec_ID, s.MainPD_ID, s.Ope_No)).ToList();

            Db2.UpdateBatchCommand(sqlList);
        }
Пример #2
0
 public ReqRpt028Runner(Db2ConnObj connObj)
 {
     LotCatcher = new DB2OperDataCatcher <FRLot_WipChart>("MMVIEW.FRLOT", new DB2Oper(connObj))
     {
         Conditions = Condition
     };
     WipChartPusher = new DB2OperDataPusher <FRLot_WipChart>("ISTRPT.RPT_WIPCHART_YSTD", new DB2Oper(connObj));
     Initialize();
 }
Пример #3
0
 public ReqRpt028Runner_Bak(Db2ConnObj connObj)
 {
     HSCatcher = new DB2OperDataCatcher <FHOPEHS_WipChart>("MMVIEW.FHOPEHS", new DB2Oper(connObj))
     {
         Conditions = Condition
     };
     WipChartPusher = new DB2OperDataPusher <RPT_WipChart_YSTD>("ISTRPT.RPT_WIPCHART_YSTD", new DB2Oper(connObj));
     Initialize();
 }
Пример #4
0
        private void HandleDBData()
        {
            Db2.GetSomeData(DelCurrentDateContentFromTimeFlowTableSql);

            Db2.GetSomeData(InsertCurrentDateContentToTimeFlowTableSql);

            Db2.GetSomeData(DeleteContentFromTimeFlowTSql);

            Db2.GetSomeData(DelOldDataFromTimeFlowTableSql);

            PDCatcher = new DB2OperDataCatcher <FRPD_PD_ID>("MMVIEW.FRPD", Db2)
            {
                Conditions = "WHERE PD_LEVEL='Main' AND PD_TYPE IN ('Production')"
            };

            ProcTimeCatcher = new DB2OperDataCatcher <RPTH_LOT_PROC_TIME>("MMVIEW.RPTH_LOT_PROC_TIME", Db2);

            TimeFlowTPusher = new DB2OperDataPusher <RPT_STD_TIME_FLOW_T>("MMVIEW.RPT_STD_TIME_FLOW_T", Db2);

            var    pd_list     = PDCatcher.GetEntities().EntityList.Select(s => s.PD_ID);
            string pdCondition = string.Join("','", pd_list);

            ProcTimeCatcher.Conditions = string.Format(@"WHERE
OPE_START_TIME BETWEEN '{0}' AND '{1}'
AND OPE_COMP_USER_ID ='TCS'
AND LAST_OPE_CATEGORY IN ('OperationComplete')
AND OPE_PASS_COUNT=1
AND QTY=25
AND MAINPD_ID IN ('{2}' )
ORDER BY LOT_ID, OPE_START_TIME", sqlStartTime, sqlEndTime, pdCondition);

            var proc_list = ProcTimeCatcher.GetEntities().EntityList;

            if (!proc_list.Any())
            {
                return;
            }
            string lotIDCondition = string.Join("','", proc_list.Select(s => s.Lot_ID).Distinct());

            ProcTimeCatcher = new DB2OperDataCatcher <RPTH_LOT_PROC_TIME>("MMVIEW.RPTH_LOT_PROC_TIME", Db2)
            {
                Conditions = string.Format("where LAST_OPE_CATEGORY IN ('OperationComplete', 'STB') and AND MAINPD_ID IN '{0}' and lot_id in ('{1}') ", pdCondition, lotIDCondition)
            };
            var allProcList = ProcTimeCatcher.GetEntities().EntityList;

            if (!allProcList.Any())
            {
                return;
            }
            foreach (var proc in proc_list)
            {
                var p = allProcList.Where(w => w.Lot_ID == proc.Lot_ID && w.Ope_Start_Time < proc.Ope_Start_Time);
                if (p.Any())
                {
                    var entity = p.OrderBy(o => o.Ope_Start_Time).Last();

                    RPT_STD_TIME_FLOW_T fLOW_T = new RPT_STD_TIME_FLOW_T()
                    {
                        Lot_ID = proc.Lot_ID, ProdSpec_ID = proc.ProdSpec_ID, MainPD_ID = proc.MainPD_ID, Ope_No = proc.Ope_No
                    };

                    bool isComplete = entity.Last_Ope_Category == "OperationComplete";
                    fLOW_T.PD_Proc_Time_Sec = isComplete? entity.Process_Duration_Sec:0;
                    fLOW_T.PD_Wait_Time_Sec = isComplete? Convert.ToInt16((proc.Process_Start_Time - entity.Process_End_Time).TotalSeconds): Convert.ToInt16((proc.Process_Start_Time - entity.Ope_Start_Time).TotalSeconds);
                }
            }

            Db2.GetSomeData(MergeFormTimeFlowSql);

            Db2.GetSomeData(MergeFormTimeTableSql);

            Db2.GetSomeData(DeleteContentFromTimeFlowTSql);

            Db2.GetSomeData(DelCurrentDateContentFromCycleTimeSql);

            Db2.GetSomeData(InsertIntoCycleTimeSql);

            MergeUpdateCycleTimeSql = string.Format(@"MERGE INTO MMVIEW.RPT_STD_TIME_CYCLETIME M
USING (
    SELECT PRODSPEC_ID, MAINPD_ID,
      AVG(DOUBLE(TIMESTAMPDIFF(2, COMPLETION_TIME - RELEASED_TIME))/60) AS FLOW_CYCLE_TIME_MIN
FROM MMVIEW.FRLOT
WHERE
     LOT_STATE='FINSIHED' AND LOT_FINISHED_STATE='COMPLETED'
       AND LOT_TYPE='Production'
       AND COMPLETION_TIME BETWEEN '{0}' AND '{1}'
       AND QTY=25
GROUP BY PRODSPEC_ID, MAINPD_ID ) C
ON
          M.CYCLETIME_RECORD_DATE=CURRENT DATE
AND M.PRODSPEC_ID=C.PRODSPEC_ID
AND M.MAINPD_ID=C.MAINPD_ID
WHEN MATCHED THEN
UPDATE SET
FLOW_CYCLE_TIME_MIN=C. FLOW_CYCLE_TIME_MIN,
FLOW_CYCLE_TIME_TYPE=1,
FLOW_WAITTIME_FACTOR_MIN= C.FLOW_CYCLE_TIME_MIN/ FLOW_PROC_TIME_MIN,
FLOW_WAITTIME_FACTOR_TYPE=1", sqlStartTime, sqlEndTime);

            Db2.GetSomeData(MergeUpdateCycleTimeSql);

            Db2.GetSomeData(MergeUpdateTimeTable);

            RewriteLastUpdateTimeToFile();
        }