Esempio n. 1
0
        //        /// <summary>
        //        /// 得到测点配置主表
        //        /// </summary>
        //        /// <returns></returns>
        //        public static DataTable GetTagListForExcel(string UnitID)
        //        {
        //            string sql = @"select 'x'SelectX, TagName, TagDesc, TagType, TagEngunit, TagIsValid, TagIndex,
        //                             TagFilterExp, TagCalcExp, TagCalcExpType, TagCalcType, TagFactor, TagOffset
        //                            from KPI_SATag
        //                            where UnitID='{0}'
        //                            order by TagIndex";

        //            sql = string.Format(sql, UnitID);

        //            DataTable dt = DBAccess.GetRelation().ExecuteDataset(sql).Tables[0];

        //            return dt;
        //        }

        public List <KPI_SATagEntity> GetSATagList(string unitID)
        {
            List <KPI_SATagEntity> Result = null;
            string sqlText = @"SELECT A.* FROM KPI_SATag A  WHERE UnitID='{0}' AND SAIsValid=1";

            sqlText = string.Format(sqlText, unitID);
            using (IDataReader reader = m_DB.ExecuteReader(sqlText)) {
                Result = reader.FillGenericList <KPI_SATagEntity>();
                reader.Close();
            }
            return(Result);
        }
Esempio n. 2
0
        /// <summary>
        /// 返回经济指标日数据
        /// </summary>
        /// <param name="ECID">指标编码</param>
        /// <param name="StartDate">开始日期</param>
        /// <param name="EndDate">结束日期</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页面大小</param>
        /// <param name="RecordCount">记录数</param>
        /// <returns></returns>
        public List <ECHistoryDataEntity> GetECDayData(String ECID, DateTime StartDate, DateTime EndDate,
                                                       int PageIndex, int PageSize, out int RecordCount)
        {
            RelaInterface DataBase            = DBAccess.GetRelation();
            List <ECHistoryDataEntity> Result = null;

            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter("@ECID", DbType.String),
                new SqlParameter("@StartDate", DbType.DateTime),
                new SqlParameter("@EndDate", DbType.DateTime),
                new SqlParameter("@PageIndex", DbType.Int32),
                new SqlParameter("@PageSize", DbType.Int32)
            };
            parames[0].Value = ECID;
            parames[1].Value = StartDate;
            parames[2].Value = EndDate;
            parames[3].Value = PageIndex;
            parames[4].Value = PageSize;
            String CTE            = @"WITH CTE AS(
                              SELECT A.*, B.ECName,C.EngunitName,ROW_NUMBER() OVER(ORDER BY CheckDate) OrderNo 
                              FROM KPI_ECDayData A JOIN KPI_ECTag   B ON A.ECID=B.ECID
                                                   JOIN KPI_Engunit C  ON B.EngunitID = C.EngunitID
                              WHERE A.ECID=@ECID AND CheckDate BETWEEN @StartDate AND @EndDate)";
            String RecordCountSql = CTE + "SELECT COUNT(ECID) FROM CTE";
            String SqlText        = CTE + @"SELECT * FROM CTE WHERE OrderNo BETWEEN (@PageIndex -1)*@PageSize 
                                AND @PageIndex * @PageSize";

            RecordCount = Convert.ToInt32(DataBase.ExecuteScalar(RecordCountSql, parames));
            using (IDataReader Reader = DataBase.ExecuteReader(CommandType.Text, SqlText, parames)) {
                Result = Reader.FillGenericList <ECHistoryDataEntity>();
            }
            return(Result);
        }
Esempio n. 3
0
        /// <summary>
        /// 返回机组指标得分排名情况
        /// </summary>
        /// <param name="UnitID"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <returns></returns>
        public List <KPIRankEntity> GetKPIRank(String UnitID, DateTime StartDate, DateTime EndDate)
        {
            RelaInterface DataBase = DBAccess.GetRelation();

            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter("@UnitID", DbType.String),
                new SqlParameter("@StartDate", DbType.DateTime),
                new SqlParameter("@EndDate", DbType.DateTime)
            };
            parames[0].Value = UnitID;
            parames[1].Value = StartDate;
            parames[2].Value = EndDate;

            String SqlText = @"WITH MonitorDurationCTE AS(
	                            SELECT UnitID,Shift,Duration=SUM(Duration) FROM KPI_MonitorDuration
	                            WHERE CheckDate BETWEEN @StartDate AND @EndDate AND UnitID=@UnitID 
	                            GROUP BY UnitID,Shift),
                            KPIScoreCTE AS(
	                            SELECT A.UnitID,A.ECID,A.Shift,TotalScore=SUM(ISNULL(Score,0)) 
	                            FROM KPI_ECDayData A JOIN KPI_ECTag B ON A.ECID=B.ECID 
	                            WHERE  A.CheckDate BETWEEN @StartDate AND @EndDate AND A.UnitID=@UnitID AND 
	                                   B.ECWeb='JJZB' AND B.ECIsSnapshot=1
	                            GROUP BY A.UnitID,A.ECID,A.Shift),
                            KPIRankCTE AS(	
	                            SELECT A.*,TotalHours=C.Duration,AvgScore=A.TotalScore/C.Duration,
	                            DENSE_RANK() OVER(PARTITION BY A.ECID ORDER BY TotalScore/Duration DESC) as OrderNo
	                            FROM KPIScoreCTE  A  JOIN MonitorDurationCTE C ON A.UnitID=C.UnitID AND  A.Shift=C.Shift),
                            Shift1Rank AS(
                            SELECT  * FROM  KPIRankCTE  WHERE Shift=1),
                            Shift2Rank AS(
                            SELECT  * FROM  KPIRankCTE  WHERE Shift=2),
                            Shift3Rank AS(
                            SELECT  * FROM  KPIRankCTE  WHERE Shift=3),
                            Shift4Rank AS(
                            SELECT  * FROM  KPIRankCTE  WHERE Shift=4),
                            Shift5Rank AS(
                            SELECT  * FROM  KPIRankCTE  WHERE Shift=5),
                            CTE AS(
                                SELECT A.ECID,A.ECName,A.ECIndex,A.UnitID,
                                B.TotalScore Shift1Score,B.TotalHours Shift1Hours,B.AvgScore Shift1AvgScore, B.OrderNo Shift1Rank,
                                C.TotalScore Shift2Score,C.TotalHours Shift2Hours,C.AvgScore Shift2AvgScore, C.OrderNo Shift2Rank,
                                D.TotalScore Shift3Score,D.TotalHours Shift3Hours,D.AvgScore Shift3AvgScore, D.OrderNo Shift3Rank,
                                E.TotalScore Shift4Score,E.TotalHours Shift4Hours,E.AvgScore Shift4AvgScore, E.OrderNo Shift4Rank,
                                F.TotalScore Shift5Score,F.TotalHours Shift5Hours,F.AvgScore Shift5AvgScore, F.OrderNo Shift5Rank

                                FROM  KPI_ECTag A LEFT JOIN Shift1Rank B ON A.ECID=B.ECID
                                                  LEFT JOIN Shift2Rank C ON A.ECID=C.ECID
                                                  LEFT JOIN Shift3Rank D ON A.ECID=D.ECID
                                                  LEFT JOIN Shift4Rank E ON A.ECID=E.ECID
                                                  LEFT JOIN Shift5Rank F ON A.ECID=F.ECID                    
                                WHERE A.ECWeb='JJZB' AND A.ECIsSnapshot=1 AND A.UnitID=@UnitID )    
                            SELECT*FROM CTE";
            List <KPIRankEntity> Result;

            using (IDataReader Reader = DataBase.ExecuteReader(CommandType.Text, SqlText, parames)) {
                Result = Reader.FillGenericList <KPIRankEntity>();
            }
            return(Result);
        }
Esempio n. 4
0
        public List <InputTagEntity> GetInputTags(String TagCategory)
        {
            String SqlText = @"SELECT A.*,B.ConstantName TagCategory
                                FROM KPI_InputTag A JOIN KPI_Constant B ON A.InputType = B.ConstantValue
                                WHERE B.ConstantCode='M' AND A.InputType=@TagCategory";

            IDbDataParameter[] Parameters = new SqlParameter[] {
                new SqlParameter("@TagCategory", SqlDbType.Int)
            };
            Parameters[0].Value = TagCategory;
            List <InputTagEntity> Result;

            using (IDataReader Reader = m_DataAccess.ExecuteReader(CommandType.Text, SqlText, Parameters)) {
                Result = Reader.FillGenericList <InputTagEntity>();
            };
            return(Result);
        }
Esempio n. 5
0
        //Added by pyf 2013-11-01

        /// <summary>
        /// 获取运行人员配置数据
        /// </summary>
        /// <returns>运行人员配置实体</returns>
        public KPI_PersonEntity GetKPI_Person(String personID)
        {
            string           SqlText = @"SELECT A.*,B.UnitName,C.PositionName FROM KPI_Person A 
                                        LEFT JOIN KPI_Unit     B ON A.UnitID=B.UnitID
                                        LEFT JOIN KPI_Position C ON A.PositionID = C.PositionID
                               WHERE  A.PersonID=@PersonID";
            KPI_PersonEntity Result  = null;

            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter("@PersonID", DbType.String)
            };
            parames[0].Value = personID;
            using (IDataReader DataReader = m_DB.ExecuteReader(CommandType.Text, SqlText, parames)) {
                Result = DataReader.FillEntity <KPI_PersonEntity>();
                DataReader.Close();
            }
            return(Result);
        }
        /// <summary>
        ///获取日常管理考核得分所有数据
        ///<param name="Shift">值别</param>
        /// </summary>
        public List <ManagementScoreEntity> GetManagementScores(String Shift, String YearMonth)
        {
            List <ManagementScoreEntity> Result = null;
            string SqlText = @"SELECT A.*,B.InputDesc TagName FROM  KPI_ManagementScore A 
                               JOIN KPI_InputTag B ON A.TagID=B.InputID 
                               WHERE CONVERT(varchar(7),A.CheckDate,120)=@YearMonth AND Shift=@Shift";

            IDbDataParameter[] Parameters = new SqlParameter[] {
                new SqlParameter("@YearMonth", SqlDbType.VarChar),
                new SqlParameter("@Shift", SqlDbType.Int)
            };
            Parameters[0].Value = YearMonth;
            Parameters[1].Value = Shift;
            using (IDataReader DataReader = m_DataAccess.ExecuteReader(CommandType.Text, SqlText, Parameters)) {
                Result = DataReader.FillGenericList <ManagementScoreEntity>();
            };
            return(Result);
        }
Esempio n. 7
0
        /// <summary>
        ///获取所有快照数据
        /// </summary>
        public List <KPI_SATagValueEntity> GetKPI_SATagSnapshotValues(String Shift, DateTime ShiftStartTime,
                                                                      DateTime ShiftEndTime)
        {
            List <KPI_SATagValueEntity> Result = null;
            string SqlText = @"Proc_GetSATagSnapshotValue";

            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter("@ShiftStartDate", DbType.DateTime),
                new SqlParameter("@ShiftEndDate", DbType.DateTime),
                new SqlParameter("@Shift", DbType.String)
            };
            parames[0].Value = ShiftStartTime;
            parames[1].Value = ShiftEndTime;
            parames[2].Value = Shift;
            using (IDataReader Reader = DataBase.ExecuteReader(CommandType.StoredProcedure, SqlText, parames)) {
                Result = Reader.FillGenericList <KPI_SATagValueEntity>();
            }
            return(Result);
        }
Esempio n. 8
0
        /// <summary>
        ///获取安全指标与测点对应关系表所有数据
        /// </summary>
        public List <SATagMapEntity> GetSATagMaps(String SAID)
        {
            List <SATagMapEntity> Result = null;
            string           sqlText     = @"SELECT A.*,B.RealCode,B.RealDesc FROM KPI_SATagMap A 
								JOIN KPI_RealTag B ON A.RealID=B.RealID WHERE SAID=@SAID"                                ;
            IDbDataParameter SAIDParam   = new SqlParameter("@SAID", SAID);
            IDataReader      Reader      = m_DB.ExecuteReader(CommandType.Text, sqlText, SAIDParam);

            try {
                Result = Reader.FillGenericList <SATagMapEntity>();
            }
            finally {
                Reader.Close();
                Reader.Dispose();
            }

            return(Result);
        }
Esempio n. 9
0
        public List <KPI_PersonScore> SearchPersonScore(string personId, DateTime startTime, DateTime endTime)
        {
            SqlParameter[] parames = new SqlParameter[] {
                new SqlParameter(param_PersonId, DbType.String),
                new SqlParameter(param_StartTime, SqlDbType.DateTime),
                new SqlParameter(param_EndTime, SqlDbType.DateTime)
            };

            parames[0].Value = personId;
            parames[1].Value = startTime;
            parames[2].Value = endTime;
            IDataReader            reader          = null;
            List <KPI_PersonScore> personScoreList = new List <KPI_PersonScore>();

            try
            {
                reader = m_DB.ExecuteReader(CommandType.Text, sql_SearchPersonScore, parames);

                while (reader.Read())
                {
                    personScoreList.Add(new KPI_PersonScore
                    {
                        PersonID  = reader["PersonID"].ToString(),
                        CheckDate = (DateTime)reader["CheckDate"],
                        Score     = reader["Score"] == DBNull.Value ? null : (decimal?)reader["Score"]
                    });
                }

                reader.Close();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }
            return(personScoreList);
        }
Esempio n. 10
0
        /// <summary>
        /// 返回值得分与奖金
        /// </summary>
        /// <param name="yearMonth">年月</param>
        /// <param name="specialField">专业</param>
        /// <returns></returns>
        public List <ShiftScoreAndBonusEntity> GetShiftScoreAndBonus(string yearMonth, String specialField)
        {
            List <ShiftScoreAndBonusEntity> Result = new List <ShiftScoreAndBonusEntity>();
            string SqlText = @"WITH ShiftScoreCTE AS(
								SELECT YearMonth=CONVERT(varchar(7),CheckDate,120),UnitID,Shift,
								ECScore=SUM(ECScore),SASCore=SUM(SASCore),TotalScore=SUM(TotalScore) FROM KPI_ShiftScore 
								WHERE SpecialField=@SpecialField AND CONVERT(varchar(7),CheckDate,120) =@YearMonth
								GROUP BY CheckDate,UnitID,Shift),
								MonitorDurationCTE AS(
								SELECT UnitID,Shift,Duration=SUM(Duration) FROM KPI_MonitorDuration
								WHERE CONVERT(Varchar(7),CheckDate,120) =@YearMonth
								GROUP BY UnitID,Shift)
								SELECT B.*,AvgScore =TotalScore/Duration,A.Bonus,C.UnitName,
                                       DENSE_RANK() OVER(PARTITION BY A.UnitID ORDER BY TotalScore/Duration DESC) as OrderNo FROM KPI_ShiftBonus A JOIN(
									SELECT YearMonth,UnitID,Shift,
										   ECScore=SUM(ECScore),SASCore=SUM(SASCore),TotalScore=SUM(TotalScore)
									FROM ShiftScoreCTE GROUP BY YearMonth,UnitID,Shift) B 
								ON A.UnitID=B.UnitID AND A.CheckYearMonth=B.YearMonth AND A.Shift=B.Shift 
								JOIN KPI_Unit C ON A.UnitID=C.UnitID
                                JOIN MonitorDurationCTE D ON A.UnitID=D.UnitID AND A.Shift=D.Shift
								WHERE A.SpecialField=@SpecialField AND A.CheckYearMonth=@YearMonth
								ORDER BY UnitID,Shift"                                ;

            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter("@SpecialField", DbType.String),
                new SqlParameter("@YearMonth", DbType.String)
            };
            parames[0].Value = specialField;
            parames[1].Value = yearMonth;
            using (IDataReader DataReader = DataBase.ExecuteReader(CommandType.Text, SqlText, parames)) {
                Result = DataReader.FillGenericList <ShiftScoreAndBonusEntity>();
                DataReader.Close();
            }
            //汇总
            ShiftScoreAndBonusEntity Total = new ShiftScoreAndBonusEntity();

            Total.UnitName   = "合计";
            Total.ECScore    = Result.Sum(p => p.ECScore);
            Total.SASCore    = Result.Sum(p => p.SASCore);
            Total.TotalScore = Result.Sum(p => p.TotalScore);
            Total.Bonus      = Result.Sum(p => p.Bonus);
            Result.Add(Total);
            return(Result);
        }
Esempio n. 11
0
        public List <KPI_OverLimitRecordEntity> GetOverLimitRecordEntityList(DateTime startTime, DateTime endTime, int startIndex, int pageSize, out int totalCount)
        {
            SqlParameter[] parames = new SqlParameter[] {
                new SqlParameter(param_StartTime, SqlDbType.DateTime),
                new SqlParameter(param_EndTime, SqlDbType.DateTime),
                new SqlParameter(param_PageIndex, DbType.Int32),
                new SqlParameter(param_PageSize, DbType.Int32),
                new SqlParameter(param_RowCount, DbType.Int32),
            };

            parames[0].Value     = startTime;
            parames[1].Value     = endTime;
            parames[2].Value     = startIndex;
            parames[3].Value     = pageSize;
            parames[4].Direction = ParameterDirection.Output;
            IDataReader reader = null;
            List <KPI_OverLimitRecordEntity> overLimitRecordEntityList = new List <KPI_OverLimitRecordEntity>();

            try {
                reader = m_DB.ExecuteReader(CommandType.StoredProcedure, pro_OverLimitRecord, parames);
                while (reader.Read())
                {
                    overLimitRecordEntityList.Add(new KPI_OverLimitRecordEntity {
                        AlarmID        = reader["AlarmID"].ToString(),
                        TagID          = reader["TagID"] == DBNull.Value ? string.Empty : reader["TagID"].ToString(),
                        KpiName        = reader["RealDesc"] == DBNull.Value ? string.Empty : reader["RealDesc"].ToString(),
                        AlarmStartTime = reader["AlarmStartTime"] == DBNull.Value ? null : (DateTime?)reader["AlarmStartTime"],
                        AlarmEndTime   = reader["AlarmEndTime"] == DBNull.Value ? null : (DateTime?)reader["AlarmEndTime"],
                        Duration       = reader["Duration"] == DBNull.Value ? null : (int?)reader["Duration"],
                        AlarmValue     = reader["AlarmValue"] == DBNull.Value ? null : (decimal?)reader["AlarmValue"],
                        StandardValue  = reader["StandardValue"] == DBNull.Value ? null : (decimal?)reader["StandardValue"],
                        Offset         = reader["Offset"] == DBNull.Value ? null : (decimal?)reader["Offset"],
                        AlarmType      = reader["AlarmType"] == DBNull.Value ? null : (int?)reader["AlarmType"],
                        Shift          = reader["Shift"] == DBNull.Value ? string.Empty : reader["Shift"].ToString(),
                        Period         = reader["Period"] == DBNull.Value ? string.Empty : (String)reader["Period"],
                        //ShiftName = reader["ShiftName"] == DBNull.Value ? string.Empty : reader["ShiftName"].ToString(),
                        UnitID   = reader["UnitID"] == DBNull.Value ? string.Empty : reader["UnitID"].ToString(),
                        UnitName = reader["UnitName"] == DBNull.Value ? string.Empty : reader["UnitName"].ToString()
                    });
                }

                reader.Close();
                if (parames[4].Value != DBNull.Value)
                {
                    totalCount = Convert.ToInt32(parames[4].Value);
                }
                else
                {
                    totalCount = 0;
                }
            }
            catch (Exception ex) {
                throw ex;
            }
            finally {
                if (!reader.IsClosed)
                {
                    reader.Close();
                }
            }


            return(overLimitRecordEntityList);
        }
Esempio n. 12
0
        /// <summary>
        /// 指标对比分析
        /// </summary>
        /// <param name="UnitID"></param>
        /// <param name="StartDate"></param>
        /// <param name="EndDate"></param>
        /// <param name="HStartDate"></param>
        /// <param name="HEndDate"></param>
        /// <returns></returns>
        public List <KPIContrastEntity> GetKPIContrast(String UnitID, DateTime StartDate, DateTime EndDate,
                                                       DateTime HStartDate, DateTime HEndDate)
        {
            RelaInterface DataBase = DBAccess.GetRelation();

            IDbDataParameter[] parames = new SqlParameter[] {
                new SqlParameter("@UnitID", DbType.String),
                new SqlParameter("@StartDate", DbType.DateTime),
                new SqlParameter("@EndDate", DbType.DateTime),
                new SqlParameter("@LStartDate", DbType.DateTime),
                new SqlParameter("@LEndDate", DbType.DateTime)
            };
            parames[0].Value = UnitID;
            parames[1].Value = StartDate;
            parames[2].Value = EndDate;
            parames[3].Value = HStartDate;
            parames[4].Value = HEndDate;

            String SqlText = @"WITH Shift1CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='1' AND CheckDate BETWEEN @StartDate AND @EndDate
                                GROUP BY ECID),
                                Shift2CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='2' AND CheckDate BETWEEN @StartDate AND @EndDate
                                GROUP BY ECID),
                                Shift3CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='3' AND CheckDate BETWEEN @StartDate AND @EndDate
                                GROUP BY ECID),
                                Shift4CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='4' AND CheckDate BETWEEN @StartDate AND @EndDate
                                GROUP BY ECID),
                                Shift5CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='5' AND CheckDate BETWEEN @StartDate AND @EndDate
                                GROUP BY ECID),

                                LShift1CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='1' AND CheckDate BETWEEN @LStartDate AND @LEndDate
                                GROUP BY ECID),
                                LShift2CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='2' AND CheckDate BETWEEN @LStartDate AND @LEndDate
                                GROUP BY ECID),
                                LShift3CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='3' AND CheckDate BETWEEN @LStartDate AND @LEndDate
                                GROUP BY ECID),
                                LShift4CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='4' AND CheckDate BETWEEN @LStartDate AND @LEndDate
                                GROUP BY ECID),
                                LShift5CTE AS(
                                SELECT ECID,AVG(ISNULL(AvgValue,0)) AvgValue,
                                DENSE_RANK() OVER(ORDER BY AVG(ISNULL(AvgValue,0)) DESC) as OrderNo
                                FROM KPI_ECDayData
                                WHERE Shift ='5' AND CheckDate BETWEEN @LStartDate AND @LEndDate
                                GROUP BY ECID),

                                CTE AS(
                                SELECT A.UnitID,A.ECID,A.ECName,A.ECIndex,
                                B.AvgValue Shift1Value,B.OrderNo Shift1Rank,
                                C.AvgValue Shift2Value,C.OrderNo Shift2Rank,
                                D.AvgValue Shift3Value,D.OrderNo Shift3Rank,
                                E.AvgValue Shift4Value,E.OrderNo Shift4Rank,
                                F.AvgValue Shift5Value,F.OrderNo Shift5Rank,

                                G.AvgValue Shift1HValue,G.OrderNo Shift1HRank,
                                H.AvgValue Shift2HValue,H.OrderNo Shift2HRank,
                                J.AvgValue Shift3HValue,J.OrderNo Shift3HRank,
                                K.AvgValue Shift4HValue,K.OrderNo Shift4HRank,
                                I.AvgValue Shift5HValue,I.OrderNo Shift5HRank
                                FROM  KPI_ECTag A LEFT JOIN Shift1CTE B ON A.ECID=B.ECID
                                                  LEFT JOIN Shift2CTE C ON A.ECID=C.ECID
                                                  LEFT JOIN Shift3CTE D ON A.ECID=D.ECID
                                                  LEFT JOIN Shift4CTE E ON A.ECID=E.ECID
                                                  LEFT JOIN Shift5CTE F ON A.ECID=F.ECID
                  
                                                  LEFT JOIN LShift1CTE G ON A.ECID=G.ECID
                                                  LEFT JOIN LShift2CTE H ON A.ECID=H.ECID
                                                  LEFT JOIN LShift3CTE J ON A.ECID=J.ECID
                                                  LEFT JOIN LShift4CTE K ON A.ECID=K.ECID
                                                  LEFT JOIN LShift5CTE I ON A.ECID=I.ECID
                                WHERE A.ECWeb='JJZB' AND A.ECIsSnapshot=1 AND UnitID=@UnitID)
                                SELECT * FROM CTE ORDER BY ECIndex";
            List <KPIContrastEntity> Result;

            using (IDataReader Reader = DataBase.ExecuteReader(CommandType.Text, SqlText, parames)) {
                Result = Reader.FillGenericList <KPIContrastEntity>();
            }
            return(Result);
        }