using BLL; using NPOI.XSSF.UserModel; using NPOI.SS.UserModel; using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; using Newtonsoft.Json.Linq; using BorderStyle = NPOI.SS.UserModel.BorderStyle; using System.Diagnostics; namespace FineUIPro.Web.WeldingProcess.WeldingManage { public partial class SuperQueWelding : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindGrid(); } } private void BindGrid() { DataTable tb = GetDataTable(); this.Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); Grid1.DataSource = table; Grid1.DataBind(); } /// /// 数据表 /// private DataTable GetDataTable() { string strSql = @"SELECT weldJoint.WeldJointId,weldJoint.ProjectId,WorkArea.WorkAreaId,wps.WPQCode, WorkArea.WorkAreaCode,pipeline.SingleNumber,pipeline.PipelineCode,weldJoint.WeldJointCode, weldType.WeldTypeCode,wl.WeldingLocationCode,weldJoint.Size,weldJoint.Thickness, weldJoint.Specification,mat1.MaterialCode AS MaterialCode1,mat2.MaterialCode AS MaterialCode2, WeldMethod.WeldingMethodCode,cw.WelderCode AS CoverWelderCode,fw.WelderCode AS BackingWelderCode, weldingDaily.WeldingDate, weldJoint.IsSuperQueWelding FROM Pipeline_WeldJoint AS weldJoint LEFT JOIN Pipeline_Pipeline AS pipeline ON pipeline.PipelineId = weldJoint.PipelineId LEFT JOIN Project_WorkArea AS WorkArea ON WorkArea.WorkAreaId = pipeline.WorkAreaId LEFT JOIN Base_Material AS mat1 ON mat1.MaterialId = weldJoint.Material1Id LEFT JOIN Base_Material AS mat2 ON mat2.MaterialId = weldJoint.Material2Id LEFT JOIN Base_WeldingMethod AS WeldMethod ON WeldMethod.WeldingMethodId = weldJoint.WeldingMethodId LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = weldJoint.WeldTypeId LEFT JOIN dbo.Base_WeldingLocation wl ON wl.WeldingLocationId = weldJoint.WeldingLocationId LEFT JOIN Pipeline_WeldingDaily AS weldingDaily ON weldingDaily.WeldingDailyId = weldJoint.WeldingDailyId LEFT JOIN Welder_Welder AS fw on weldJoint.BackingWelderId = fw.WelderId LEFT JOIN Welder_Welder AS cw on weldJoint.CoverWelderId = cw.WelderId LEFT JOIN dbo.WPQ_WPQList wps ON wps.WPQId = weldJoint.WPQId WHERE weldJoint.WeldingDailyId IS NOT NULL AND weldJoint.ProjectId=@projectId"; List listStr = new List(); listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId)); if (!string.IsNullOrEmpty(txtPipeLineCode.Text)) { strSql += " AND pipeline.PipelineCode LIKE @PipelineCode"; listStr.Add(new SqlParameter("@PipelineCode", "%" + this.txtPipeLineCode.Text.Trim() + "%")); } if (rbWarn.SelectedValue != "0") { strSql += " AND weldJoint.IsSuperQueWelding=1"; } if (txtStarTime.Text != "") { strSql += " AND weldingDaily.WeldingDate> = @WeldingStartDate"; listStr.Add(new SqlParameter("@WeldingStartDate", txtStarTime.Text.Trim())); } if (txtEndTime.Text != "") { strSql += " AND weldingDaily.WeldingDate< = @WeldingEndDate"; listStr.Add(new SqlParameter("@WeldingEndDate", txtEndTime.Text.Trim())); } strSql += " ORDER BY pipeline.PipelineCode,WeldJointCode"; SqlParameter[] parameter = listStr.ToArray(); DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter); return dt; } #region 按钮事件 /// /// 统计 /// /// /// protected void BtnAnalyse_Click(object sender, EventArgs e) { BindGrid(); } protected void BtnExtract_Click(object sender, EventArgs e) { bool canWPS = true; var jotList = (from x in Funs.DB.Pipeline_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId && x.WeldingDailyId != null && x.WeldingMethodId != null select x).ToList(); foreach (var jot in jotList) { var wps = BLL.WPQListServiceService.GetWPQById(jot.WPQId); string floorWelder = jot.BackingWelderId; string cellWelder = jot.CoverWelderId; if (wps != null) { // 验证焊工WPS资质 if (floorWelder == cellWelder) { if (!wps.WelderIds.Contains(floorWelder)) { canWPS = false; } } else { if (!wps.WelderIds.Contains(floorWelder)) { canWPS = false; } if (!wps.WelderIds.Contains(cellWelder)) { canWPS = false; } } } // 验证焊工合格项目资质 bool canSave = false; var joty = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId); var mat=BLL.Base_WeldingMethodService.GetWeldingMethodByWeldingMethodId(jot.WeldingMethodId); var loc=BLL.Base_WeldingLocationServie.GetWeldingLocationById(jot.WeldingLocationId); string weldTypeGroup = joty.Flag; string weldTypeCode = joty.WeldTypeCode; decimal? dia = jot.Dia; decimal? sch = jot.Thickness; string[] wmeCodes = mat.WeldingMethodCode.Split('+'); string location = loc.WeldingLocationCode; string ste = jot.Material1Id; List floorWelderQualifys = (from x in Funs.DB.Welder_WelderQualify where x.WelderId == floorWelder && x.WeldingMethodId != null && x.WeldingLocationId != null && x.MaterialType != null && x.WeldType != null && x.ThicknessMax != null && x.SizesMin != null select x).ToList(); List cellWelderQualifys = (from x in Funs.DB.Welder_WelderQualify where x.WelderId == cellWelder && x.WeldingMethodId != null && x.WeldingLocationId != null && x.MaterialType != null && x.WeldType != null && x.ThicknessMax != null && x.SizesMin != null select x).ToList(); // 打底和盖面同一焊工 if (floorWelder == cellWelder) { if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0) { if (wmeCodes.Count() <= 1) // 一种焊接方法 { canSave = BLL.WelderQualifiedService.IsOK(floorWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch); } else // 大于一种焊接方法,如氩电联焊 { canSave = BLL.WelderQualifiedService.TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldTypeGroup, ste, dia, sch); } } } // 打底和盖面焊工不同 else { bool isok1 = false; bool isok2 = false; if (wmeCodes.Count() <= 1) // 一种焊接方法 { if (floorWelderQualifys != null && floorWelderQualifys.Count() > 0) { isok1 = BLL.WelderQualifiedService.IsOK(floorWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch); } if (cellWelderQualifys != null && cellWelderQualifys.Count() > 0) { isok2 = BLL.WelderQualifiedService.IsOK(cellWelderQualifys, wmeCodes[0], location, weldTypeGroup, ste, dia, sch); } if (isok1 && isok2) { canSave = true; } } else { canSave = BLL.WelderQualifiedService.TwoWmeIsOK(floorWelderQualifys, cellWelderQualifys, wmeCodes[0], wmeCodes[1], location, weldTypeGroup, ste, dia, sch); } } if (canWPS==false || canSave == false) { jot.IsSuperQueWelding = true; Funs.DB.SubmitChanges(); } } ShowNotify("提取完成"); return; } #endregion protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { DataRowView row = e.DataItem as DataRowView; if (row["IsSuperQueWelding"].ToString() != "") { Boolean isSup = Convert.ToBoolean(row["IsSuperQueWelding"]); if (isSup==true) { e.RowCssClass = "color1"; } } } #region /// /// 改变索引事件 /// /// /// protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { BindGrid(); } /// /// 分页下拉选择事件 /// /// /// protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); BindGrid(); } /// /// 排序 /// /// /// protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e) { this.BindGrid(); } #endregion } }