//取得Line相关的Station数据显示列表,按order排序  ok
        //参数winId: window id
        //lineId: LineID,用户Line 表 的id
        private static List<FamilyShowingInfo> GetShowInfoStationListByLineAndWinId(String winId, String lineId, String stationDataTableName, String fmlDspField, String IsSaStage)
        {
            List<FamilyShowingInfo> result = new List<FamilyShowingInfo>();

            String connectString = DatabaseUtil.GetConnectionString();
            String sqlString = "";

            StringBuilder sqlStringBuilder = new StringBuilder();
            sqlStringBuilder.Append("SELECT Dashboard_Family_Target.WindowsID, ")
                            .Append("RTRIM(LTRIM(Dashboard_Family_Target.Line)) AS Line, ")
                            .Append("RTRIM(LTRIM(Dashboard_Family_Target.Family)) AS Family, ")
                            .Append("RTRIM(LTRIM(Dashboard_Family_Target.Series)) AS Series, ")
                            .Append("ISNULL(Dashboard_Family_Target.[Plan],0) AS [Plan], ")
                            .Append("ISNULL(Dashboard_Family_Data.Output,0) AS Output, ")
                            .Append("ISNULL(Dashboard_Family_Data.DefectQty,0) AS DefectQty, ")
                            .Append("ISNULL(Dashboard_Family_Data.Input,0) AS Input, ")
                            .Append("ISNULL(Dashboard_Family_Data.AOI_Output,0) AS AOI_Output, ")
                            .Append("ISNULL(Dashboard_Family_Data.AOI_Defect,0) AS AOI_Defect, ")
                            .Append("ISNULL(Dashboard_Family_Data.ICT_Input,0) AS ICT_Input, ")
                            .Append("ISNULL(Dashboard_Family_Data.ICT_Defect,0) AS ICT_Defect ")
                            .Append("FROM Dashboard_Family_Target ")
                            .Append("LEFT OUTER JOIN ")
                            .Append(stationDataTableName)
                            .Append(" AS [Dashboard_Family_Data] ")
                            .Append("ON [Dashboard_Family_Target].Line=[Dashboard_Family_Data].Line ")
                            .Append("AND [Dashboard_Family_Target].Family=[Dashboard_Family_Data].Family ")
                            .Append("AND [Dashboard_Family_Target].Series=[Dashboard_Family_Data].Series ")
                            .Append("WHERE Dashboard_Family_Target.WindowsID=@param1 AND ")
                            .Append("RTRIM(LTRIM(Dashboard_Family_Target.Line))=@param2 ")
                            .Append("ORDER BY Dashboard_Family_Target.[Order]");

            sqlString = sqlStringBuilder.ToString();


            //stationDataTableNam
            List<ConditionValueSet> paramList = new List<ConditionValueSet>();
            ConditionValueSet param1 = new ConditionValueSet();
            param1.ParamName = "@param1";
            param1.DataType = "char(32)";
            param1.ParamValue = winId;
            paramList.Add(param1);

            //!!varchar(32)
            ConditionValueSet param2 = new ConditionValueSet();
            param2.ParamName = "@param2";
            param2.DataType = "char(10)";
            param2.ParamValue = lineId;
            paramList.Add(param2);

            DataTable StationResult = DatabaseUtil.GetResultBySQL(sqlString, connectString, paramList);


            int sumPlan = 0;
            int sumOutput = 0;
            int sumDefect = 0;
            int sumInput = 0;
            int sumICTInput = 0;
            int sumICTDefect = 0;
            int sumAOIOutput = 0;
            int sumAOIDefect = 0;

            SaStationDisplayFieldInfo displayFieldInfosSa = new SaStationDisplayFieldInfo();
            SmtStationDisplayFieldInfo displayFieldInfosSmt = new SmtStationDisplayFieldInfo();

            if (IsSaStage == "True")
            {
                if (fmlDspField != "")
                {
                    displayFieldInfosSa = DashboardManager.SaStationDisplayFieldsString2Struct(fmlDspField);
                }

            }
            else  //Smt
            {
                if (fmlDspField != "")
                {
                    displayFieldInfosSmt = DashboardManager.SmtStationDisplayFieldsString2Struct(fmlDspField);
                }
            }



            for (int i = 0; i < StationResult.Rows.Count; i++)
            {
                FamilyShowingInfo StationInfo = new FamilyShowingInfo();

                String Family = GeneralUtil.Null2String(StationResult.Rows[i]["Family"]);
                String Series = GeneralUtil.Null2String(StationResult.Rows[i]["Series"]);
                String Plan = GeneralUtil.Null2String(StationResult.Rows[i]["Plan"]);
                String Output = GeneralUtil.Null2String(StationResult.Rows[i]["Output"]);
                String DefectQty = GeneralUtil.Null2String(StationResult.Rows[i]["DefectQty"]);

                String Input = GeneralUtil.Null2String(StationResult.Rows[i]["Input"]);
                String AOI_Output = GeneralUtil.Null2String(StationResult.Rows[i]["AOI_Output"]);
                String AOI_Defect = GeneralUtil.Null2String(StationResult.Rows[i]["AOI_Defect"]);
                String ICT_Input = GeneralUtil.Null2String(StationResult.Rows[i]["ICT_Input"]);
                String ICT_Defect = GeneralUtil.Null2String(StationResult.Rows[i]["ICT_Defect"]);
                
                StationInfo.AOIDefect = AOI_Defect;
                StationInfo.AOIOutput = AOI_Output;
                StationInfo.Defect = DefectQty;
                StationInfo.Family = Family;
                StationInfo.ICTDefect = ICT_Defect;
                StationInfo.ICTInput = ICT_Input;
                //StationInfo.ICTYield=
                StationInfo.Input = Input;
                StationInfo.Output = Output;
                StationInfo.Plan = Plan;
                //StationInfo.Progress 
                StationInfo.Series = Series;
                //StationInfo.YieldRate

                sumPlan += Int32.Parse(Plan);
                sumOutput += Int32.Parse(Output);
                sumDefect += Int32.Parse(DefectQty);
                sumInput += Int32.Parse(Input);
                sumICTInput += Int32.Parse(ICT_Input);
                sumICTDefect += Int32.Parse(ICT_Defect);
                sumAOIOutput += Int32.Parse(AOI_Output);
                sumAOIDefect += Int32.Parse(AOI_Defect);


                if (IsSaStage == "True")
                {
                    StationInfo.IsDefectDsp = displayFieldInfosSa.IsDefectDsp;
                    StationInfo.IsICTDefectDsp = displayFieldInfosSa.IsICTDefectDsp;
                    StationInfo.IsICTInputDsp = displayFieldInfosSa.IsICTInputDsp;
                    StationInfo.IsICTYieldRateDsp = displayFieldInfosSa.IsICTYieldRateDsp;
                    StationInfo.IsInputDsp = displayFieldInfosSa.IsInputDsp;
                    StationInfo.IsYieldRateDsp = displayFieldInfosSa.IsYieldRateDsp;

                }
                else  //Smt
                {
                    StationInfo.IsDefectDsp = displayFieldInfosSmt.IsDefectDsp;
                    StationInfo.IsAOIDefectDsp = displayFieldInfosSmt.IsAOIDefectDsp;
                    StationInfo.IsAOIOutputDsp = displayFieldInfosSmt.IsAOIOutputDsp;
                    StationInfo.IsInputDsp = displayFieldInfosSmt.IsInputDsp;
                    StationInfo.IsYieldRateDsp = displayFieldInfosSmt.IsYieldRateDsp;
                }

                string ICTYield = GetYieldRate(ICT_Input, ICT_Defect);
                StationInfo.ICTYield = ICTYield;


                string YieldRate = GetYieldRate(Output, DefectQty);
                StationInfo.YieldRate = YieldRate;

                //算Progress
                string Progress = GetProgress(Plan, Output);
                StationInfo.Progress = Progress;

                result.Add(StationInfo);
            }

            FamilyShowingInfo StationSumInfo = new FamilyShowingInfo();

            if (IsSaStage == "True")
            {
                StationSumInfo.IsDefectDsp = displayFieldInfosSa.IsDefectDsp;
                StationSumInfo.IsICTDefectDsp = displayFieldInfosSa.IsICTDefectDsp;
                StationSumInfo.IsICTInputDsp = displayFieldInfosSa.IsICTInputDsp;
                StationSumInfo.IsICTYieldRateDsp = displayFieldInfosSa.IsICTYieldRateDsp;
                StationSumInfo.IsInputDsp = displayFieldInfosSa.IsInputDsp;
                StationSumInfo.IsYieldRateDsp = displayFieldInfosSa.IsYieldRateDsp;

            }
            else  //Smt
            {
                StationSumInfo.IsDefectDsp = displayFieldInfosSmt.IsDefectDsp;
                StationSumInfo.IsAOIDefectDsp = displayFieldInfosSmt.IsAOIDefectDsp;
                StationSumInfo.IsAOIOutputDsp = displayFieldInfosSmt.IsAOIOutputDsp;
                StationSumInfo.IsInputDsp = displayFieldInfosSmt.IsInputDsp;
                StationSumInfo.IsYieldRateDsp = displayFieldInfosSmt.IsYieldRateDsp;
            }


            if (StationResult.Rows.Count > 0)
            {

                StationSumInfo.Plan = sumPlan.ToString();
                StationSumInfo.Output = sumOutput.ToString();
                StationSumInfo.Defect = sumDefect.ToString();
                StationSumInfo.Input = sumInput.ToString();
                StationSumInfo.ICTInput = sumICTInput.ToString();
                StationSumInfo.ICTDefect = sumICTDefect.ToString();
                StationSumInfo.AOIOutput = sumAOIOutput.ToString();
                StationSumInfo.AOIDefect = sumAOIDefect.ToString();

                StationSumInfo.ICTYield = GetYieldRate(StationSumInfo.ICTInput, StationSumInfo.ICTDefect);
                StationSumInfo.YieldRate = GetYieldRate(StationSumInfo.Output, StationSumInfo.Defect);
                StationSumInfo.Progress = GetProgress(StationSumInfo.Plan, StationSumInfo.Output);

                StationSumInfo.Family = "Total";
                StationSumInfo.Series = "&nbsp";
            }
            else
            {
                StationSumInfo.Plan = "0";
                StationSumInfo.Output = "0";
                StationSumInfo.Defect = "0";
                StationSumInfo.Input = "0";
                StationSumInfo.ICTInput = "0";
                StationSumInfo.ICTDefect = "0";
                StationSumInfo.AOIOutput = "0";
                StationSumInfo.AOIDefect = "0";

                StationSumInfo.ICTYield = "";
                StationSumInfo.YieldRate = "";
                StationSumInfo.Progress = "";

                StationSumInfo.Family = "Total";
                StationSumInfo.Series = "&nbsp";

            }

            result.Add(StationSumInfo);
            return result;

        }
Example #2
0
        //这部分字段顺序固定  ok
        //this.isInputDsp 
        //this.isDefectDsp 
        //this.isYieldRateDsp 
        //this.isICTInputDsp 
        //this.isICTDefectDsp 
        //this.isICTYieldRateDsp
        public static SaStationDisplayFieldInfo SaStationDisplayFieldsString2Struct(String DisplayFieldsString)
        {
            SaStationDisplayFieldInfo result = new SaStationDisplayFieldInfo();

            //如 "Quantilt=true". 逗号分隔
            String[] separator = { "," };
            String[] values = DisplayFieldsString.Split(separator, StringSplitOptions.None);
            String[] separatorNext = { "=" };

            String[] DspInfos0 = values[0].Split(separatorNext, StringSplitOptions.None);
            if (DspInfos0[1].ToLower() == "true")
            {
                result.IsInputDsp = "True";
            }
            else
            {
                result.IsInputDsp = "False";
            }

            String[] DspInfos1 = values[1].Split(separatorNext, StringSplitOptions.None);
            if (DspInfos1[1].ToLower() == "true")
            {
                result.IsDefectDsp = "True";
            }
            else
            {
                result.IsDefectDsp = "False";
            }

            String[] DspInfos2 = values[2].Split(separatorNext, StringSplitOptions.None);
            if (DspInfos2[1].ToLower() == "true")
            {
                result.IsYieldRateDsp = "True";
            }
            else
            {
                result.IsYieldRateDsp = "False";
            }

            String[] DspInfos3 = values[3].Split(separatorNext, StringSplitOptions.None);
            if (DspInfos3[1].ToLower() == "true")
            {
                result.IsICTInputDsp = "True";
            }
            else
            {
                result.IsICTInputDsp = "False";
            }

            String[] DspInfos4 = values[4].Split(separatorNext, StringSplitOptions.None);
            if (DspInfos4[1].ToLower() == "true")
            {
                result.IsICTDefectDsp = "True";
            }
            else
            {
                result.IsICTDefectDsp = "False";
            }

            String[] DspInfos5 = values[5].Split(separatorNext, StringSplitOptions.None);
            if (DspInfos5[1].ToLower() == "true")
            {
                result.IsICTYieldRateDsp = "True";
            }
            else
            {
                result.IsICTYieldRateDsp = "False";
            }
            return result;

        }
Example #3
0
        public static DashboardWindowInfo GetDashboardWindowSetting(String WindowId,String StageType)
        {
            WindowId = GeneralUtil.Null2String(WindowId);

            DashboardWindowInfo result = new DashboardWindowInfo();

            if (WindowId == "")
            {
                return result;
            }
            else
            {
                DataTable DashboardMainInfo = GetEditDashboardMainByWinId(WindowId);
                if (DashboardMainInfo.Rows.Count == 0)
                {
                    ExceptionManager.Throw("The specified item has been removed.");
                }

                //还需要进一步转换添加等,注意每一位都要根据新的内容赋值
                result.WindowId = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["ID"]);
                result.WindowName = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["WindowName"]);

                result.DisplayName = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["DisplayName"]);
                result.AlertMessage = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["AlertMessage"]);
                result.RefreshTime = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["RefreshTime"]);

                TimeInfo timeInfos = new TimeInfo();
                if (result.RefreshTime != "")
                {
                    int freshTime = Int32.Parse(result.RefreshTime);
                    timeInfos = TimeInt2Struct(freshTime);

                }
                result.Hour = timeInfos.Hour;
                result.Second = timeInfos.Second;
                result.Minute = timeInfos.Minute;

                result.DataSourceType = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["DataSourceType"]);
                result.StageTargetId = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StageTargetId"]);
                result.StageId = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StageId"]);
                result.StageName = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StageName"]);
                result.IsStageDisplay = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["IsStageDsp"]);
                result.StartWorkTime = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StartWorkTime"]);

                TimeInfo startWorkInfos = new TimeInfo();
                if (result.StartWorkTime != "")
                {
                    startWorkInfos = TimeString2Struct(result.StartWorkTime);

                }

                result.StartWorkTimeHour = startWorkInfos.Hour;
                result.StartWorkTimeMinute = startWorkInfos.Minute;

                result.StopWorkTime = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["StopWorkTime"]);

                TimeInfo stopWorkInfos = new TimeInfo();
                if (result.StopWorkTime != "")
                {
                    stopWorkInfos = TimeString2Struct(result.StopWorkTime);

                }

                result.StopWorkTimeHour = stopWorkInfos.Hour;
                result.StopWorkTimeMinute = stopWorkInfos.Minute;

                result.DisplayFields = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["DisplayFields"]);

                StageDisplayFieldInfo displayFieldInfos = new StageDisplayFieldInfo();

                if (result.DisplayFields != "")
                {
                    displayFieldInfos = StageDisplayFieldsString2Struct(result.DisplayFields);

                }

                result.IsGoalDisplay = displayFieldInfos.IsGoalDisplay;
                result.IsInputDisplay = displayFieldInfos.IsInputDisplay;
                result.IsOutputDisplay = displayFieldInfos.IsOutputDisplay;
                result.IsRateDisplay = displayFieldInfos.IsRateDisplay;

                result.Cdt = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["Cdt"]);
                result.Udt = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["Udt"]);
                result.Editor = GeneralUtil.Null2String(DashboardMainInfo.Rows[0]["Editor"]);

                DataTable LineResult = GetEditLineListByWinId(WindowId);


                for (int i = 0; i < LineResult.Rows.Count; i++)
                {
                    WindowLineInfo lineInfo = new WindowLineInfo();
                    lineInfo.LineTargetId = GeneralUtil.Null2String(LineResult.Rows[i]["LineTargetId"]);
                    lineInfo.LineID = GeneralUtil.Null2String(LineResult.Rows[i]["LineId"]);
                    lineInfo.Stage = GeneralUtil.Null2String(LineResult.Rows[i]["SatgeName"]);
                    lineInfo.Line = GeneralUtil.Null2String(LineResult.Rows[i]["LineName"]);
                    //lineInfo.FPYTarget = GeneralUtil.Null2String(LineResult.Rows[i]["FPYTarget"]);
                    //lineInfo.FPYAlert = GeneralUtil.Null2String(LineResult.Rows[i]["FPYAlert"]);
                    //lineInfo.OutputTarget = GeneralUtil.Null2String(LineResult.Rows[i]["OutputTarget"]);
                    lineInfo.StartWork = GeneralUtil.Null2String(LineResult.Rows[i]["StartWorkTime"]);
                    lineInfo.Shift = GeneralUtil.Null2String(LineResult.Rows[i]["Shift"]);

                    String FmlDspField = GeneralUtil.Null2String(LineResult.Rows[i]["FmlDspField"]);

                    if (StageType == Constants.SA_STAGE.ToString())
                    {
                        SaStationDisplayFieldInfo info = new SaStationDisplayFieldInfo();
                        info = SaStationDisplayFieldsString2Struct(FmlDspField);
                        lineInfo.IsDefectDsp = info.IsDefectDsp;
                        lineInfo.IsInputDsp = info.IsInputDsp;
                        lineInfo.IsYieldRateDsp = info.IsYieldRateDsp;
                        lineInfo.IsICTDefectDsp = info.IsICTDefectDsp;
                        lineInfo.IsICTInputDsp = info.IsICTInputDsp;
                        lineInfo.IsICTYieldRateDsp = info.IsICTYieldRateDsp;
                    }
                    else
                    {
                        SmtStationDisplayFieldInfo info = new SmtStationDisplayFieldInfo();
                        info = SmtStationDisplayFieldsString2Struct(FmlDspField);
                        lineInfo.IsDefectDsp = info.IsDefectDsp;
                        lineInfo.IsInputDsp = info.IsInputDsp;
                        lineInfo.IsYieldRateDsp = info.IsYieldRateDsp;
                        lineInfo.IsAOIDefectDsp = info.IsAOIDefectDsp;
                        lineInfo.IsAOIOutputDsp = info.IsAOIOutputDsp;
                    }


                    TimeInfo lineStartWorkInfos = new TimeInfo();
                    if (lineInfo.StartWork != "")
                    {
                        lineStartWorkInfos = TimeString2Struct(lineInfo.StartWork);

                    }
                    lineInfo.StartWorkHour = lineStartWorkInfos.Hour;
                    lineInfo.StartWorkMinute = lineStartWorkInfos.Minute;

                    lineInfo.StopWork = GeneralUtil.Null2String(LineResult.Rows[i]["StopWorkTime"]);

                    TimeInfo lineStopWorkInfos = new TimeInfo();
                    if (lineInfo.StopWork != "")
                    {
                        lineStopWorkInfos = TimeString2Struct(lineInfo.StopWork);

                    }
                    lineInfo.StopWorkHour = lineStopWorkInfos.Hour;
                    lineInfo.StopWorkMinute = lineStopWorkInfos.Minute;

                    //lineInfo.StationDisplay = GeneralUtil.Null2String(LineResult.Rows[i]["IsStationDsp"]);
                    lineInfo.Order = GeneralUtil.Null2String(LineResult.Rows[i]["SortOrder"]);
                    List<WindowLineFamilyInfo> StationResult = GetEditStationListByLineAndWinId(WindowId, lineInfo.LineID);
                    lineInfo.WindowLineFamilyInfos = StationResult;
                    result.WindowLineInfos.Add(lineInfo);
                    
                }
                return result;
            }
        }
Example #4
0
        public static WindowLineInfo GetLineBaseSettingInfo(String lineId,Boolean isSaStage)
        {
            WindowLineInfo result = new WindowLineInfo();
            String connectString = DatabaseUtil.GetConnectionString();

            String sqlString = "SELECT top 1 [StartWorkTime],[StopWorkTime],[Shift],[FmlDspField] FROM [Dashboard_Line_Target] WHERE [Line]=@param1";
            List<ConditionValueSet> paramList = new List<ConditionValueSet>();
            ConditionValueSet param1 = new ConditionValueSet();
            param1.ParamName = "@param1";
            param1.DataType = "char(10)";
            param1.ParamValue = lineId;
            paramList.Add(param1);

            DataTable sqlResult = DatabaseUtil.GetResultBySQL(sqlString, connectString, paramList);
            if (sqlResult.Rows.Count > 0)
            {

                result.Shift  = GeneralUtil.Null2String(sqlResult.Rows[0]["Shift"]);

                String FmlDspField = GeneralUtil.Null2String(sqlResult.Rows[0]["FmlDspField"]);

                if (isSaStage == true)
                {
                    SaStationDisplayFieldInfo displayFieldInfos = new SaStationDisplayFieldInfo();

                    if (FmlDspField != "")
                    {
                        displayFieldInfos = SaStationDisplayFieldsString2Struct(FmlDspField);
                        result.IsDefectDsp = displayFieldInfos.IsDefectDsp;
                        result.IsICTDefectDsp  = displayFieldInfos.IsICTDefectDsp;
                        result.IsICTInputDsp = displayFieldInfos.IsICTInputDsp;
                        result.IsICTYieldRateDsp = displayFieldInfos.IsICTYieldRateDsp;
                        result.IsInputDsp = displayFieldInfos.IsInputDsp;
                        result.IsYieldRateDsp = displayFieldInfos.IsYieldRateDsp;
                        
                    }

                }
                else
                {
                    SmtStationDisplayFieldInfo displayFieldInfos = new SmtStationDisplayFieldInfo();

                    if (FmlDspField != "")
                    {
                        displayFieldInfos = SmtStationDisplayFieldsString2Struct(FmlDspField);
                        result.IsDefectDsp = displayFieldInfos.IsDefectDsp;
                        result.IsAOIDefectDsp = displayFieldInfos.IsAOIDefectDsp;
                        result.IsAOIOutputDsp = displayFieldInfos.IsAOIOutputDsp;
                        result.IsInputDsp = displayFieldInfos.IsInputDsp;
                        result.IsYieldRateDsp = displayFieldInfos.IsYieldRateDsp;
                    }
                }

                String StartWorkTime = GeneralUtil.Null2String(sqlResult.Rows[0]["StartWorkTime"]);
                String StopWorkTime = GeneralUtil.Null2String(sqlResult.Rows[0]["StopWorkTime"]);

                TimeInfo startWorkInfos = new TimeInfo();
                if (StartWorkTime != "")
                {
                    startWorkInfos = TimeString2Struct(StartWorkTime);
                }
                TimeInfo stopWorkInfos = new TimeInfo();
                if (StopWorkTime != "")
                {
                    stopWorkInfos = TimeString2Struct(StopWorkTime);
                }

                result.StartWorkHour = startWorkInfos.Hour;
                result.StartWorkMinute = startWorkInfos.Minute;
                result.StopWorkHour = stopWorkInfos.Hour;
                result.StopWorkMinute = stopWorkInfos.Minute;

            }
            return result;

        }
Example #5
0
        public static String SaveDashboardWindowSetting(DashboardWindowInfo windowInfo, String stageType)
        {
            String connectString = DatabaseUtil.GetConnectionString();

            String windowId = GeneralUtil.Null2String(windowInfo.WindowId);
            String windowName = GeneralUtil.Null2String(windowInfo.WindowName);

            //String stage=GeneralUtil.Null2String(windowInfo.StageId);
            String sqlString = "";
            StringBuilder sqlStringBuilder = new StringBuilder();

            //同时更新全部相同的stage的start work和stop work的所有SQL
            StringBuilder sqlStageUpdateAllStringBuilder = new StringBuilder();
            //同时更新全部相同的line的start work和stop work的所有SQL
            StringBuilder sqlLineUpdateAllStringBuilder = new StringBuilder();

            List<ConditionValueSet> paramList = new List<ConditionValueSet>();
            int paramIndex = 0;

            //如果原先有数据,先删除
            if (windowId != "")
            {
                CheckWindowSettingExist(windowId);

                ConditionValueSet paramItem = new ConditionValueSet();
                String paramName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramItem.ParamName = paramName;
                paramItem.DataType = "char(32)";
                paramItem.ParamValue = windowId;

                paramList.Add(paramItem);

                sqlStringBuilder.Append("DELETE FROM [Dashboard_Family_Target] WHERE WindowsID=").Append(paramName).Append(" ");
                sqlStringBuilder.Append("DELETE FROM [Dashboard_Line_Target] WHERE WindowsID=").Append(paramName).Append(" ");
                sqlStringBuilder.Append("DELETE FROM [Dashboard_Stage_Target] WHERE WindowID=").Append(paramName).Append(" ");
                sqlStringBuilder.Append("DELETE FROM [Dashboard_Window] WHERE ID=").Append(paramName).Append(" ");
            }
            else
            {
                //检查名称是否重复
                windowId = DatabaseUtil.GetUUID();
            }

            CheckWindowNameSame(windowName, windowId);

            ConditionValueSet paramItemWindowId = new ConditionValueSet();
            paramItemWindowId.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramItemWindowId.DataType = "char(32)";
            paramItemWindowId.ParamValue = windowId;
            paramList.Add(paramItemWindowId);

            ConditionValueSet paramWindowName = new ConditionValueSet();
            paramWindowName.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramWindowName.DataType = "nvarchar(128)";
            paramWindowName.ParamValue = windowName;
            paramList.Add(paramWindowName);

            ConditionValueSet paramDisplayName = new ConditionValueSet();
            paramDisplayName.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramDisplayName.DataType = "nvarchar(128)";
            paramDisplayName.ParamValue = GeneralUtil.Null2String(windowInfo.DisplayName);
            paramList.Add(paramDisplayName);


            ConditionValueSet paramAlertMessage = new ConditionValueSet();
            paramAlertMessage.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramAlertMessage.DataType = "nvarchar(512)";
            paramAlertMessage.ParamValue = GeneralUtil.Null2String(windowInfo.AlertMessage);
            paramList.Add(paramAlertMessage);

            TimeInfo timeInfos = new TimeInfo();
            timeInfos.Hour = windowInfo.Hour;
            timeInfos.Minute = windowInfo.Minute;
            timeInfos.Second = windowInfo.Second;
            int refreshTime = Struct2TimeInt(timeInfos);

            ConditionValueSet paramRefreshTime = new ConditionValueSet();
            paramRefreshTime.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramRefreshTime.DataType = "bigint";
            paramRefreshTime.ParamValue = refreshTime.ToString();
            paramList.Add(paramRefreshTime);

            ConditionValueSet paramDataSourceType = new ConditionValueSet();
            paramDataSourceType.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramDataSourceType.DataType = "int";
            paramDataSourceType.ParamValue = GeneralUtil.Null2String(windowInfo.DataSourceType);
            paramList.Add(paramDataSourceType);

            ConditionValueSet paramIsStageDsp = new ConditionValueSet();
            paramIsStageDsp.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramIsStageDsp.DataType = "bit";
            paramIsStageDsp.ParamValue = GeneralUtil.Null2String(windowInfo.IsStageDisplay);
            paramList.Add(paramIsStageDsp);

            ConditionValueSet paramCdt = new ConditionValueSet();
            //新建时
            if (windowInfo.Cdt != "")
            {
                paramCdt.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramCdt.DataType = "datetime";
                paramCdt.ParamValue = GeneralUtil.Null2String(windowInfo.Cdt);
                paramList.Add(paramCdt);
            }

            ConditionValueSet paramEditor = new ConditionValueSet();
            paramEditor.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramEditor.DataType = "nvarchar(100)";
            paramEditor.ParamValue = GeneralUtil.Null2String(windowInfo.Editor);
            paramList.Add(paramEditor);


            //create time由于没有地方修改,而保留了原来的create time
            sqlStringBuilder.Append("INSERT INTO [Dashboard_Window] ([ID],[WindowName],[DisplayName],[AlertMessage],[RefreshTime]")
                .Append(",[DataSourceType],[IsStageDsp],[Cdt],[Udt],[Editor]) VALUES(")
                .Append(paramItemWindowId.ParamName).Append(",")
                .Append(paramWindowName.ParamName).Append(",")
                .Append(paramDisplayName.ParamName).Append(",")
                .Append(paramAlertMessage.ParamName).Append(",")
                .Append(paramRefreshTime.ParamName).Append(",")
                .Append(paramDataSourceType.ParamName).Append(",")
                .Append(paramIsStageDsp.ParamName).Append(",");
            if (windowInfo.Cdt != "")
            {
                sqlStringBuilder.Append(paramCdt.ParamName).Append(",");
            }
            else
            {
                sqlStringBuilder.Append("getdate()").Append(",");
            }
            sqlStringBuilder.Append("getdate()").Append(",")
                .Append(paramEditor.ParamName)
                .Append(") ");



            ConditionValueSet paramStageTargetId = new ConditionValueSet();
            paramStageTargetId.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStageTargetId.DataType = "char(32)";
            paramStageTargetId.ParamValue = DatabaseUtil.GetUUID();
            paramList.Add(paramStageTargetId);

            ConditionValueSet paramStageId = new ConditionValueSet();
            paramStageId.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStageId.DataType = "char(10)";
            paramStageId.ParamValue = GeneralUtil.Null2String(windowInfo.StageId);
            paramList.Add(paramStageId);

            //window id见上面

            TimeInfo stageStartWorkTimeInfo = new TimeInfo();
            stageStartWorkTimeInfo.Hour = windowInfo.StartWorkTimeHour;
            stageStartWorkTimeInfo.Minute = windowInfo.StartWorkTimeMinute;
            String stageStartWorkTime = Struct2TimeString(stageStartWorkTimeInfo);

            ConditionValueSet paramStartWorkTime = new ConditionValueSet();
            paramStartWorkTime.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStartWorkTime.DataType = "datetime";
            paramStartWorkTime.ParamValue = stageStartWorkTime;
            paramList.Add(paramStartWorkTime);

            TimeInfo stageStopWorkTimeInfo = new TimeInfo();
            stageStopWorkTimeInfo.Hour = windowInfo.StopWorkTimeHour;
            stageStopWorkTimeInfo.Minute = windowInfo.StopWorkTimeMinute;
            String stageStopWorkTime = Struct2TimeString(stageStopWorkTimeInfo);

            ConditionValueSet paramStopWorkTime = new ConditionValueSet();
            paramStopWorkTime.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramStopWorkTime.DataType = "datetime";
            paramStopWorkTime.ParamValue = stageStopWorkTime;
            paramList.Add(paramStopWorkTime);

            StageDisplayFieldInfo stageDisplayFieldInfo = new StageDisplayFieldInfo();
            stageDisplayFieldInfo.IsGoalDisplay = windowInfo.IsGoalDisplay;
            stageDisplayFieldInfo.IsInputDisplay = windowInfo.IsInputDisplay;
            stageDisplayFieldInfo.IsOutputDisplay = windowInfo.IsOutputDisplay;
            stageDisplayFieldInfo.IsRateDisplay = windowInfo.IsRateDisplay;

            String stageDisplayFieldValue = Struct2StageDisplayFieldsString(stageDisplayFieldInfo);

            ConditionValueSet paramDisplayFields = new ConditionValueSet();
            paramDisplayFields.ParamName = "@param" + paramIndex;
            paramIndex = paramIndex + 1;
            paramDisplayFields.DataType = "varchar(100)";
            paramDisplayFields.ParamValue = stageDisplayFieldValue;
            paramList.Add(paramDisplayFields);

            StringBuilder sqlStageStringBuilder = new StringBuilder();
            sqlStageStringBuilder.Append("INSERT INTO [Dashboard_Stage_Target] ([ID],[Stage],[WindowID],[StartWorkTime],[StopWorkTime],[DisplayFields]) ")
                .Append("VALUES(")
                .Append(paramStageTargetId.ParamName).Append(",")
                .Append(paramStageId.ParamName).Append(",")
                .Append(paramItemWindowId.ParamName).Append(",")
                .Append(paramStartWorkTime.ParamName).Append(",")
                .Append(paramStopWorkTime.ParamName).Append(",")
                .Append(paramDisplayFields.ParamName)
                .Append(") ");

            sqlStageUpdateAllStringBuilder.Append("UPDATE [Dashboard_Stage_Target] SET [StartWorkTime] = ")
                .Append(paramStartWorkTime.ParamName).Append(",")
                .Append("[StopWorkTime] =")
                .Append(paramStopWorkTime.ParamName)
                .Append(" WHERE [Stage]=")
                .Append(paramStageId.ParamName).Append(" ");

            StringBuilder sqlLineStringBuilder = new StringBuilder();
            StringBuilder sqlStationStringBuilder = new StringBuilder();

            //判断windowId,如果不为空,先删除对应的station,line, stage window,再加入
            for (int i = 0; i < windowInfo.WindowLineInfos.Count; i++)
            {
                WindowLineInfo lineItem = windowInfo.WindowLineInfos[i];

                ConditionValueSet paramLineTargetId = new ConditionValueSet();
                paramLineTargetId.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineTargetId.DataType = "char(32)";
                paramLineTargetId.ParamValue = DatabaseUtil.GetUUID();
                paramList.Add(paramLineTargetId);

                ConditionValueSet paramLineId = new ConditionValueSet();
                paramLineId.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineId.DataType = "char(10)";
                paramLineId.ParamValue = GeneralUtil.Null2String(lineItem.LineID);
                paramList.Add(paramLineId);

                //ConditionValueSet paramOutputTarget = new ConditionValueSet();
                //paramOutputTarget.ParamName = "@param" + paramIndex;
                //paramIndex = paramIndex + 1;
                //paramOutputTarget.DataType = "int";
                //paramOutputTarget.ParamValue = GeneralUtil.Null2String(lineItem.OutputTarget);
                //paramList.Add(paramOutputTarget);

                //ConditionValueSet paramFPYTarget = new ConditionValueSet();
                //paramFPYTarget.ParamName = "@param" + paramIndex;
                //paramIndex = paramIndex + 1;
                //paramFPYTarget.DataType = "float";
                //paramFPYTarget.ParamValue = GeneralUtil.Null2String(lineItem.FPYTarget);
                //paramList.Add(paramFPYTarget);

                //ConditionValueSet paramFPYAlert = new ConditionValueSet();
                //paramFPYAlert.ParamName = "@param" + paramIndex;
                //paramIndex = paramIndex + 1;
                //paramFPYAlert.DataType = "float";
                //paramFPYAlert.ParamValue = GeneralUtil.Null2String(lineItem.FPYAlert);
                //paramList.Add(paramFPYAlert);

                TimeInfo lineStartWorkTimeInfo = new TimeInfo();
                lineStartWorkTimeInfo.Hour = lineItem.StartWorkHour;
                lineStartWorkTimeInfo.Minute = lineItem.StartWorkMinute;
                String lineStartWorkTime = Struct2TimeString(lineStartWorkTimeInfo);

                ConditionValueSet paramLineStartWorkTime = new ConditionValueSet();
                paramLineStartWorkTime.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineStartWorkTime.DataType = "datetime";
                paramLineStartWorkTime.ParamValue = lineStartWorkTime;
                paramList.Add(paramLineStartWorkTime);

                TimeInfo lineStopWorkTimeInfo = new TimeInfo();
                lineStopWorkTimeInfo.Hour = lineItem.StopWorkHour;
                lineStopWorkTimeInfo.Minute = lineItem.StopWorkMinute;
                String lineStopWorkTime = Struct2TimeString(lineStopWorkTimeInfo);

                ConditionValueSet paramLineStopWorkTime = new ConditionValueSet();
                paramLineStopWorkTime.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineStopWorkTime.DataType = "datetime";
                paramLineStopWorkTime.ParamValue = lineStopWorkTime;
                paramList.Add(paramLineStopWorkTime);

                ConditionValueSet paramShift = new ConditionValueSet();
                paramShift.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramShift.DataType = "varchar";
                paramShift.ParamValue = lineItem.Shift;
                paramList.Add(paramShift);

                String fmlDspField="";

                if (stageType ==Constants.SA_STAGE.ToString())
                {
                    SaStationDisplayFieldInfo DisplayFieldsInfo=new SaStationDisplayFieldInfo();

                    DisplayFieldsInfo.IsDefectDsp =lineItem.IsDefectDsp;
                    DisplayFieldsInfo.IsICTDefectDsp  =lineItem.IsICTDefectDsp;
                    DisplayFieldsInfo.IsICTInputDsp  =lineItem.IsICTInputDsp;
                    DisplayFieldsInfo.IsICTYieldRateDsp  =lineItem.IsICTYieldRateDsp;
                    DisplayFieldsInfo.IsInputDsp =lineItem.IsInputDsp;
                    DisplayFieldsInfo.IsYieldRateDsp =lineItem.IsYieldRateDsp;

                    fmlDspField=Struct2SaStationDisplayFieldsString(DisplayFieldsInfo);

                }
                else
                {
                    SmtStationDisplayFieldInfo DisplayFieldsInfo=new SmtStationDisplayFieldInfo();

                    DisplayFieldsInfo.IsDefectDsp =lineItem.IsDefectDsp;
                    DisplayFieldsInfo.IsInputDsp =lineItem.IsInputDsp;
                    DisplayFieldsInfo.IsYieldRateDsp =lineItem.IsYieldRateDsp;
                    DisplayFieldsInfo.IsAOIDefectDsp =lineItem.IsAOIDefectDsp;
                    DisplayFieldsInfo.IsAOIOutputDsp  =lineItem.IsAOIOutputDsp;

                    fmlDspField=Struct2SmtStationDisplayFieldsString(DisplayFieldsInfo);
                }

                ConditionValueSet paramFmlDspField = new ConditionValueSet();
                paramFmlDspField.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramFmlDspField.DataType = "varchar";
                paramFmlDspField.ParamValue = fmlDspField;
                paramList.Add(paramFmlDspField);


                ConditionValueSet paramLineOrder = new ConditionValueSet();
                paramLineOrder.ParamName = "@param" + paramIndex;
                paramIndex = paramIndex + 1;
                paramLineOrder.DataType = "int";
                paramLineOrder.ParamValue = i.ToString();
                paramList.Add(paramLineOrder);

                sqlLineStringBuilder.Append("INSERT INTO [Dashboard_Line_Target] ")
                    .Append("([Line]")
                    .Append(",[ID]")
                    .Append(",[WindowsID]")
                    .Append(",[StartWorkTime]")
                    .Append(",[StopWorkTime]")
                    .Append(",[Order]")
                    .Append(",[Shift]")
                    .Append(",[FmlDspField]) ")
                 .Append("VALUES (")
                 .Append(paramLineId.ParamName).Append(",")
                 .Append(paramLineTargetId.ParamName).Append(",")
                 .Append(paramItemWindowId.ParamName).Append(",")
                 .Append(paramLineStartWorkTime.ParamName).Append(",")
                 .Append(paramLineStopWorkTime.ParamName).Append(",")
                 .Append(paramLineOrder.ParamName).Append(",")
                 .Append(paramShift.ParamName).Append(",")
                 .Append(paramFmlDspField.ParamName)               
                 .Append(") ");

                //存盘时,相同的line的基本数据同时变
                sqlLineUpdateAllStringBuilder.Append("UPDATE [Dashboard_Line_Target] SET [StartWorkTime] = ")
                .Append(paramLineStartWorkTime.ParamName)
                .Append(",[StopWorkTime] =")
                .Append(paramLineStopWorkTime.ParamName)
                .Append(",[Shift] =")
                .Append(paramShift.ParamName)
                .Append(" WHERE [Line]=")
                .Append(paramLineId.ParamName).Append(" ");

                //存SA的目标量
               // String SA = ConfigurationManager.AppSettings["SA"].ToString();
               // ConditionValueSet paramSaStage = new ConditionValueSet();
               // paramSaStage.ParamName = "@param" + paramIndex;
               // paramIndex = paramIndex + 1;
               // paramSaStage.DataType = "char";
               // paramSaStage.ParamValue = SA;
               // paramList.Add(paramSaStage);

               // sqlLineUpdateAllStringBuilder.Append("DELETE FROM [Dashboard_StageGoal] WHERE Stage=")
               //.Append(paramSaStage.ParamName).Append(" ")
               //.Append("INSERT INTO [Dashboard_StageGoal] ([Stage],[Goal]) ")
               //.Append("SELECT a.Stage, SUM(a.OutputTarget) as GoalNum ")
               //.Append("FROM (SELECT DISTINCT [Dashboard_Line_Target].[Line] ")
               //.Append(",[Dashboard_Line_Target].[OutputTarget],[Line].Stage ")
               //.Append("FROM [Dashboard_Line_Target] INNER JOIN [Line] ")
               //.Append("ON [Dashboard_Line_Target].[Line]=[Line].[Line] ")
               //.Append("WHERE [Line].Stage=")
               //.Append(paramSaStage.ParamName).Append(" ) AS a GROUP BY a.Stage ");

                for (int j = 0; j < lineItem.WindowLineFamilyInfos.Count; j++)
                {

                    WindowLineFamilyInfo stationItem = lineItem.WindowLineFamilyInfos[j];

                    ConditionValueSet paramFamilyTargetId = new ConditionValueSet();
                    paramFamilyTargetId.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramFamilyTargetId.DataType = "char(32)";
                    paramFamilyTargetId.ParamValue = DatabaseUtil.GetUUID();
                    paramList.Add(paramFamilyTargetId);

                    ConditionValueSet paramFamilyId = new ConditionValueSet();
                    paramFamilyId.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramFamilyId.DataType = "varchar";  
                    paramFamilyId.ParamValue = GeneralUtil.Null2String(stationItem.Family);
                    paramList.Add(paramFamilyId);

                    ConditionValueSet paramSeries = new ConditionValueSet();
                    paramSeries.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramSeries.DataType = "varchar";
                    paramSeries.ParamValue = GeneralUtil.Null2String(stationItem.Series);
                    paramList.Add(paramSeries);

                 
                    ConditionValueSet paramPlan = new ConditionValueSet();
                    paramPlan.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramPlan.DataType = "int";
                    paramPlan.ParamValue = stationItem.PlanQty;
                    paramList.Add(paramPlan);

                    ConditionValueSet paramStationOrder = new ConditionValueSet();
                    paramStationOrder.ParamName = "@param" + paramIndex;
                    paramIndex = paramIndex + 1;
                    paramStationOrder.DataType = "int";
                    paramStationOrder.ParamValue = j.ToString();
                    paramList.Add(paramStationOrder);

                    sqlStationStringBuilder.Append("INSERT INTO [Dashboard_Family_Target] ")
                        .Append("([ID]")
                        .Append(",[Line]")
                        .Append(",[WindowsID]")
                        .Append(",[Family]")
                        .Append(",[Series]")
                        .Append(",[Plan]")
                        .Append(",[Order]) ")
                        .Append("VALUES (")
                        .Append(paramFamilyTargetId.ParamName).Append(",")
                        .Append(paramLineId.ParamName).Append(",")
                        .Append(paramItemWindowId.ParamName).Append(",")                        
                        .Append(paramFamilyId.ParamName).Append(",")
                        .Append(paramSeries.ParamName).Append(",")
                        .Append(paramPlan.ParamName).Append(",")
                        .Append(paramStationOrder.ParamName)
                        .Append(") ");

                }
            }

            sqlString = sqlStringBuilder.ToString() + sqlStageStringBuilder.ToString() + sqlLineStringBuilder.ToString() + sqlStationStringBuilder.ToString() + sqlStageUpdateAllStringBuilder.ToString() + sqlLineUpdateAllStringBuilder.ToString();
            DatabaseUtil.ExecSqlNonQueryWithParam(sqlString, connectString, paramList);

            return windowId;
        }
Example #6
0
        //Display ok
        private static String Struct2SaStationDisplayFieldsString(SaStationDisplayFieldInfo DisplayFieldsInfo)
        {
            String result = "";

            if (DisplayFieldsInfo.IsInputDsp.ToLower() == "true")
            {
                result += "Input=True,";
            }
            else
            {
                result += "Input=False,";
            }

            if (DisplayFieldsInfo.IsDefectDsp.ToLower() == "true")
            {
                result += "Defect=True,";
            }
            else
            {
                result += "Defect=False,";
            }

            if (DisplayFieldsInfo.IsYieldRateDsp.ToLower() == "true")
            {
                result += "YieldRate=True,";
            }
            else
            {
                result += "YieldRate=False,";
            }

            if (DisplayFieldsInfo.IsICTInputDsp.ToLower() == "true")
            {
                result += "ICTInput=True,";
            }
            else
            {
                result += "ICTInput=False,";
            }

            if (DisplayFieldsInfo.IsICTDefectDsp.ToLower() == "true")
            {
                result += "ICTDefect=True,";
            }
            else
            {
                result += "ICTDefect=False,";
            }


            if (DisplayFieldsInfo.IsICTYieldRateDsp.ToLower() == "true")
            {
                result += "ICTYieldRate=True";
            }
            else
            {
                result += "ICTYieldRate=False";
            }
          
            return result;

        }