Exemple #1
0
        public object[] QueryTryNo(
            string itemCodes, string moCodes, string modelCodes,
            string startSn, string endSn, string TryNo,
            int inclusive, int exclusive)
        {
            string itemCondition = "";

            if (itemCodes != "" && itemCodes != null)
            {
                itemCondition = string.Format(
                    @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
            }

            string moCondition = "";

            if (moCodes != "" && moCodes != null)
            {
                moCondition = string.Format(
                    @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
            }

            string modelCondition = "";

            if (modelCodes != "" && modelCodes != null)
            {
                modelCondition = string.Format(
                    @" and modelcode in ({0})", FormatHelper.ProcessQueryValues(modelCodes));
            }

            string         SnCondition    = string.Empty;
            CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);

            if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
            {
                ArrayList array = new ArrayList();
                array.Add(startSn);
                castDownHelper.GetAllRCard(ref array, startSn);

                string[] rCards = (string[])array.ToArray(typeof(System.String));

                SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
            }
            else if (string.Compare(startSn, endSn, true) != 0)
            {
                ArrayList array = new ArrayList();
                castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                string rcardCondition = string.Empty;
                if (array.Count > 0)
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        if (i < array.Count - 1)
                        {
                            rcardCondition += array[i].ToString() + " union ";
                        }
                        else
                        {
                            rcardCondition += array[i].ToString();
                        }
                    }
                }
                SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                if (rcardCondition != string.Empty)
                {
                    SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                }
                SnCondition += " ) ";
            }

            string TryNoCondition = "";

            if (TryNo != "" && TryNo != null)
            {
                TryNoCondition = string.Format(
                    @" and TRYNO like '{0}%'", TryNo.ToUpper());
            }

            string sql = string.Format(
                @"select distinct {0} from TBLONWIPTRY where 1=1 {1}{2}{3}{4}{5}",
                DomainObjectUtility.GetDomainObjectFieldsString(typeof(QDOTryNo)),
                itemCondition, moCondition, modelCondition, SnCondition, TryNoCondition);

#if DEBUG
            Log.Info(
                new PagerCondition(
                    sql,
                    "mocode,itemcode",
                    inclusive, exclusive, true).SQLText);
#endif

            object[] objs = this.DataProvider.CustomQuery(
                typeof(QDOTryNo),
                new PagerCondition(
                    sql,
                    "mocode,itemcode",
                    inclusive, exclusive, true));


            if (objs != null)
            {
                foreach (QDOTryNo obj in objs)
                {
                    object[] sn = this.DataProvider.CustomQuery(typeof(Simulation),
                                                                new SQLCondition(
                                                                    string.Format(@"select ProductStatus from TBLSIMULATION where RCARD = '{0}'", obj.RunningCard)));
                    if (sn != null)
                    {
                        object[] sn2 = this.DataProvider.CustomQuery(typeof(Simulation),
                                                                     new SQLCondition(
                                                                         string.Format(
                                                                             @"select tblts.tsstatus as ProductStatus from TBLSIMULATION,tblts 
							where TBLSIMULATION.RCARD = tblts.rcard
							and tblsimulation.rcardseq = tblts.rcardseq
							and tblsimulation.mocode = tblts.mocode  
							and TBLSIMULATION.rcard = '{0}' "                            , obj.RunningCard)));
                        if (sn2 != null)
                        {
                            obj.SNState = (sn2[0] as Simulation).ProductStatus;
                        }
                        else
                        {
                            obj.SNState = (sn[0] as Simulation).ProductStatus;
                        }
                    }
                    else
                    {
                        obj.SNState = ProductStatus.OffLine;
                    }

                    object[] onWip = this.DataProvider.CustomQuery(typeof(OnWIP),
                                                                   new SQLCondition(String.Format(
                                                                                        @"select opcode from tblonwip where rcard ='{0}'     
							and (rcardseq,mocode) in 
							(select rcardseq,mocode
									from (select rcardseq, mocode
											from tblonwip
											where rcard = '{0}'
											order by mdate * 1000000 + mtime desc)
									where rownum = 1)"                                    , obj.RunningCard)));

                    if (onWip != null)
                    {
                        obj.CollectionOPCODE = obj.OPCode;                              //采集工位
                        obj.OPCode           = ((OnWIP)onWip[0]).OPCode;                //当前工位
                    }
                }
            }

            return(objs);
        }
Exemple #2
0
        public int QueryTryNoCount(
            string itemCodes, string moCodes, string modelCodes,
            string startSn, string endSn, string TryNo)
        {
            string itemCondition = "";

            if (itemCodes != "" && itemCodes != null)
            {
                itemCondition = string.Format(
                    @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
            }

            string moCondition = "";

            if (moCodes != "" && moCodes != null)
            {
                moCondition = string.Format(
                    @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
            }

            string modelCondition = "";

            if (modelCodes != "" && modelCodes != null)
            {
                modelCondition = string.Format(
                    @" and modelcode in ({0})", FormatHelper.ProcessQueryValues(modelCodes));
            }

            string         SnCondition    = string.Empty;
            CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);

            if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
            {
                ArrayList array = new ArrayList();
                array.Add(startSn);
                castDownHelper.GetAllRCard(ref array, startSn);

                string[] rCards = (string[])array.ToArray(typeof(System.String));

                SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
            }
            else if (string.Compare(startSn, endSn, true) != 0)
            {
                ArrayList array = new ArrayList();
                castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                string rcardCondition = string.Empty;
                if (array.Count > 0)
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        if (i < array.Count - 1)
                        {
                            rcardCondition += array[i].ToString() + " union ";
                        }
                        else
                        {
                            rcardCondition += array[i].ToString();
                        }
                    }
                }
                SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                if (rcardCondition != string.Empty)
                {
                    SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                }
                SnCondition += " ) ";
            }

            string TryNoCondition = "";

            if (TryNo != "" && TryNo != null)
            {
                TryNoCondition = string.Format(
                    @" and TRYNO like '{0}%'", TryNo.ToUpper());
            }

            string sql = string.Format(
                @"select {0} from TBLONWIPTRY where 1=1 {1}{2}{3}{4}{5}",
                "count(mocode)",
                itemCondition, moCondition, modelCondition, SnCondition, TryNoCondition);

#if DEBUG
            Log.Info(
                new SQLCondition(
                    sql).SQLText);
#endif

            return(this.DataProvider.GetCount(
                       new SQLCondition(
                           sql)));
        }
        public object[] QuerySoftwareVersion(
            string itemCodes, string moCodes,
            string startSn, string endSn,
            int startDate, int endDate,
            string compareResult,
            string softwareName, string softwareVersion,
            int inclusive, int exclusive)
        {
            if (compareResult == SoftCompareStatus.Success)
            {
                #region 比对成功的信息 TBLONWIPSOFTVER

                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and SOFTVER like '{0}%'", softwareVersion);
                }

                string sql = string.Format(@"select distinct {0} from TBLONWIPSOFTVER where 1=1 {1}{2}{3}{4}{5}",
                                           DomainObjectUtility.GetDomainObjectFieldsString(typeof(OnWIPSoftVersion)),
                                           itemCondition, moCondition, SnCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(
                    new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true).SQLText);
#endif

                return(this.DataProvider.CustomQuery(
                           typeof(OnWIPSoftVersion),
                           new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true
                                              )));

                #endregion
            }
            else if (compareResult == SoftCompareStatus.Failed)
            {
                #region 比对失败的信息 TBLVERSIONERROR


                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and TBLVERSIONERROR.mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and TBLVERSIONERROR.rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("TBLVERSIONERROR.rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or TBLVERSIONERROR.rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and MOVERSIONINFO like '{0}%'", softwareVersion);
                }

                string dateCondition = "";
                if (startDate != 0 && endDate != 0)
                {
                    dateCondition = FormatHelper.GetDateRangeSql("TBLVERSIONERROR.mdate", startDate, endDate);
                }

                string sql = string.Format(@"select distinct TBLVERSIONERROR.* ,tblonwipsoftver.RCARDSEQ,SOFTNAME,TPCODE,SHIFTCODE,SHIFTTYPECODE,RESCODE,OPCODE,SSCODE,SEGCODE,ROUTECODE,MODELCODE,ITEMCODE
							 from TBLVERSIONERROR left join tblonwipsoftver on (TBLVERSIONERROR.rcard = tblonwipsoftver.rcard)
							 where 1=1 {0}{1}{2}{3}{4}{5}"                            ,
                                           itemCondition, moCondition,
                                           SnCondition, dateCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(
                    new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true).SQLText);
#endif

                return(this.DataProvider.CustomQuery(
                           typeof(OnWIPSoftVersionError),
                           new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true
                                              )));

                #endregion
            }

            return(null);
        }
        public object[] QuerySoftwareVersion(
            string itemCodes, string moCodes,
            string startSn, string endSn,
            string softwareName, string softwareVersion,
            int inclusive, int exclusive)
        {
            string itemCondition = "";

            if (itemCodes != "" && itemCodes != null)
            {
                itemCondition = string.Format(
                    @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
            }

            string moCondition = "";

            if (moCodes != "" && moCodes != null)
            {
                moCondition = string.Format(
                    @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
            }

            string         SnCondition    = string.Empty;
            CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);

            if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
            {
                ArrayList array = new ArrayList();
                array.Add(startSn);
                castDownHelper.GetAllRCard(ref array, startSn);

                string[] rCards = (string[])array.ToArray(typeof(System.String));

                SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
            }
            else if (string.Compare(startSn, endSn, true) != 0)
            {
                ArrayList array = new ArrayList();
                castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                string rcardCondition = string.Empty;
                if (array.Count > 0)
                {
                    for (int i = 0; i < array.Count; i++)
                    {
                        if (i < array.Count - 1)
                        {
                            rcardCondition += array[i].ToString() + " union ";
                        }
                        else
                        {
                            rcardCondition += array[i].ToString();
                        }
                    }
                }
                SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                if (rcardCondition != string.Empty)
                {
                    SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                }
                SnCondition += " ) ";
            }

            string nameCondition = "";

            if (softwareName != "" && softwareName != null)
            {
                nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
            }

            string versionCondition = "";

            if (softwareVersion != "" && softwareVersion != null)
            {
                versionCondition = string.Format(@" and SOFTVER like '{0}%'", softwareVersion);
            }

            string sql = string.Format(@"select distinct {0} from TBLONWIPSOFTVER where 1=1 {1}{2}{3}{4}{5}",
                                       DomainObjectUtility.GetDomainObjectFieldsString(typeof(OnWIPSoftVersion)),
                                       itemCondition, moCondition, SnCondition,
                                       nameCondition, versionCondition);

#if DEBUG
            Log.Info(
                new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true).SQLText);
#endif

            return(this.DataProvider.CustomQuery(
                       typeof(OnWIPSoftVersion),
                       new PagerCondition(sql, "mocode,itemcode", inclusive, exclusive, true
                                          )));
        }
        public int QuerySoftwareVersionCount(
            string itemCodes, string moCodes,
            string startSn, string endSn,
            int startDate, int endDate,
            string compareResult,
            string softwareName, string softwareVersion)
        {
            if (compareResult == SoftCompareStatus.Success)
            {
                #region 比对成功的信息 TBLONWIPSOFTVER

                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and SOFTVER like '{0}%'", softwareVersion);
                }

                string sql = string.Format(@"select {0} from TBLONWIPSOFTVER where 1=1 {1}{2}{3}{4}{5}",
                                           "count(mocode)",
                                           itemCondition, moCondition, SnCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(
                    new SQLCondition(sql).SQLText);
#endif
                return(this.DataProvider.GetCount(
                           new SQLCondition(sql)));

                #endregion
            }
            else if (compareResult == SoftCompareStatus.Failed)
            {
                #region 比对失败的信息 TBLVERSIONERROR

                string itemCondition = "";
                if (itemCodes != "" && itemCodes != null)
                {
                    itemCondition = string.Format(
                        @" and itemcode in ({0})", FormatHelper.ProcessQueryValues(itemCodes));
                }

                string moCondition = "";
                if (moCodes != "" && moCodes != null)
                {
                    moCondition = string.Format(
                        @" and TBLVERSIONERROR.mocode in ({0})", FormatHelper.ProcessQueryValues(moCodes));
                }

                string         SnCondition    = string.Empty;
                CastDownHelper castDownHelper = new CastDownHelper(this.DataProvider);
                if (string.Compare(startSn, endSn, true) == 0 && startSn != string.Empty)
                {
                    ArrayList array = new ArrayList();
                    array.Add(startSn);
                    castDownHelper.GetAllRCard(ref array, startSn);

                    string[] rCards = (string[])array.ToArray(typeof(System.String));

                    SnCondition = string.Format(" and TBLVERSIONERROR.rcard in ({0}) ", FormatHelper.ProcessQueryValues(rCards));
                }
                else if (string.Compare(startSn, endSn, true) != 0)
                {
                    ArrayList array = new ArrayList();
                    castDownHelper.BuildProcessRcardCondition(ref array, startSn.ToUpper(), endSn.ToUpper());
                    string rcardCondition = string.Empty;
                    if (array.Count > 0)
                    {
                        for (int i = 0; i < array.Count; i++)
                        {
                            if (i < array.Count - 1)
                            {
                                rcardCondition += array[i].ToString() + " union ";
                            }
                            else
                            {
                                rcardCondition += array[i].ToString();
                            }
                        }
                    }
                    SnCondition = "and ( 1=1 " + FormatHelper.GetRCardRangeSql("TBLVERSIONERROR.rcard", startSn.ToUpper(), endSn.ToUpper());

                    if (rcardCondition != string.Empty)
                    {
                        SnCondition += string.Format(" or TBLVERSIONERROR.rcard in ({0}) ", rcardCondition);
                    }
                    SnCondition += " ) ";
                }

                string nameCondition = "";
                if (softwareName != "" && softwareName != null)
                {
                    nameCondition = string.Format(@" and SOFTNAME like '{0}%'", softwareName);
                }

                string versionCondition = "";
                if (softwareVersion != "" && softwareVersion != null)
                {
                    versionCondition = string.Format(@" and MOVERSIONINFO like '{0}%'", softwareVersion);
                }

                string dateCondition = "";
                if (startDate != 0 && endDate != 0)
                {
                    dateCondition = FormatHelper.GetDateRangeSql("TBLVERSIONERROR.mdate", startDate, endDate);
                }

                string sql = string.Format(@"select  count(PKID)
							 from TBLVERSIONERROR left join tblonwipsoftver on (TBLVERSIONERROR.rcard = tblonwipsoftver.rcard)
							 where 1=1 {1}{2}{3}{4}"                            ,
                                           itemCondition, moCondition,
                                           SnCondition, dateCondition,
                                           nameCondition, versionCondition);

#if DEBUG
                Log.Info(sql);
#endif

                return(this.DataProvider.GetCount(new SQLCondition(sql)));


                #endregion
            }

            return(0);
        }