diff --git a/DataBase/版本日志/HJGLDB_DS_2026-07-13_bwj.sql b/DataBase/版本日志/HJGLDB_DS_2026-07-13_bwj.sql new file mode 100644 index 0000000..fe0b586 --- /dev/null +++ b/DataBase/版本日志/HJGLDB_DS_2026-07-13_bwj.sql @@ -0,0 +1,151 @@ + +ALTER PROCEDURE [dbo].[Sp_WeekWelding] +( + @StartWeldingDate DATETIME, + @EndWeldingDate DATETIME, + @WelderCode NVARCHAR(20) = NULL +) +AS +BEGIN + SET NOCOUNT ON; + + DECLARE @Sql NVARCHAR(MAX) + DECLARE @ColList NVARCHAR(MAX) = '' + DECLARE @ColNameList NVARCHAR(MAX) = '' + DECLARE @FinalDateCols NVARCHAR(MAX) = '' + + ;WITH DateCalendar AS ( + SELECT CAST(@StartWeldingDate AS DATE) AS WeldDay + UNION ALL + SELECT DATEADD(DAY, 1, WeldDay) + FROM DateCalendar + WHERE WeldDay < CAST(@EndWeldingDate AS DATE) + ) + SELECT + @ColList += ISNULL(',[' + CONVERT(VARCHAR, WeldDay, 23) + ']',''), + @ColNameList += ISNULL(',ISNULL([' + CONVERT(VARCHAR, WeldDay, 23) + '],0) AS [' + CONVERT(VARCHAR, WeldDay, 23) + ']',''), + @FinalDateCols += ISNULL(',t.[' + CONVERT(VARCHAR, WeldDay, 23) + ']','') + FROM DateCalendar + ORDER BY WeldDay + + SET @ColList = STUFF(@ColList,1,1,'') + SET @ColNameList = STUFF(@ColNameList,1,1,'') + SET @FinalDateCols = STUFF(@FinalDateCols,1,1,'') + + -- ̬תSQL + SET @Sql = N' + WITH DailyDataAll AS ( + SELECT + welder.WED_Code AS WelderCode, + CONVERT(DATE, daily.JOT_WeldDate) AS WeldDay, + SUM(ISNULL(jot.JOT_DoneDin, 0)) AS DailyWeldingSize + FROM HJGL_PW_JointInfo jot + LEFT JOIN dbo.HJGL_PW_IsoInfo pipe ON pipe.ISO_ID = jot.ISO_ID + LEFT JOIN HJGL_BO_WeldReportMain daily ON jot.DReportID = daily.DReportID + LEFT JOIN dbo.HJGL_BS_Welder welder ON welder.WED_ID = jot.JOT_FloorWelder + WHERE + daily.JOT_WeldDate >= @StartWeldingDate + AND daily.JOT_WeldDate < DATEADD(DAY, 1, @EndWeldingDate) + AND jot.JOT_Size <> jot.JOT_DoneDin + AND (@WelderCode IS NULL OR welder.WED_Code = @WelderCode) + GROUP BY welder.WED_Code, CONVERT(DATE, daily.JOT_WeldDate) + ), + FilterWelder AS ( + SELECT DISTINCT WelderCode + FROM DailyDataAll + WHERE DailyWeldingSize > 40 + ), + DailyData AS ( + SELECT a.* + FROM DailyDataAll a + INNER JOIN FilterWelder f ON a.WelderCode = f.WelderCode + ) + SELECT + pvt.WelderCode, + ' + @ColNameList + ' + FROM DailyData + PIVOT ( + SUM(DailyWeldingSize) + FOR WeldDay IN (' + @ColList + ') + ) pvt + ORDER BY pvt.WelderCode; + ' + + -- ʱֻ + CREATE TABLE #TempResult + ( + WelderCode NVARCHAR(50) + ); + + DECLARE @AddColSql NVARCHAR(MAX) = '' + ;WITH DateCalendar AS ( + SELECT CAST(@StartWeldingDate AS DATE) AS WeldDay + UNION ALL + SELECT DATEADD(DAY, 1, WeldDay) + FROM DateCalendar + WHERE WeldDay < CAST(@EndWeldingDate AS DATE) + ) + SELECT @AddColSql += 'ALTER TABLE #TempResult ADD [' + CONVERT(VARCHAR, WeldDay, 23) + '] FLOAT DEFAULT 0;' + FROM DateCalendar + ORDER BY WeldDay + EXEC(@AddColSql); + + -- ִж̬PIVOTдʱ + INSERT INTO #TempResult EXEC sp_executesql @Sql, + N'@StartWeldingDate DATETIME,@EndWeldingDate DATETIME,@WelderCode NVARCHAR(20)', + @StartWeldingDate,@EndWeldingDate,@WelderCode; + + -- ѯĿ + CREATE TABLE #WelderProject + ( + WelderCode NVARCHAR(50), + ProjectNames NVARCHAR(MAX) + ); + + INSERT INTO #WelderProject(WelderCode,ProjectNames) + SELECT DISTINCT + welder.WED_Code, + ISNULL(STUFF(( + SELECT DISTINCT ',' + proj.ProjectCode + FROM HJGL_PW_JointInfo jot2 + LEFT JOIN HJGL_PW_IsoInfo pipe2 ON pipe2.ISO_ID = jot2.ISO_ID + LEFT JOIN dbo.Base_Project proj ON proj.ProjectId = pipe2.ProjectId + LEFT JOIN HJGL_BO_WeldReportMain daily2 ON jot2.DReportID = daily2.DReportID + LEFT JOIN dbo.HJGL_BS_Welder welder2 ON welder2.WED_ID = jot2.JOT_FloorWelder + WHERE welder2.WED_Code = welder.WED_Code + AND daily2.JOT_WeldDate >= @StartWeldingDate + AND daily2.JOT_WeldDate < DATEADD(DAY, 1, @EndWeldingDate) + AND jot2.JOT_Size <> jot2.JOT_DoneDin + FOR XML PATH(''), TYPE + ).value('.','NVARCHAR(MAX)'),1,1,''),'') AS ProjectNames + FROM HJGL_PW_JointInfo jot + LEFT JOIN dbo.HJGL_PW_IsoInfo pipe ON pipe.ISO_ID = jot.ISO_ID + LEFT JOIN HJGL_BO_WeldReportMain daily ON jot.DReportID = daily.DReportID + LEFT JOIN dbo.HJGL_BS_Welder welder ON welder.WED_ID = jot.JOT_FloorWelder + WHERE + daily.JOT_WeldDate >= @StartWeldingDate + AND daily.JOT_WeldDate < DATEADD(DAY, 1, @EndWeldingDate) + AND jot.JOT_Size <> jot.JOT_DoneDin + AND (@WelderCode IS NULL OR welder.WED_Code = @WelderCode); + + -- ̬ƴSQL + DECLARE @FinalSql NVARCHAR(MAX) = N' + SELECT + t.WelderCode, + wp.ProjectNames, + ' + @FinalDateCols + ' + FROM #TempResult t + INNER JOIN #WelderProject wp ON t.WelderCode = wp.WelderCode + ORDER BY t.WelderCode; + ' + EXEC(@FinalSql); + + -- ʱ + DROP TABLE IF EXISTS #TempResult; + DROP TABLE IF EXISTS #WelderProject; +END + + +GO + + diff --git a/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/工艺管线参数信息导入模板.xls b/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/工艺管线参数信息导入模板.xls index fbfc92c..f336f32 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/工艺管线参数信息导入模板.xls and b/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/工艺管线参数信息导入模板.xls differ diff --git a/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊口信息导入模板.xls b/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊口信息导入模板.xls index fdbb3c0..6eef8e5 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊口信息导入模板.xls and b/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊口信息导入模板.xls differ diff --git a/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊接记录导入模板.xls b/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊接记录导入模板.xls index 20aee66..c5ca102 100644 Binary files a/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊接记录导入模板.xls and b/HJGL_DS/FineUIPro.Web/File/Excel/HJGL_DataIn/焊接记录导入模板.xls differ diff --git a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user index 6e29203..e3436b8 100644 --- a/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user +++ b/HJGL_DS/FineUIPro.Web/FineUIPro.Web.csproj.user @@ -2,7 +2,7 @@ true - Debug|Any CPU + Release|Any CPU diff --git a/HJGL_DS/FineUIPro.Web/HJGL/CheckManage/QualityRatingDataIn.aspx.cs b/HJGL_DS/FineUIPro.Web/HJGL/CheckManage/QualityRatingDataIn.aspx.cs index a4aa4ce..fb20fec 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/CheckManage/QualityRatingDataIn.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/CheckManage/QualityRatingDataIn.aspx.cs @@ -1,6 +1,7 @@ using BLL; using BLL.Common; using Model; +using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; using System.Data; @@ -32,6 +33,32 @@ namespace FineUIPro.Web.HJGL.CheckManage } } + private string BatchId + { + get + { + return (string)ViewState["BatchId"]; + } + set + { + + ViewState["BatchId"] = value; + } + } + + private string ISO_ID + { + get + { + return (string)ViewState["ISO_ID"]; + } + set + { + + ViewState["ISO_ID"] = value; + } + } + /// /// 错误集合 /// @@ -347,8 +374,8 @@ namespace FineUIPro.Web.HJGL.CheckManage percent[UserId] = (int)(100 * i / ir); string errInfo = string.Empty; string unitId = string.Empty; - string batchId = string.Empty; - string isoId = string.Empty; + //string batchId = string.Empty; + //string isoId = string.Empty; string jotId = string.Empty; int filmNum = 0; int rMatNum = 0; @@ -385,7 +412,7 @@ namespace FineUIPro.Web.HJGL.CheckManage } else { - batchId = getBatch.BatchId; + this.BatchId = getBatch.BatchId; } } else @@ -401,8 +428,8 @@ namespace FineUIPro.Web.HJGL.CheckManage } else { - isoId = getIso.ISO_ID; - newQualityRating.ISO_ID = isoId; + this.ISO_ID = getIso.ISO_ID; + newQualityRating.ISO_ID = this.ISO_ID; } } else @@ -411,7 +438,7 @@ namespace FineUIPro.Web.HJGL.CheckManage } if (!string.IsNullOrEmpty(tempData.Value4.Trim())) { - var getJoint = jointInfos.FirstOrDefault(x => x.ISO_ID == isoId && x.JOT_JointNo == tempData.Value4.Trim()); + var getJoint = jointInfos.FirstOrDefault(x => x.ISO_ID == this.ISO_ID && x.JOT_JointNo == tempData.Value4.Trim()); if (getJoint == null) { errInfo += "焊口号[" + tempData.Value4.Trim() + "]该管线下不存在;"; @@ -606,7 +633,7 @@ namespace FineUIPro.Web.HJGL.CheckManage } trustItem = (from x in db.HJGL_CH_TrustItem join y in db.HJGL_CH_Trust on x.CH_TrustID equals y.CH_TrustID - where y.BatchId == batchId && x.JOT_ID == jotId && x.States == "1" + where y.BatchId == this.BatchId && x.JOT_ID == jotId && x.States == "1" && y.CH_NDTMethod == "20d2cbca-8b3d-434b-b1c1-181796986fa5" select x).FirstOrDefault(); if (trustItem != null) @@ -722,8 +749,142 @@ namespace FineUIPro.Web.HJGL.CheckManage BLL.HJGL_PW_JointInfoService.JointFileNumWriteBack(jotId, qualityRating.Count()); BLL.HJGL_PW_JointInfoService.JointRMaterialWriteBack(jotId, totalRMatNum); BLL.HJGL_PW_JointInfoService.JointCheckStateWriteBack(jotId, "20d2cbca-8b3d-434b-b1c1-181796986fa5", trustItem.States); - BLL.HJGL_CH_TrustItemService.UpdateTrustItem(trustItem); + BLL.HJGL_CH_TrustItemService.UpdateTrustItem(trustItem); } + + #region 生成返修通知单 + //bool isExitNotOKItem = false; //是否存在不合格项 + List qualityRatingLists = new List(); + var cH_TrustItemIDs = from x in Funs.DB.HJGL_CH_TrustItem + join y in Funs.DB.HJGL_CH_Trust on x.CH_TrustID equals y.CH_TrustID + join j in Funs.DB.HJGL_PW_JointInfo on x.JOT_ID equals j.JOT_ID + where y.BatchId == this.BatchId && j.ISO_ID == this.ISO_ID + && y.CH_NDTMethod == "20d2cbca-8b3d-434b-b1c1-181796986fa5" + select x.CH_TrustItemID; + foreach (var CH_TrustItemID in cH_TrustItemIDs) + { + if (!string.IsNullOrEmpty(CH_TrustItemID)) + { + var trustItem = BLL.HJGL_CH_TrustItemService.GetTrustItemByID(CH_TrustItemID); + var jot = BLL.HJGL_PW_JointInfoService.GetJointInfoByJotID(trustItem.JOT_ID); + var trust = BLL.HJGL_TrustManageEditService.GetCH_TrustByID(trustItem.CH_TrustID); + Model.HJGL_BS_NDTType ndt = null; + if (trust.CH_NDTMethod != null) + { + ndt = BLL.HJGL_TestingService.GetTestingByTestingId(trust.CH_NDTMethod); + } + string defectNatures = string.Empty; + qualityRatingLists = BLL.HJGL_BO_QualityRatingService.GetQualityRatingByTrustDetailId(CH_TrustItemID); + qualityRatingLists = qualityRatingLists.Where(x => x.IsPass == "不合格").ToList(); // 获取不合格的项 + if (qualityRatingLists.Count() > 0) + { + //isExitNotOKItem = true; + foreach (var item in qualityRatingLists) + { + var oldRepairItemRecord = (from x in Funs.DB.HJGL_CH_RepairItemRecord + where x.JOT_ID == item.JOT_ID && x.TrustItemID == item.CH_TrustItemID && x.FilmNum == item.FilmNum + select x).FirstOrDefault(); + if (oldRepairItemRecord == null) + { + if (ndt != null && ndt.NDT_Code.Contains("RT")) + { + if (item.RMaterial == true) + { + defectNatures += "R母材,"; + } + if (item.Cack == true) + { + defectNatures += "裂纹,"; + } + if (item.NotFusion == true) + { + defectNatures += "未熔合,"; + } + if (item.NotPenetration == true) + { + defectNatures += "未焊透,"; + } + if (item.StripDefects == true) + { + defectNatures += "条状缺陷,"; + } + if (item.CircularDefects == true) + { + defectNatures += "圆形缺陷,"; + } + if (item.DeepHoleDefects == true) + { + defectNatures += "深孔缺陷,"; + } + if (item.RootsConcave == true) + { + defectNatures += "根部内凹,"; + } + if (item.RootsBiteEdge == true) + { + defectNatures += "根部咬边,"; + } + if (item.PseudoDefects == true) + { + defectNatures += "伪缺陷,"; + } + } + else + { + if (!string.IsNullOrEmpty(item.DefectNature)) + { + defectNatures = "缺陷性质:" + item.DefectNature + ","; + } + if (item.DefectLocation != null) + { + defectNatures = defectNatures + "缺陷位置:" + item.DefectLocation + ","; + } + if (item.DefectSize != null) + { + defectNatures = defectNatures + "缺陷尺寸:" + item.DefectSize + ","; + } + } + + if (!string.IsNullOrEmpty(defectNatures)) + { + defectNatures = defectNatures.Substring(0, defectNatures.LastIndexOf(",")); + } + + Model.HJGL_CH_RepairItemRecord newRepairItemRecord = new Model.HJGL_CH_RepairItemRecord(); + newRepairItemRecord.RepairItemRecordId = SQLHelper.GetNewID(typeof(Model.HJGL_CH_RepairItemRecord)); + newRepairItemRecord.ProjectId = trust.ProjectId; + newRepairItemRecord.ISO_ID = jot.ISO_ID; + newRepairItemRecord.JOT_ID = trustItem.JOT_ID; + newRepairItemRecord.FilmNum = item.FilmNum; + newRepairItemRecord.DefectNature = defectNatures; + newRepairItemRecord.TrustItemID = trustItem.CH_TrustItemID; + newRepairItemRecord.BatchId = trust.BatchId; + newRepairItemRecord.RepairMark = "R1"; + newRepairItemRecord.FeedbackDate = DateTime.Now; + newRepairItemRecord.NDT_ID = trust.CH_NDTMethod; + newRepairItemRecord.SignMan = this.CurrUser.UserName; + newRepairItemRecord.SignDate = DateTime.Now; + BLL.HJGL_CH_RepairItemRecordService.AddCH_RepairItemRecord(newRepairItemRecord); + + defectNatures = string.Empty; + } + } + + trustItem.ReportNoticeDate = DateTime.Now; + BLL.HJGL_CH_TrustItemService.UpdateTrustItem(trustItem); + } + } + } + //if (isExitNotOKItem) + //{ + // Alert.ShowInTop("成功生成返修通知单!", MessageBoxIcon.Success); + //} + //else + //{ + // Alert.ShowInTop("无不合格的项,请提交!", MessageBoxIcon.Warning); + // return; + //} + #endregion } #endregion diff --git a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/WeldReportIn.aspx.cs b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/WeldReportIn.aspx.cs index 6f8138a..cbc2691 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/DataIn/WeldReportIn.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/DataIn/WeldReportIn.aspx.cs @@ -325,8 +325,9 @@ namespace FineUIPro.Web.HJGL.DataIn var locationItems = BLL.DropListService.HJGL_JOT_LocationItem(); var welders = from x in db.HJGL_BS_Welder select x; var weldMethods = from x in db.HJGL_BS_WeldMethod select x; - var weldMats = from x in db.HJGL_BS_WeldMaterial where x.WMT_MatType == "2" select x; //焊条 - var weldSilks = from x in db.HJGL_BS_WeldMaterial where x.WMT_MatType == "1" select x; //焊丝 + //var weldMats = from x in db.HJGL_BS_WeldMaterial where x.WMT_MatType == "2" select x; //焊条 + //var weldSilks = from x in db.HJGL_BS_WeldMaterial where x.WMT_MatType == "1" select x; //焊丝 + var weldMaterials = from x in db.View_WeldInfoDropDownLists select x; //焊材 var welderQualifiedProjects = from x in db.HJGL_BS_WelderQualifiedProject select x; int ir = pds.Rows.Count; List jots = new List(); @@ -353,8 +354,8 @@ namespace FineUIPro.Web.HJGL.DataIn var floorWelderMan = welders.FirstOrDefault(x => x.WED_Code == col5); var locationItem = locationItems.FirstOrDefault(x => x.Text == col8); var weldMethod = weldMethods.FirstOrDefault(x => x.WME_Name == col12); - var weldMat = weldMats.FirstOrDefault(x => x.WMT_MatCode == col13); - var weldSilk = weldSilks.FirstOrDefault(x => x.WMT_MatCode == col14); + var weldMat = weldMaterials.FirstOrDefault(x => x.WeldTypeName.Contains("焊条") && x.WeldName == col13); + var weldSilk = weldMaterials.FirstOrDefault(x => x.WeldTypeName.Contains("焊丝") && x.WeldName == col14); if (joint == null) { if (string.IsNullOrEmpty(col0) || string.IsNullOrEmpty(col1) || string.IsNullOrEmpty(col2)) diff --git a/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx b/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx index d268bd9..8824e69 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx +++ b/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx @@ -4,114 +4,127 @@ - + 焊工单日工作量异常预警 - + } +
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.cs b/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.cs index a46cd5c..019bfc6 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.cs @@ -1,33 +1,28 @@ -using System; +using BLL; +using System; using System.Collections.Generic; -using System.Data.SqlClient; using System.Data; -using BLL; -using System.Text; -using AspNet = System.Web.UI.WebControls; -using NPOI.SS.UserModel; -using NPOI.XSSF.UserModel; -using System.IO; +using System.Data.SqlClient; using System.Linq; -using System.Web.UI.DataVisualization.Charting; -using FineUIPro.Web.common; namespace FineUIPro.Web.HJGL.WeldingReport { public partial class WelderDailyWorkExceptionWarning : PageBase { + #region 加载页面 + /// + /// 加载页面 + /// + /// + /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { - this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString(); - - this.drpProjectId.DataTextField = "ProjectCode"; - this.drpProjectId.DataValueField = "ProjectId"; - this.drpProjectId.DataSource = BLL.Base_ProjectService.GetProjectListByUserId(this.CurrUser.UserId, "1"); - this.drpProjectId.DataBind(); - Funs.FineUIPleaseSelect(this.drpProjectId); - this.drpProjectId.SelectedValue = this.CurrUser.LoginProjectId; + DateTime today = DateTime.Now.Date; + DateTime monthStart = today.AddMonths(-1).AddDays(1); + txtStartWeldingDate.Text = monthStart.ToString("yyyy-MM-dd"); + txtEndWeldingDate.Text = today.ToString("yyyy-MM-dd"); } } @@ -36,185 +31,57 @@ namespace FineUIPro.Web.HJGL.WeldingReport /// private void BindGrid() { - List listStr = new List(); - if (!string.IsNullOrEmpty(this.drpProjectId.SelectedValue) && this.drpProjectId.SelectedValue != BLL.Const._Null) + string startDate = txtStartWeldingDate.Text.Trim(); + string endDate = txtEndWeldingDate.Text.Trim(); + + List listParams = new List { - listStr.Add(new SqlParameter("@ProjectId", this.drpProjectId.SelectedValue)); - } - else + new SqlParameter("@StartWeldingDate", startDate), + new SqlParameter("@EndWeldingDate", endDate) + }; + if (!string.IsNullOrEmpty(txtWelderCode.Text.Trim())) { - Alert.ShowInTop("请选择施工号!", MessageBoxIcon.Warning); - return; + listParams.Add(new SqlParameter("@WelderCode", txtWelderCode.Text.Trim())); } - if (!string.IsNullOrEmpty(this.txtWeldingDate.Text.Trim())) + DataTable dt = SQLHelper.GetDataTableRunProc("Sp_WeekWelding", listParams.ToArray()); + + // 取出dt中所有日期字段(排除固定两列) + var dateCols = dt.Columns.Cast() + .Where(dc => dc.ColumnName != "WelderCode" && dc.ColumnName != "ProjectNames") + .Select(dc => dc.ColumnName) + .ToList(); + + int dateColIndex = 0; + // 遍历Grid所有列,只修改日期RenderField + foreach (var col in Grid1.Columns) { - listStr.Add(new SqlParameter("@WeldingDate", this.txtWeldingDate.Text.Trim())); + RenderField rf = col as RenderField; + if (rf == null) continue; + // 跳过基础固定列 + if (rf.ColumnID == "WelderCode" || rf.ColumnID == "ProjectNames") + continue; + + // 有对应查询日期则更新表头、绑定字段 + if (dateColIndex < dateCols.Count) + { + rf.Hidden = false; + string dateStr = dateCols[dateColIndex]; + rf.HeaderText = dateStr; + rf.ColumnID = dateStr; + rf.DataField = dateStr; + dateColIndex++; + } + else + { + // 查询区间不足31天,隐藏多余的列 + rf.Hidden = true; + } } - else - { - Alert.ShowInTop("请选择焊接日期!", MessageBoxIcon.Warning); - return; - } - if (!string.IsNullOrEmpty(this.txtWelderCode.Text.Trim())) - { - listStr.Add(new SqlParameter("@WelderCode", this.txtWelderCode.Text.Trim())); - } - else - { - listStr.Add(new SqlParameter("@WelderCode", null)); - } - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunProc("Sp_WeekWelding", parameter); - this.Grid1.RecordCount = tb.Rows.Count; - var table = this.GetPagedDataTable(Grid1, tb); - Grid1.DataSource = table; + Grid1.RecordCount = dt.Rows.Count; + Grid1.DataSource = dt; Grid1.DataBind(); - - foreach (GridColumn column in Grid1.Columns) - { - if (column.ColumnID == "week1") - { - column.HeaderText = txtWeldingDate.Text; - } - if (column.ColumnID == "week2") - { - column.HeaderText = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(txtWeldingDate.Text).AddDays(1)); - } - if (column.ColumnID == "week3") - { - column.HeaderText = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(txtWeldingDate.Text).AddDays(2)); - } - if (column.ColumnID == "week4") - { - column.HeaderText = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(txtWeldingDate.Text).AddDays(3)); - } - if (column.ColumnID == "week5") - { - column.HeaderText = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(txtWeldingDate.Text).AddDays(4)); - } - if (column.ColumnID == "week6") - { - column.HeaderText = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(txtWeldingDate.Text).AddDays(5)); - } - if (column.ColumnID == "week7") - { - column.HeaderText = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(txtWeldingDate.Text).AddDays(6)); - } - } - - } - - protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) - { - DataRowView row = e.DataItem as DataRowView; - double week1Num = Convert.ToDouble(row["week1"]); - RenderField week1 = Grid1.FindColumn("week1") as RenderField; - if (week1Num >= 50 && week1Num < 60) - { - e.CellCssClasses[week1.ColumnIndex] = "color2"; - } - if (week1Num >= 60) - { - e.CellCssClasses[week1.ColumnIndex] = "color1"; - } - - double week2Num = Convert.ToDouble(row["week2"]); - RenderField week2 = Grid1.FindColumn("week2") as RenderField; - if (week2Num >= 50 && week2Num < 60) - { - e.CellCssClasses[week2.ColumnIndex] = "color2"; - } - if (week2Num >= 60) - { - e.CellCssClasses[week2.ColumnIndex] = "color1"; - } - - double week3Num = Convert.ToDouble(row["week3"]); - RenderField week3 = Grid1.FindColumn("week3") as RenderField; - if (week3Num >= 50 && week3Num < 60) - { - e.CellCssClasses[week3.ColumnIndex] = "color2"; - } - if (week3Num >= 60) - { - e.CellCssClasses[week3.ColumnIndex] = "color1"; - } - - double week4Num = Convert.ToDouble(row["week4"]); - RenderField week4 = Grid1.FindColumn("week4") as RenderField; - if (week4Num >= 50 && week4Num < 60) - { - e.CellCssClasses[week4.ColumnIndex] = "color2"; - } - if (week4Num >= 60) - { - e.CellCssClasses[week4.ColumnIndex] = "color1"; - } - - double week5Num = Convert.ToDouble(row["week5"]); - RenderField week5 = Grid1.FindColumn("week5") as RenderField; - if (week5Num >= 50 && week5Num < 60) - { - e.CellCssClasses[week5.ColumnIndex] = "color2"; - } - if (week5Num >= 60) - { - e.CellCssClasses[week5.ColumnIndex] = "color1"; - } - - double week6Num = Convert.ToDouble(row["week6"]); - RenderField week6 = Grid1.FindColumn("week6") as RenderField; - if (week6Num >= 50 && week6Num < 60) - { - e.CellCssClasses[week6.ColumnIndex] = "color2"; - } - if (week6Num >= 60) - { - e.CellCssClasses[week6.ColumnIndex] = "color1"; - } - - double week7Num = Convert.ToDouble(row["week7"]); - RenderField week7 = Grid1.FindColumn("week7") as RenderField; - if (week7Num >= 50 && week7Num < 60) - { - e.CellCssClasses[week7.ColumnIndex] = "color2"; - } - if (week7Num >= 60) - { - e.CellCssClasses[week7.ColumnIndex] = "color1"; - } - } - - /// - /// 改变索引事件 - /// - /// - /// - 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 #region 统计按钮事件 /// @@ -224,102 +91,26 @@ namespace FineUIPro.Web.HJGL.WeldingReport /// protected void BtnAnalyse_Click(object sender, EventArgs e) { + string startDate = txtStartWeldingDate.Text.Trim(); + string endDate = txtEndWeldingDate.Text.Trim(); + if (string.IsNullOrEmpty(startDate) || string.IsNullOrEmpty(endDate)) + { + Alert.ShowInTop("请选择焊接起止日期", MessageBoxIcon.Warning); + return; + } + if (Convert.ToDateTime(startDate) > Convert.ToDateTime(endDate)) + { + Alert.ShowInTop("起始日期不能大于结束日期", MessageBoxIcon.Warning); + return; + } + int dayDiff = (Convert.ToDateTime(endDate) - Convert.ToDateTime(startDate)).Days + 1; + if (dayDiff > 31) + { + Alert.ShowInTop("查询区间不能超过31天,请缩小日期范围", MessageBoxIcon.Warning); + return; + } BindGrid(); } #endregion - - #region 导出按钮 - /// 导出按钮 - /// - /// - /// - protected void btnOut_Click(object sender, EventArgs e) - { - Response.ClearContent(); - string filename = Funs.GetNewFileName(); - Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊工单日工作量异常预警" + filename, System.Text.Encoding.UTF8) + ".xls"); - Response.ContentType = "application/excel"; - Response.ContentEncoding = System.Text.Encoding.UTF8; - Response.Write(GetGridTableHtml(Grid1)); - Response.End(); - } - - /// - /// 导出方法 - /// - /// - /// - private string GetGridTableHtml(Grid grid) - { - StringBuilder sb = new StringBuilder(); - grid.PageSize = 10000; - BindGrid(); - sb.Append(""); - sb.Append(""); - sb.Append(""); - foreach (GridColumn column in grid.Columns) - { - sb.AppendFormat("", column.HeaderText); - } - sb.Append(""); - foreach (GridRow row in grid.Rows) - { - sb.Append(""); - foreach (GridColumn column in grid.Columns) - { - string html = row.Values[column.ColumnIndex].ToString(); - if (column.ColumnID == "tfNumber") - { - html = (row.FindControl("labNumber") as AspNet.Label).Text; - } - sb.AppendFormat("", html); - } - - sb.Append(""); - } - - sb.Append("
{0}
{0}
"); - - return sb.ToString(); - } - #endregion - - #region NPOI私有方法 - private XSSFSheet ExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, bool istitle = false) - { - for (int i = sRows; i <= eRows; i++) - { - ws.CreateRow(i); - if (istitle) - { - ws.GetRow(i).HeightInPoints = - i == sRows ? 49.75f : - i == (sRows + 1) ? 13.75f : - 38f; - } - else - { - ws.GetRow(i).HeightInPoints = 38f; - } - for (int j = cStart; j <= cEnd; j++) - { - ws.GetRow(i).CreateCell(j); - ws.GetRow(i).GetCell(j).CellStyle = style; - } - } - return ws; - } - - private ICellStyle SetStyle(XSSFWorkbook ws, BorderStyle top, BorderStyle bottom, BorderStyle left, BorderStyle right) - { - ICellStyle style = ws.CreateCellStyle(); - style.BorderLeft = left; - style.BorderRight = right; - style.BorderTop = top; - style.BorderBottom = bottom; - - return style; - } - #endregion } } \ No newline at end of file diff --git a/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.designer.cs b/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.designer.cs index a3b49a6..4aeb0c3 100644 --- a/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.designer.cs +++ b/HJGL_DS/FineUIPro.Web/HJGL/WeldingReport/WelderDailyWorkExceptionWarning.aspx.designer.cs @@ -60,22 +60,22 @@ namespace FineUIPro.Web.HJGL.WeldingReport protected global::FineUIPro.Toolbar Toolbar1; /// - /// drpProjectId 控件。 + /// txtStartWeldingDate 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::FineUIPro.DropDownList drpProjectId; + protected global::FineUIPro.DatePicker txtStartWeldingDate; /// - /// txtWeldingDate 控件。 + /// txtEndWeldingDate 控件。 /// /// /// 自动生成的字段。 /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// - protected global::FineUIPro.DatePicker txtWeldingDate; + protected global::FineUIPro.DatePicker txtEndWeldingDate; /// /// txtWelderCode 控件。 @@ -104,15 +104,6 @@ namespace FineUIPro.Web.HJGL.WeldingReport /// protected global::FineUIPro.Button BtnAnalyse; - /// - /// btnOut 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.Button btnOut; - /// /// labNumber 控件。 /// @@ -121,32 +112,5 @@ namespace FineUIPro.Web.HJGL.WeldingReport /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label labNumber; - - /// - /// ToolbarSeparator1 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1; - - /// - /// ToolbarText1 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.ToolbarText ToolbarText1; - - /// - /// ddlPageSize 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.DropDownList ddlPageSize; } } diff --git a/HJGL_DS/FineUIPro.Web/Web.config b/HJGL_DS/FineUIPro.Web/Web.config index 1b40665..3c98f31 100644 --- a/HJGL_DS/FineUIPro.Web/Web.config +++ b/HJGL_DS/FineUIPro.Web/Web.config @@ -11,7 +11,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/HJGL_DS/WebAPI/WebAPI.csproj.user b/HJGL_DS/WebAPI/WebAPI.csproj.user index ef14066..8cd7f1f 100644 --- a/HJGL_DS/WebAPI/WebAPI.csproj.user +++ b/HJGL_DS/WebAPI/WebAPI.csproj.user @@ -1,7 +1,7 @@ - Debug|Any CPU + Release|Any CPU FolderProfile true