public FileResult ExportOQCDailyInputDataExcel(string query) { QAReportSearchVM search = JsonConvert.DeserializeObject <QAReportSearchVM>(query); if (search.FunPlant == "Assembly1" || search.FunPlant == "Assembly2" || search.FunPlant == "Assembly") { return(ExportAmessbleDailyInputDataForExcel(search)); } var stream = new MemoryStream(); var fileName = PathHelper.SetGridExportExcelName(""); ExportOQCDataForExcel data = GetOQCInputDataForExportExcel(search); if (data.OQCDatas.Count != 0) { using (var excelPackage = new ExcelPackage(stream)) { foreach (OQCExportModel oqcData in data.OQCDatas) { var worksheetDaily = excelPackage.Workbook.Worksheets.Add(oqcData.MasterData.Process); WriteOQCInputDataToExcel(worksheetDaily, oqcData); } excelPackage.Save(); } } return(new FileContentResult(stream.ToArray(), "application/octet-stream") { FileDownloadName = Server.UrlEncode(fileName) }); }
public List <ProductSaleReport_RateVM> QueryDistributeRateReportDetail(QAReportSearchVM searchModel) { List <ProductSaleReport_RateVM> result = new List <ProductSaleReport_RateVM>(); try { var Product_date = new SqlParameter("ProductDate", searchModel.ProductDate); var ProjectName = new SqlParameter("Flowchart_Master_UID ", searchModel.FlowChart_Master_UID); var MaterialType = new SqlParameter("MaterialType", searchModel.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(searchModel.Color) ? "" : searchModel.Color); var FunPlant = new SqlParameter("FunPlant", searchModel.FunPlant); var RateType = new SqlParameter("RateType", searchModel.RateType); var SearchType = new SqlParameter("SearchType", searchModel.SearchType); var OPType_OrganizationUID = new SqlParameter("OPType_OrganizationUID", searchModel.OPType_OrganizationUID); IEnumerable <ProductSaleReport_RateVM> tempResult = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <ProductSaleReport_RateVM>(@"dbo.usp_Get_QADistributeRate_ProcessSummaryByFunPlant @ProductDate, @Flowchart_Master_UID, @MaterialType,@Color,@FunPlant, @RateType,@SearchType,@OPType_OrganizationUID", Product_date, ProjectName, MaterialType, Color, FunPlant, RateType, SearchType, OPType_OrganizationUID).ToArray(); result = tempResult.ToList(); } catch (Exception ex) { log.Error(ex); } return(result); }
public FileResult ExportAmessbleDailyInputDataForExcel(QAReportSearchVM search) { var stream = new MemoryStream(); var fileName = PathHelper.SetGridExportExcelName(""); search.Count = 10000; OQCReportExcel detailData = GetOQCReportForExportExcel(search); if (detailData.SumData.Count != 0) { using (var excelPackage = new ExcelPackage(stream)) { var worksheetYield = excelPackage.Workbook.Worksheets.Add("Yield"); var worksheetDetails = excelPackage.Workbook.Worksheets.Add("Details"); string title = this.CurrentUser.GetUserInfo.OrgInfo.First().Plant + "_" + search.ProjectName + "_" + search.FunPlant + " " + search.MaterialType + (string.IsNullOrEmpty(search.Color) ? "" : "(" + search.Color + ") ") + search.ProductDate.Date.ToShortDateString() + this.CurrentUser.GetLocaleStringResource(PISSessionContext.Current.CurrentWorkingLanguage.System_Language_UID, "QA.2Htestreport"); WriteYieldDataToExcel(worksheetYield, detailData, title, search.FunPlant); if (detailData.TopFive.Count != 0) { WriteDetailsDataToExcel(worksheetDetails, detailData); } excelPackage.Save(); } } return(new FileContentResult(stream.ToArray(), "application/octet-stream") { FileDownloadName = Server.UrlEncode(fileName) }); }
public FileResult ExportReportExcel(string query) { OQCReportExcel Report = new OQCReportExcel(); QAReportSearchVM search = JsonConvert.DeserializeObject <QAReportSearchVM>(query); search.Count = 5; Report = GetOQCReportForExportExcel(search); var stream = new MemoryStream(); var fileName = PathHelper.SetGridExportExcelName(""); using (var excelPackage = new ExcelPackage(stream)) { var worksheetYield = excelPackage.Workbook.Worksheets.Add("Yield"); var worksheetTopFive = excelPackage.Workbook.Worksheets.Add("Top5"); string title = this.CurrentUser.GetUserInfo.OrgInfo.First().Plant + "_" + search.ProjectName + "_" + search.FunPlant + " " + search.MaterialType + (string.IsNullOrEmpty(search.Color) ? "" : "(" + search.Color + ") ") + search.ProductDate.Date.ToShortDateString() + this.CurrentUser.GetLocaleStringResource(PISSessionContext.Current.CurrentWorkingLanguage.System_Language_UID, "QA.2Htestreport"); WriteYieldDataToExcel(worksheetYield, Report, title, search.FunPlant); if (Report.TopFive.Count != 0) { WriteTopFiveToExcel(worksheetTopFive, Report, search.FunPlant); } excelPackage.Save(); } return(new FileContentResult(stream.ToArray(), "application/octet-stream") { FileDownloadName = Server.UrlEncode(fileName) }); }
/// <summary> /// 全功能厂汇总良率 /// </summary> /// <param name="search"></param> /// <param name="page"></param> /// <returns></returns> public ActionResult QueryProductSaleReportSummery(QAReportSearchVM search, Page page) { var apiUrl = string.Format("QAProductSaleReport/QueryProductSaleReportSummery"); HttpResponseMessage responMessage = APIHelper.APIPostAsync(search, page, apiUrl); var result = responMessage.Content.ReadAsStringAsync().Result; return(Content(result, "application/json")); }
public ActionResult QueryOQCReworkDetails(QAReportSearchVM search, Page page) { var apiUrl = "OQCQuality/QueryOQCReworkDetailsAPI"; HttpResponseMessage responMessage = APIHelper.APIPostAsync(search, page, apiUrl); var result = responMessage.Content.ReadAsStringAsync().Result; return(Content(result, "application/json")); }
public QAReportDaySummeryDTO GetQAReportDaySummery(QAReportSearchVM search) { try { string selectedTabSumType = ""; if (!string.IsNullOrEmpty(search.Tab_Select_Text)) { if (search.Tab_Select_Text == "白班小计") { selectedTabSumType = "Daily_Sum"; } else if (search.Tab_Select_Text == "全天") { selectedTabSumType = "ALL"; } else if (search.Tab_Select_Text == "夜班小计") { selectedTabSumType = "Night_Sum"; } } var Flowchart_Detail_UID = new SqlParameter("Flowchart_Detail_UID", search.FlowChart_Detail_UID); var Product_date = new SqlParameter("ProductDate", search.ProductDate); var SumType = new SqlParameter("SumType", string.IsNullOrEmpty(selectedTabSumType) ? search.Time_interval : selectedTabSumType); var MaterialType = new SqlParameter("MaterialType", search.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(search.Color) ? "" : search.Color); var FlowChart_Master_UID = new SqlParameter("FlowChart_Master_UID", search.FlowChart_Master_UID); var Process = new SqlParameter("Process", search.Process); var ProjectName = new SqlParameter("ProjectName", search.ProjectName); if (search.Part_Type == "ALL" || search.Color == "ALL") // 增加的汇总所有Part Type { IEnumerable <QAReportDaySummeryDTO> summeryData = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QAReportDaySummeryDTO>(@" dbo.usp_GetQAReportSum @ProductDate,@Process, @SumType,@MaterialType,@Color,@ProjectName", Product_date, Process, SumType, MaterialType, Color, ProjectName).ToArray(); if (summeryData.Count() != 0) { return(summeryData.ToArray()[0]); } } else { IEnumerable <QAReportDaySummeryDTO> summeryData = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QAReportDaySummeryDTO>(@" dbo.usp_GetQAReportDaySummery @ProductDate,@Flowchart_Detail_UID, @SumType,@MaterialType,@Color", Product_date, Flowchart_Detail_UID, SumType, MaterialType, Color).ToArray(); if (summeryData.Count() != 0) { return(summeryData.ToArray()[0]); } } } catch (Exception ex) { log.Error(ex); } return(new QAReportDaySummeryDTO()); }
public List <QAReportExceptionTypeRankDTO> GetQAReportTypeRank(QAReportSearchVM search, int yield) { try { string selectedTabSumType = ""; if (!string.IsNullOrEmpty(search.Tab_Select_Text)) { if (search.Tab_Select_Text == "白班小计") { selectedTabSumType = "Daily_Sum"; } else if (search.Tab_Select_Text == "全天") { selectedTabSumType = "ALL"; } else if (search.Tab_Select_Text == "夜班小计") { selectedTabSumType = "Night_Sum"; } } var FlowChart_Detail_UID = new SqlParameter("FlowChart_Detail_UID", search.FlowChart_Detail_UID); var Product_date = new SqlParameter("ProductDate", search.ProductDate); var SumType = new SqlParameter("SumType", string.IsNullOrEmpty(selectedTabSumType) ? search.Time_interval : selectedTabSumType); var MaterialType = new SqlParameter("MaterialType", search.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(search.Color) ? "" : search.Color); var count = new SqlParameter("count", 10); var yieldType = new SqlParameter("yieldType", yield); var Process = new SqlParameter("Process", search.Process); var ProjectName = new SqlParameter("ProjectName", search.ProjectName); var FlowChart_Master_UID = new SqlParameter("FlowChart_Master_UID", search.FlowChart_Master_UID); if (search.Part_Type == "ALL" || search.Color == "ALL") // 增加的汇总所有Part Type { IEnumerable <QAReportExceptionTypeRankDTO> topTenRate = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QAReportExceptionTypeRankDTO>(@" dbo.usp_GetQAReportSumDayYield @ProductDate,@Process, @SumType,@MaterialType,@Color,@count,@yieldType,@ProjectName", Product_date, Process, SumType, MaterialType, Color, count, yieldType, ProjectName).ToArray(); if (topTenRate.Count() != 0) { return(topTenRate.ToList()); } } else { IEnumerable <QAReportExceptionTypeRankDTO> topTenRate = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QAReportExceptionTypeRankDTO>(@" dbo.usp_GetQAReportDayYield @ProductDate,@FlowChart_Detail_UID, @SumType,@MaterialType,@Color,@count,@yieldType", Product_date, FlowChart_Detail_UID, SumType, MaterialType, Color, count, yieldType).ToArray(); if (topTenRate.Count() != 0) { return(topTenRate.ToList()); } } } catch (Exception ex) { log.Error(ex); } return(new List <QAReportExceptionTypeRankDTO>()); }
/// <summary> /// 制程明细 /// </summary> /// <param name="search"></param> /// <param name="page"></param> /// <returns></returns> public ActionResult QueryDistributeRateReportProcessDetail(QAReportSearchVM search, Page page) { search.SearchType = 1; var apiUrl = string.Format("QAProductSaleReport/QueryDistributeRateReportDetail"); HttpResponseMessage responMessage = APIHelper.APIPostAsync(search, page, apiUrl); var result = responMessage.Content.ReadAsStringAsync().Result; return(Content(result, "application/json")); }
private ExportOQCDataForExcel GetOQCInputDataForExportExcel(QAReportSearchVM search) { var apiUrl = string.Format("OQCQuality/DownloadOQCInputDataForExportExcelAPI"); HttpResponseMessage responMessage = APIHelper.APIPostAsync(search, apiUrl); var result = responMessage.Content.ReadAsStringAsync().Result; var list = JsonConvert.DeserializeObject <ExportOQCDataForExcel>(result); return(list); }
public ActionResult QueryQADayReportTopFive(QAReportSearchVM search, Page page) { int languageID = PISSessionContext.Current.CurrentWorkingLanguage.System_Language_UID; search.languageID = languageID; var apiUrl = string.Format("OQCQuality/QueryQADayReportTopFiveAPI"); HttpResponseMessage responMessage = APIHelper.APIPostAsync(search, page, apiUrl); var result = responMessage.Content.ReadAsStringAsync().Result; return(Content(result, "application/json")); }
public string GetAllSecondTargetYield(QAReportSearchVM search) { string Product_Date = search.ProductDate.ToString("yyyy-MM-dd"); string result = string.Empty; double first = 1.0; if (search.Part_Type == "ALL" || search.Color == "ALL") //按功能厂汇总 { int opUID = int.Parse(search.OPType); var query = from mg in DataContext.QualityAssurance_MgData where mg.FlowChart_Master.System_Project.Project_Name == search.ProjectName && mg.ProductDate == search.ProductDate && mg.FlowChart_Master.System_Project.Organization_UID == opUID select mg; var list = query.Where(m => m.FlowChart_Detail.Color != "").GroupBy(m => m.FlowChart_Detail.Color).ToDictionary(p => p.Key, m => m.Count()); var color = list.OrderByDescending(p => p.Value).FirstOrDefault().Key; var list2 = query.Where(m => m.FlowChart_Detail.Color == color || m.FlowChart_Detail.Color == ""); foreach (var item in list2) { first *= (float)item.SecondRejectionRate; } } else if (search.Color != "ALL") { //int opUID = int.Parse(search.OPType); //var query = from mg in DataContext.QualityAssurance_MgData // join fm in DataContext.FlowChart_Master on mg.FlowChart_Master_UID equals fm.FlowChart_Master_UID // join fd in DataContext.FlowChart_Detail on fm.FlowChart_Master_UID equals fd.FlowChart_Master_UID // where fm.FlowChart_Master_UID == search.FlowChart_Master_UID // && (fd.Color == search.Color||fd.Color=="") // && mg.ProductDate == search.ProductDate // select mg; //foreach (var item in query) //{ // first *= (float)item.SecondRejectionRate; //} string sql = string.Format(@" SELECT EXP(SUM(Log(Fm.SecondRejectionRate))) FROM dbo.[QualityAssurance_MgData] FM JOIN dbo.FlowChart_Detail FD ON FD.FlowChart_Detail_UID = FM.FlowChart_Detail_UID JOIN dbo.FlowChart_Master F ON F.FlowChart_Master_UID = FD.FlowChart_Master_UID WHERE f.FlowChart_Master_UID={0} AND FM.ProductDate='{1}' AND (FD.Color='' OR fd.Color=N'{2}')" , search.FlowChart_Master_UID, Product_Date, search.Color); first = DataContext.Database.SqlQuery <double>(sql).ToArray()[0]; } return(first.ToString()); }
public IHttpActionResult QueryQAHistroyDatasAPI(dynamic data) { var jsonData = data.ToString(); QAReportSearchVM conditionModel = JsonConvert.DeserializeObject <QAReportSearchVM>(jsonData); IntervalEnum time = EventReportManagerService.GetIntervalInfo("OP1"); if (string.IsNullOrEmpty(conditionModel.Time_interval) && string.IsNullOrEmpty(conditionModel.Tab_Select_Text)) { conditionModel.Time_interval = time.Time_Interval; conditionModel.ProductDate = DateTime.Parse(time.NowDate); } var result = QualityService.QueryQAHistroyDatas(conditionModel, DateTime.Parse(time.NowDate)); return(Ok(result)); }
public ActionResult OQCReportFromOQCHistoryBack(int FlowChart_Master_UID, string PartType, string project, string date, string materialType, string color, string OPType, string funplant) { QAReportSearchVM search = new QAReportSearchVM(); search.Color = color; search.ProductDate = DateTime.Parse(date); search.MaterialType = materialType; search.OPType = OPType; search.FunPlant = funplant; search.ProjectName = project; search.FlowChart_Master_UID = FlowChart_Master_UID; search.Part_Type = PartType; TempData["search"] = search; return(RedirectToAction("OQCReport", "OQCQuality")); }
public QAReportVM QueryQAReport(QAReportSearchVM search) { QAReportVM result = new QAReportVM(); try { result.summeryData = GetQAReportDaySummery(search); result.summeryData.Color = search.Color; result.FirstRejectionRateTopTen = GetQAReportTypeRank(search, 1); result.SecondRejectionRateTopTen = GetQAReportTypeRank(search, 2); } catch (Exception ex) { log.Error(ex); } return(result); }
public List <OQC_InputDetailVM> QueryOQCExceptionRecord(QAReportSearchVM searchModel, string Classify) { if (searchModel.Tab_Select_Text == "夜班小计") { searchModel.Tab_Select_Text = "Night_Sum"; } else if (searchModel.Tab_Select_Text == "白班小计") { searchModel.Tab_Select_Text = "Daily_Sum"; } else if (searchModel.Tab_Select_Text == "全天") { searchModel.Tab_Select_Text = "ALL"; } if (searchModel.Tab_Select_Text == "0") { searchModel.Time_interval = "ALL"; searchModel.Tab_Select_Text = "ALL"; } List <OQC_InputDetailVM> result = new List <OQC_InputDetailVM>(); try { var ProductDate = new SqlParameter("ProductDate", searchModel.ProductDate.ToShortDateString()); var MaterialType = new SqlParameter("MaterialType", searchModel.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(searchModel.Color) ? "" : searchModel.Color); var typeClassify = new SqlParameter("typeClassify ", Classify); var Time_Interval = new SqlParameter("TimeInterval", searchModel.Tab_Select_Text); var Flowchart_Detail_UID = new SqlParameter("Flowchart_Detail_UID", searchModel.FlowChart_Detail_UID); IEnumerable <OQC_InputDetailVM> tempResult = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <OQC_InputDetailVM>("dbo.usp_QueryQAHistory_OQC @ProductDate, @MaterialType, @Color,@typeClassify,@TimeInterval,@Flowchart_Detail_UID", ProductDate, MaterialType, Color, typeClassify, Time_Interval, Flowchart_Detail_UID).ToArray(); result = tempResult.ToList(); } catch (Exception ex) { log.Error(ex); } return(result); }
public List <OQCReprotDTO> GetQAReportOQCDaySummery(QAReportSearchVM search) { List <OQCReprotDTO> result = new List <OQCReprotDTO>(); try { var Product_date = new SqlParameter("ProductDate", search.ProductDate); var FlowChart_Master_UID = new SqlParameter("FlowChart_Master_UID", search.FlowChart_Master_UID); var MaterialType = new SqlParameter("MaterialType", search.MaterialType); var FunPlant = new SqlParameter("FunPlant", search.FunPlant); var Color = new SqlParameter("Color", string.IsNullOrEmpty(search.Color) ? "" : search.Color); IEnumerable <OQCReprotDTO> tempResult = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <OQCReprotDTO>("dbo.usp_GetQAReport_OQC_DaySummery @ProductDate, @FlowChart_Master_UID , @MaterialType,@FunPlant, @Color", Product_date, FlowChart_Master_UID, MaterialType, FunPlant, Color).ToArray(); result = tempResult.ToList(); } catch (Exception ex) { log.Error(ex); } return(result); }
public ActionResult OQCReport() { if (TempData["search"] != null) { QAReportSearchVM search = (QAReportSearchVM)TempData["search"]; ViewBag.Color = search.Color; ViewBag.ProductDate = search.ProductDate.ToString(FormatConstants.DateTimeFormatStringByDate); ViewBag.MaterialType = search.MaterialType; ViewBag.OPtype = search.OPType; ViewBag.FunPlant = search.FunPlant; ViewBag.ProjectName = search.ProjectName; ViewBag.FlowChart_Master_UID = search.FlowChart_Master_UID; ViewBag.PartType = search.Part_Type; ViewBag.IsSearchHistory = "visible"; } else { ViewBag.IsSearchHistory = "hidden"; } return(View()); }
public List <TimeIntervalFPYReportVM> QueryTimeIntervalFPYReport(QAReportSearchVM searchModel) { List <TimeIntervalFPYReportVM> result = new List <TimeIntervalFPYReportVM>(); try { var Product_date = new SqlParameter("ProductDate", searchModel.ProductDate); var ProjectName = new SqlParameter("Flowchart_Master_UID ", searchModel.FlowChart_Master_UID); var MaterialType = new SqlParameter("MaterialType", searchModel.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(searchModel.Color) ? "" : searchModel.Color); var RateType = new SqlParameter("RateType", searchModel.RateType); var OPType_OrganizationUID = new SqlParameter("OPType_OrganizationUID", searchModel.OPType_OrganizationUID); IEnumerable <TimeIntervalFPYReportVM> tempResult = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <TimeIntervalFPYReportVM>(@"dbo.usp_Get_QAFPYByDay @ProductDate, @Flowchart_Master_UID, @MaterialType,@Color, @RateType,@OPType_OrganizationUID", Product_date, ProjectName, MaterialType, Color, RateType, OPType_OrganizationUID).ToArray(); result = tempResult.ToList(); } catch (Exception ex) { log.Error(ex); } return(result); }
public List <QABackToFunPlant> QueryQABackToFunPlantInfo(QAReportSearchVM searchModel) { List <QABackToFunPlant> result = new List <QABackToFunPlant>(); try { var Product_date = new SqlParameter("ProductDate", searchModel.ProductDate); var Flowchart_Master_UID = new SqlParameter("Flowchart_Master_UID ", searchModel.FlowChart_Master_UID); var FlowchartDetailUID = new SqlParameter("Flowchart_Detail_UID ", searchModel.FlowChart_Detail_UID); var systemFunPlantUID = new SqlParameter("System_FunPlant_UID ", searchModel.System_FunPlant_UID); var MaterialType = new SqlParameter("MaterialType", searchModel.MaterialType); var RateType = new SqlParameter("RateType", searchModel.RateType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(searchModel.Color) ? "" : searchModel.Color); IEnumerable <QABackToFunPlant> tempResult = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QABackToFunPlant>(@"dbo.QueryQADistrbuteRate @ProductDate, @Flowchart_Master_UID,@System_FunPlant_UID,@Flowchart_Detail_UID,@RateType, @MaterialType,@Color", Product_date, Flowchart_Master_UID, systemFunPlantUID, FlowchartDetailUID, RateType, MaterialType, Color).ToArray(); result = tempResult.ToList(); } catch (Exception ex) { log.Error(ex); } return(result); }
public List <OQC_InputDetailVM> QueryOQCExceptionDetails(QAReportSearchVM searchModel, string typeClassify) { List <OQC_InputDetailVM> result = new List <OQC_InputDetailVM>(); try { bool searchHistory = false; TimeSpan tSpan = DateTime.Now.Date - searchModel.ProductDate; if (tSpan.Days >= 7) { searchHistory = true; } string sql = string.Empty; sql = string.Format(@" SELECT detai.OQCMater_UID, detai.OQCDetail_UID, detai.FunPlant, detai.TypeClassify, detai.Qty, detai.ExceptionType_UID, Etype.TypeName AS ExcetionTypeName INTO #temp FROM dbo.{7} detai WITH ( NOLOCK ) INNER JOIN dbo.QualityAssurance_ExceptionType Etype WITH(NOLOCK) ON Etype.ExceptionType_UID = detai.ExceptionType_UID INNER JOIN dbo.{0} OQCMa WITH ( NOLOCK ) ON OQCMa.OQCMater_UID = detai.OQCMater_UID INNER JOIN dbo.System_Project SP WITH ( NOLOCK ) ON SP.Project_UID = OQCMa.Project_UID WHERE FlowChart_Detail_UID = {1} AND SP.Project_Name = N'{2}' AND OQCMa.Color = N'{3}' AND OQCMa.MaterialType = N'{4}' AND ProductDate = N'{5}' AND Time_interval = N'{6}' DECLARE @DefectRate TABLE ( ExceptionType_UID INT , DailyRate DECIMAL(8, 6) , NightRate DECIMAL(8, 6) , DayRate DECIMAL(8, 6) ) INSERT INTO @DefectRate ( DailyRate, DayRate , NightRate, ExceptionType_UID) EXEC dbo.usp_CalculateDefectRate N'{5}', N'{4}', N'{3}',N'{8}',N'{6}',N'{10}' DECLARE @CanModify BIT IF EXISTS (SELECT TOP 1 1 FROM #temp) BEGIN SET @CanModify=0 END ELSE IF EXISTS(SELECT TOP 1 1 FROM dbo.{0} OQCMa WITH ( NOLOCK ) WHERE OQCMa.Color = N'{3}' AND FlowChart_Detail_UID = {1} AND OQCMa.MaterialType = N'{4}' AND ProductDate = N'{5}' AND Time_interval = N'{6}') BEGIN SET @CanModify=0 END ElSE BEGIN SET @CanModify=1 END SELECT 0 AS OQCMater_UID , 0 AS OQCDetail_UID , FunPlant , EWF.TypeClassify , 0 AS QTY , EType.TypeName AS ExcetionTypeName, EType.ExceptionType_UID, @CanModify AS CanModify, ISNULL(rate.DailyRate,0) AS DailyRate, ISNULL(rate.NightRate,0) AS NightRate, ISNULL(rate.DayRate,0) AS DayRate FROM dbo.ExceptionTypeWithFlowchart EWF WITH ( NOLOCK ) INNER JOIN dbo.QualityAssurance_ExceptionType EType WITH (NOLOCK) ON EType.ExceptionType_UID = EWF.ExceptionType_UID Left JOIN @DefectRate rate ON rate.ExceptionType_UID = EType.ExceptionType_UID WHERE EWF.FlowChart_Detail_UID = {1} AND EWF.FlowChart_Master_UID = {9} AND ewf.TypeClassify = N'{8}' AND ewf.ExceptionType_UID NOT IN (SELECT ExceptionType_UID FROM #temp) UNION SELECT OQCMater_UID, OQCDetail_UID, FunPlant, TypeClassify, Qty, ExcetionTypeName, t.ExceptionType_UID, @CanModify AS CanModify , ISNULL(rate.DailyRate,0) AS DailyRate, ISNULL(rate.NightRate,0) AS NightRate, ISNULL(rate.DayRate,0) AS DayRate FROM #temp t Left JOIN @DefectRate rate ON rate.ExceptionType_UID = t.ExceptionType_UID Where TypeClassify=N'{8}' ORDER BY FunPlant,ExceptionType_UID DROP TABLE #temp", !searchHistory ? "OQC_InputMaster" : "OQC_InputMaster_History", searchModel.FlowChart_Detail_UID, searchModel.ProjectName, searchModel.Color, searchModel.MaterialType, searchModel.ProductDate.ToShortDateString(), searchModel.Time_interval, !searchHistory ? "OQC_InputDetail" : "OQC_InputDetail_History", typeClassify, searchModel.FlowChart_Master_UID, searchModel.FlowChart_Detail_UID); var query = DataContext.Database.SqlQuery <OQC_InputDetailVM>(sql).ToList(); result = query; } catch (Exception ex) { log.Error(ex); } return(result); }
public List <QualityAssurance_InputMasterDTO> QueryQAHistroyDatas(QAReportSearchVM searchModel, DateTime dateNow) { var ProcesColor = string.IsNullOrEmpty(searchModel.Color) ? "" : searchModel.Color; List <QualityAssurance_InputMasterDTO> result = new List <QualityAssurance_InputMasterDTO>(); try { string timeInterVal = searchModel.Time_interval; if (!string.IsNullOrEmpty(searchModel.Tab_Select_Text) && (searchModel.Tab_Select_Text.Contains("小计") || searchModel.Tab_Select_Text.Contains("全天"))) { //TODO:SP 获取 全天,白班小计,夜班小计的情况 var sumType = ""; if (searchModel.Tab_Select_Text.Equals("全天")) { sumType = "ALL"; } else if (searchModel.Tab_Select_Text.Contains("白班")) { sumType = "Daily_Sum"; } else { sumType = "Night_Sum"; } var Product_date = new SqlParameter("ProductDate", searchModel.ProductDate); var SumType = new SqlParameter("SumType", sumType); var MaterialType = new SqlParameter("MaterialType", searchModel.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(searchModel.Color) ? "" : searchModel.Color); var FlowChart_Detail_UID = new SqlParameter("FlowChart_Detail_UID", searchModel.FlowChart_Detail_UID); IEnumerable <QualityAssurance_InputMasterDTO> tempResult = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QualityAssurance_InputMasterDTO>("dbo.usp_GetQADayDataSum @ProductDate,@FlowChart_Detail_UID, @SumType, @MaterialType, @Color", Product_date, FlowChart_Detail_UID, SumType, MaterialType, Color).ToArray(); result = tempResult.ToList(); } else { if (!string.IsNullOrEmpty(searchModel.Tab_Select_Text)) { timeInterVal = searchModel.Tab_Select_Text; } bool searchHistory = false; TimeSpan tSpan = DateTime.Now.Date - searchModel.ProductDate; if (tSpan.Days >= 7) { searchHistory = true; } if (!searchHistory) { var query = from qAMaster in DataContext.QualityAssurance_InputMaster join flowDetail in DataContext.FlowChart_Detail on qAMaster.FlowChart_Detail_UID equals flowDetail.FlowChart_Detail_UID where qAMaster.Product_Date == searchModel.ProductDate && qAMaster.Time_Interval == timeInterVal && flowDetail.FlowChart_Detail_UID == searchModel.FlowChart_Detail_UID && qAMaster.MaterielType == searchModel.MaterialType && qAMaster.Color == ProcesColor select new QualityAssurance_InputMasterDTO { NG_Qty = qAMaster.NG_Qty, Input = qAMaster.Input, Color = qAMaster.Color, FirstCheck_Qty = qAMaster.FirstCheck_Qty, FirstOK_Qty = qAMaster.FirstOK_Qty, FirstRejectionRate = qAMaster.FirstRejectionRate, FlowChart_Detail_UID = qAMaster.FlowChart_Detail_UID, MaterielType = qAMaster.MaterielType, Process = qAMaster.Process, Product_Date = qAMaster.Product_Date, Shipment_Qty = qAMaster.Shipment_Qty, SurfaceSA_Qty = qAMaster.SurfaceSA_Qty, SizeSA_Qty = qAMaster.SizeSA_Qty, RepairCheck_Qty = qAMaster.RepairCheck_Qty, RepairOK_Qty = qAMaster.RepairOK_Qty, WIPForCheck_Qty = qAMaster.WIPForCheck_Qty, Time_Interval = qAMaster.Time_Interval, QualityAssurance_InputMaster_UID = qAMaster.QualityAssurance_InputMaster_UID, CanModify = (dateNow == qAMaster.Product_Date), NGFlag = qAMaster.NGFlag, FirstCheckFlag = qAMaster.FirstCheckFlag, Displace_Qty = qAMaster.Displace_Qty, DisplaceFlag = qAMaster.DisplaceFlag }; if (query.Count() != 0) { result = query.ToList(); } } else { var query = from qAMaster in DataContext.QualityAssurance_InputMaster_History join flowDetail in DataContext.FlowChart_Detail on qAMaster.FlowChart_Detail_UID equals flowDetail.FlowChart_Detail_UID where qAMaster.Product_Date == searchModel.ProductDate && qAMaster.Time_Interval == timeInterVal && flowDetail.FlowChart_Detail_UID == searchModel.FlowChart_Detail_UID && qAMaster.MaterielType == searchModel.MaterialType && qAMaster.Color == ProcesColor select new QualityAssurance_InputMasterDTO { NG_Qty = qAMaster.NG_Qty, Input = qAMaster.Input, Color = qAMaster.Color, FirstCheck_Qty = qAMaster.FirstCheck_Qty, FirstOK_Qty = qAMaster.FirstOK_Qty, FirstRejectionRate = qAMaster.FirstRejectionRate, FlowChart_Detail_UID = qAMaster.FlowChart_Detail_UID, MaterielType = qAMaster.MaterielType, Process = qAMaster.Process, Product_Date = qAMaster.Product_Date, Shipment_Qty = qAMaster.Shipment_Qty, SurfaceSA_Qty = qAMaster.SurfaceSA_Qty, SizeSA_Qty = qAMaster.SizeSA_Qty, RepairCheck_Qty = qAMaster.RepairCheck_Qty, RepairOK_Qty = qAMaster.RepairOK_Qty, WIPForCheck_Qty = qAMaster.WIPForCheck_Qty, Time_Interval = qAMaster.Time_Interval, QualityAssurance_InputMaster_UID = qAMaster.QualityAssurance_InputMaster_UID, CanModify = (dateNow == qAMaster.Product_Date), NGFlag = qAMaster.NGFlag, FirstCheckFlag = qAMaster.FirstCheckFlag, Displace_Qty = qAMaster.Displace_Qty, DisplaceFlag = qAMaster.DisplaceFlag }; if (query.Count() != 0) { result = query.ToList(); } } } } catch (Exception ex) { log.Error(ex); } return(result); }
public List <QAReportDaySummeryDTO> QueryIPQCALLProcessReportSummaryAPI(QAReportSearchVM search) { List <QAReportDaySummeryDTO> result = new List <QAReportDaySummeryDTO>(); try { string selectedTabSumType = ""; if (!string.IsNullOrEmpty(search.Tab_Select_Text)) { if (search.Tab_Select_Text == "白班小计") { selectedTabSumType = "Daily_Sum"; } else if (search.Tab_Select_Text == "全天") { selectedTabSumType = "ALL"; } else if (search.Tab_Select_Text == "夜班小计") { selectedTabSumType = "Night_Sum"; } } var ProjectName = new SqlParameter("ProjectName", search.ProjectName); var Part_Type = new SqlParameter("Part_Type", search.Part_Type); var OPType = new SqlParameter("OPType", int.Parse(search.OPType)); var Product_Phase = new SqlParameter("Product_Phase", search.Product_Phase); var FlowChart_Master_UID = new SqlParameter("flowChartMaster_UID", search.FlowChart_Master_UID); var Product_date = new SqlParameter("ProductDate", search.ProductDate); var SumType = new SqlParameter("SumType", string.IsNullOrEmpty(selectedTabSumType) ? search.Time_interval : selectedTabSumType); var MaterialType = new SqlParameter("MaterialType", search.MaterialType); var Color = new SqlParameter("Color", string.IsNullOrEmpty(search.Color) ? "" : search.Color); if (search.Part_Type == "ALL" || search.Color == "ALL") // 增加的汇总所有Part Type { //SqlParameter[] parameters = new SqlParameter[5]; //parameters[0] = new SqlParameter() { ParameterName = "ProductDate", Value = search.ProductDate };//值为上面转换的datatable //parameters[1] = new SqlParameter() { ParameterName = "ProjectName", Value = search.ProjectName }; //parameters[2] = new SqlParameter() { ParameterName = "OPType", Value = search.OPType }; //parameters[3] = new SqlParameter() { ParameterName = "Product_Phase", Value = search.Product_Phase }; //parameters[4] = new SqlParameter() { ParameterName = "SumType", Value = string.IsNullOrEmpty(selectedTabSumType) ? search.Time_interval : selectedTabSumType }; //IEnumerable<QAReportDaySummeryDTO> summeryData = ExecuteNonQuery("usp_Get_QA_ReportSummary", parameters); IEnumerable <QAReportDaySummeryDTO> summeryData = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QAReportDaySummeryDTO>(@" dbo.usp_Get_QA_ReportSummary @ProductDate,@ProjectName, @OPType,@Product_Phase,@SumType", Product_date, ProjectName, OPType, Product_Phase, SumType).ToArray(); if (summeryData.Count() != 0) { result = summeryData.ToList(); } } else { //TODO: 修改SP IEnumerable <QAReportDaySummeryDTO> summeryData = ((IObjectContextAdapter)this.DataContext).ObjectContext.ExecuteStoreQuery <QAReportDaySummeryDTO>(@" dbo.usp_GetIPQC_ALLProcess_ReportSummary @ProductDate,@flowChartMaster_UID, @SumType,@MaterialType,@Color", Product_date, FlowChart_Master_UID, SumType, MaterialType, Color).ToArray(); if (summeryData.Count() != 0) { result = summeryData.ToList(); } } } catch (Exception ex) { log.Error(ex); } return(result); }
public OQC_InputMasterDTO QueryOQCMasterData(QAReportSearchVM searchModel) { OQC_InputMasterDTO result = new OQC_InputMasterDTO(); try { bool searchHistory = false; TimeSpan tSpan = DateTime.Now.Date - searchModel.ProductDate; if (tSpan.Days >= 7) { searchHistory = true; } string sql = string.Format(@" SELECT OQCMa.* FROM dbo.{0} OQCMa WITH ( NOLOCK ) INNER JOIN dbo.System_Project SP WITH ( NOLOCK ) ON SP.Project_UID = OQCMa.Project_UID WHERE FlowChart_Detail_UID = {1} AND SP.Project_Name = N'{2}' AND OQCMa.Color = N'{3}' AND OQCMa.MaterialType = N'{4}' AND ProductDate = N'{5}' AND Time_interval = N'{6}' ", !searchHistory ? "OQC_InputMaster" : "OQC_InputMaster_History", searchModel.FlowChart_Detail_UID, searchModel.ProjectName, searchModel.Color, searchModel.MaterialType, searchModel.ProductDate.ToShortDateString(), searchModel.Time_interval); var query = DataContext.Database.SqlQuery <OQC_InputMasterDTO>(sql).ToList(); if (query.Count == 0) { var query1 = from QAinterface in DataContext.PPForQAInterface join flowDetails in DataContext.FlowChart_Detail on QAinterface.FlowChart_Detail_UID equals flowDetails.FlowChart_Detail_UID join flowMaster in DataContext.FlowChart_Master on flowDetails.FlowChart_Master_UID equals flowMaster.FlowChart_Master_UID where QAinterface.Color == searchModel.Color && QAinterface.Product_Date == searchModel.ProductDate && QAinterface.Time_Interval == searchModel.Time_interval && QAinterface.MaterielType == searchModel.MaterialType && QAinterface.QAUsedFlag == false && QAinterface.FlowChart_Detail_UID == searchModel.FlowChart_Detail_UID && flowDetails.FlowChart_Version == flowMaster.FlowChart_Version select new OQC_InputMasterDTO { Input = QAinterface.Input_Qty, GoodParts_Qty = QAinterface.Good_Qty, NGParts_Qty = QAinterface.NG_Qty, Rework = QAinterface.ReWorkQty, ProductDate = searchModel.ProductDate, Time_interval = searchModel.Time_interval, FlowChart_Detail_UID = searchModel.FlowChart_Detail_UID, Color = searchModel.Color, MaterialType = searchModel.MaterialType, Project_UID = flowMaster.Project_UID }; if (query1.Count() > 0) { result = query1.ToList()[0]; } else { var query2 = from flowDetails in DataContext.FlowChart_Detail join flowMaster in DataContext.FlowChart_Master on flowDetails.FlowChart_Master_UID equals flowMaster.FlowChart_Master_UID where flowDetails.FlowChart_Detail_UID == searchModel.FlowChart_Detail_UID && flowDetails.FlowChart_Version == flowMaster.FlowChart_Version select new OQC_InputMasterDTO { ProductDate = searchModel.ProductDate, Time_interval = searchModel.Time_interval, FlowChart_Detail_UID = searchModel.FlowChart_Detail_UID, Color = searchModel.Color, MaterialType = searchModel.MaterialType, Project_UID = flowMaster.Project_UID }; if (query2.Count() > 0) { result = query2.ToList()[0]; } } } else { result = query[0]; } } catch (Exception ex) { log.Error(ex); } return(result); }
public OQC_InputMasterDTO QueryOQCRecordData(QAReportSearchVM searchModel) { OQC_InputMasterDTO result = new OQC_InputMasterDTO(); #region int uid = 0; if (searchModel.FlowChart_Detail_UID != 0) { uid = searchModel.FlowChart_Detail_UID; } else { uid = GetDetailUID(searchModel.ProjectName, searchModel.Process, searchModel.ProductDate); } if (searchModel.Tab_Select_Text == "Night_Sum" || searchModel.Tab_Select_Text == "Daily_Sum" || searchModel.Tab_Select_Text == "ALL") { try { bool searchHistory = false; TimeSpan tSpan = DateTime.Now.Date - searchModel.ProductDate; if (tSpan.Days >= 7) { searchHistory = true; } string sql = string.Format(@" DECLARE @SumReworkQty INT , @SumNGQTy INT , @DailyEndTimeIndex INT , @NightEndTimeIndex INT , @StartIndex INT , @EndIndex INT , @TimeType VARCHAR(50) SET @TimeType = N'{6}' SELECT @DailyEndTimeIndex = CONVERT(INT, EN.Enum_Name) FROM dbo.Enumeration EN WITH ( NOLOCK ) INNER JOIN dbo.Enumeration E WITH ( NOLOCK ) ON E.Enum_Value = EN.Enum_Value WHERE En.Enum_Type = 'Time_InterVal_OP1' AND E.Enum_Type = 'Sum_TimeInterval' AND E.Enum_Name = 'Daily_Sum' SELECT @NightEndTimeIndex = CONVERT(INT, EN.Enum_Name) FROM dbo.Enumeration EN WITH ( NOLOCK ) INNER JOIN dbo.Enumeration E WITH ( NOLOCK ) ON E.Enum_Value = EN.Enum_Value WHERE En.Enum_Type = 'Time_InterVal_OP1' AND E.Enum_Type = 'Sum_TimeInterval' AND E.Enum_Name = 'Night_Sum' IF @TimeType = N'ALL' BEGIN SET @StartIndex = 1 SET @EndIndex = @NightEndTimeIndex END ELSE IF @TimeType = N'Daily_Sum' BEGIN SET @StartIndex = 1 SET @EndIndex = @DailyEndTimeIndex END ELSE IF @TimeType = N'Night_Sum' BEGIN SET @StartIndex = @DailyEndTimeIndex + 1 SET @EndIndex = @NightEndTimeIndex END SELECT @SumReworkQty = SUM(QaDetails.Qty) FROM dbo.{5} QaDetails WITH ( NOLOCK ) INNER JOIN dbo.{0} OQCMa WITH ( NOLOCK ) ON OQCMa.OQCMater_UID = QaDetails.OQCMater_UID INNER JOIN dbo.Enumeration en ON OQCMa.Time_Interval = en.Enum_Value WHERE FlowChart_Detail_UID = {1} AND QaDetails.TypeClassify = N'返修明细' AND OQCMa.Color = N'{2}' AND OQCMa.MaterialType = N'{3}' AND ProductDate = N'{4}' AND en.Enum_Type = N'Time_InterVal_OP1' AND CONVERT(INT, Enum_Name) <= @EndIndex AND CONVERT(INT, Enum_Name) >= @StartIndex SELECT @SumNGQTy = SUM(QaDetails.Qty) FROM dbo.{5} QaDetails WITH ( NOLOCK ) INNER JOIN dbo.{0} OQCMa WITH ( NOLOCK ) ON OQCMa.OQCMater_UID = QaDetails.OQCMater_UID INNER JOIN dbo.Enumeration en ON OQCMa.Time_Interval = en.Enum_Value WHERE FlowChart_Detail_UID = {1} AND QaDetails.TypeClassify = N'不良明细' AND OQCMa.Color = N'{2}' AND OQCMa.MaterialType = N'{3}' AND ProductDate = N'{4}' AND en.Enum_Type = N'Time_InterVal_OP1' AND CONVERT(INT, Enum_Name) <= @EndIndex AND CONVERT(INT, Enum_Name) >= @StartIndex SELECT OQCMa.FlowChart_Detail_UID , OQCMa.MaterialType , OQCMa.Color , OQCMa.Project_UID , SUM(OQCMa.Input) AS Input , SUM(OQCMa.GoodParts_Qty) AS GoodParts_Qty , SUM(OQCMa.NGParts_Qty) AS NGParts_Qty , SUM(OQCMa.Rework) AS Rework , SUM(OQCMa.ReworkQtyFromOQC) AS ReworkQtyFromOQC, SUM(OQCMa.ProductLineRework) AS ProductLineRework , SUM(OQCMa.ReworkQtyFromAssemble) AS ReworkQtyFromAssemble , SUM(OQCMa.RepairNG_Qty) AS RepairNG_Qty , SUM(OQCMa.NG_Qty) AS NG_Qty , @SumReworkQty * 1.00 / ( SUM(OQCMa.GoodParts_Qty) + SUM(OQCMa.NGParts_Qty) + SUM(OQCMa.Rework) + SUM(OQCMa.ProductLineRework) ) * 1.00 AS RepairNG_Yield , @SumNGQTy * 1.00 / ( SUM(OQCMa.GoodParts_Qty) + SUM(OQCMa.NGParts_Qty) ) * 1.00 AS NG_Yield , CASE WHEN ( SUM(OQCMa.GoodParts_Qty) + SUM(OQCMa.NGParts_Qty) + SUM(OQCMa.Rework) - SUM(OQCMa.ReworkQtyFromOQC) ) > 0 THEN (SUM(OQCMa.GoodParts_Qty)-SUM(OQCMa.ReworkQtyFromOQC)) * 1.00 / ( SUM(OQCMa.GoodParts_Qty) + SUM(OQCMa.NGParts_Qty) + SUM(OQCMa.Rework) - SUM(OQCMa.ReworkQtyFromOQC) ) * 1.00 ELSE 0 END AS FirstYieldRate , CASE WHEN ( SUM(OQCMa.GoodParts_Qty) + SUM(OQCMa.NGParts_Qty) ) > 0 THEN SUM(OQCMa.GoodParts_Qty) * 1.00 / ( SUM(OQCMa.GoodParts_Qty) + SUM(OQCMa.NGParts_Qty) ) * 1.00 ELSE 0 END AS SecondYieldRate , SUM(OQCMa.Storage_Qty) AS Storage_Qty , SUM(OQCMa.Storage_Qty) AS Storage_Qty , SUM(OQCMa.WaitStorage_Qty) AS WaitStorage_Qty , 0 AS WIP FROM dbo.{0} OQCMa WITH ( NOLOCK ) INNER JOIN dbo.Enumeration EN WITH ( NOLOCK ) ON OQCMa.Time_Interval = en.Enum_Value WHERE FlowChart_Detail_UID = {1} AND OQCMa.Color = N'{2}' AND OQCMa.MaterialType = N'{3}' AND ProductDate = N'{4}' AND en.Enum_Type = N'Time_InterVal_OP1' AND CONVERT(INT, Enum_Name) <= @EndIndex AND CONVERT(INT, Enum_Name) >= @StartIndex GROUP BY OQCMa.FlowChart_Detail_UID , OQCMa.MaterialType , OQCMa.Project_UID , OQCMa.Color ", !searchHistory ? "OQC_InputMaster" : "OQC_InputMaster_History", uid, searchModel.Color, searchModel.MaterialType, searchModel.ProductDate.ToShortDateString(), !searchHistory ? "OQC_InputDetail" : "OQC_InputDetail_History", searchModel.Tab_Select_Text); var query = DataContext.Database.SqlQuery <OQC_InputMasterDTO>(sql).ToList(); if (query.Count == 0) { return(result); } else { result = query[0]; } } catch (Exception ex) { log.Error(ex); } } else { try { bool searchHistory = false; TimeSpan tSpan = DateTime.Now.Date - searchModel.ProductDate; if (tSpan.Days >= 7) { searchHistory = true; } string sql = string.Format(@" SELECT OQCMa.* FROM dbo.{0} OQCMa WITH ( NOLOCK ) WHERE FlowChart_Detail_UID = {1} AND OQCMa.Color = N'{2}' AND OQCMa.MaterialType = N'{3}' AND ProductDate = N'{4}' AND Time_interval = N'{5}' ", !searchHistory ? "OQC_InputMaster" : "OQC_InputMaster_History", uid, searchModel.Color, searchModel.MaterialType, searchModel.ProductDate.ToShortDateString(), searchModel.Tab_Select_Text); var query = DataContext.Database.SqlQuery <OQC_InputMasterDTO>(sql).ToList(); if (query.Count == 0) { return(result); } else { result = query[0]; } } catch (Exception ex) { log.Error(ex); } } #endregion return(result); }