From fdaf615194bfad71b7a3f282fe01d482a456ac5e Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Fri, 21 Aug 2026 15:22:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(hjgl):=20=E5=AE=8C=E5=96=84=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E7=BB=93=E6=9E=9C=E5=AF=BC=E5=85=A5=E4=B8=8E=E7=84=8A?= =?UTF-8?q?=E6=8E=A5=E8=B4=A8=E9=87=8F=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 通过批量导入、标准化打印和材料导出,减少检测结果及材料信息的人工整理,确保检测单、委托状态和焊口质量资料保持一致。 --- SGGL/BLL/BLL.csproj | 3 +- SGGL/BLL/Common/Const.cs | 11 + SGGL/BLL/HJGL/NDT/Batch_NDEImportService.cs | 170 ++++++ .../WeldAppearanceCheckService.cs | 90 +++- .../File/Excel/DataIn/检测结果导入模板.xlsx | Bin 0 -> 3928 bytes .../Fastreport/管道焊接接头报检/检查记录.frx | 71 +++ SGGL/FineUIPro.Web/FineUIPro.Web.csproj | 12 +- .../HJGL/DataImport/MaterialInformation.aspx | 7 +- .../DataImport/MaterialInformation.aspx.cs | 122 +---- .../MaterialInformation.aspx.designer.cs | 18 +- SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx | 6 + SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.cs | 23 + .../HJGL/NDT/NDTBatch.aspx.designer.cs | 104 ++-- .../HJGL/NDT/NDTBatchUnitImport.aspx | 80 +++ .../HJGL/NDT/NDTBatchUnitImport.aspx.cs | 496 ++++++++++++++++++ .../NDT/NDTBatchUnitImport.aspx.designer.cs | 23 + .../WeldingManage/WeldAppearanceCheck.aspx | 12 + .../WeldingManage/WeldAppearanceCheck.aspx.cs | 122 ++++- .../WeldAppearanceCheck.aspx.designer.cs | 27 + .../APIItem/HJGL/WeldAppearanceCheckItem.cs | 10 + 20 files changed, 1236 insertions(+), 171 deletions(-) create mode 100644 SGGL/BLL/HJGL/NDT/Batch_NDEImportService.cs create mode 100644 SGGL/FineUIPro.Web/File/Excel/DataIn/检测结果导入模板.xlsx create mode 100644 SGGL/FineUIPro.Web/File/Fastreport/管道焊接接头报检/检查记录.frx create mode 100644 SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx create mode 100644 SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.cs create mode 100644 SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.designer.cs diff --git a/SGGL/BLL/BLL.csproj b/SGGL/BLL/BLL.csproj index 5d35c895..e3604353 100644 --- a/SGGL/BLL/BLL.csproj +++ b/SGGL/BLL/BLL.csproj @@ -432,6 +432,7 @@ + @@ -920,4 +921,4 @@ --> - \ No newline at end of file + diff --git a/SGGL/BLL/Common/Const.cs b/SGGL/BLL/Common/Const.cs index e58c48d2..00e9501a 100644 --- a/SGGL/BLL/Common/Const.cs +++ b/SGGL/BLL/Common/Const.cs @@ -3553,6 +3553,17 @@ namespace BLL /// public const string NDTBatchTemplateUrl = "File\\Excel\\DataIn\\管道焊口检测结果通知单导入模板.xlsx"; + /// + /// 检测结果批量导入空白模板 + /// + public const string NDTBatchUnitImportTemplateUrl = "File\\Excel\\DataIn\\检测结果导入模板.xlsx"; + + /// + /// 管道焊接接头报检/检查记录打印模板 + /// + public const string WeldAppearanceCheckReportTemplateUrl = + "File\\Fastreport\\管道焊接接头报检\\检查记录.frx"; + #endregion #region 初始化上传路径 diff --git a/SGGL/BLL/HJGL/NDT/Batch_NDEImportService.cs b/SGGL/BLL/HJGL/NDT/Batch_NDEImportService.cs new file mode 100644 index 00000000..2f1ac0f2 --- /dev/null +++ b/SGGL/BLL/HJGL/NDT/Batch_NDEImportService.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace BLL +{ + /// + /// 单位工程级检测结果导入行 + /// + public class UnitWorkNDEImportItem + { + public int RowNumber { get; set; } + + public string TrustBatchId { get; set; } + + public string TrustBatchCode { get; set; } + + public string TrustBatchItemId { get; set; } + + public string PipelineCode { get; set; } + + public string WeldJointCode { get; set; } + + public string WelderCode { get; set; } + + public int TotalFilm { get; set; } + + public int PassFilm { get; set; } + + public string CheckResult { get; set; } + + public string CheckResultText { get; set; } + + public string JudgeGrade { get; set; } + + public string CheckDefects { get; set; } + + public string CheckDefectsText { get; set; } + + public string RepairLocation { get; set; } + + public string Remark { get; set; } + + public DateTime? FilmDate { get; set; } + + public DateTime? ReportDate { get; set; } + } + + /// + /// 单位工程级检测结果批量导入 + /// + public static class Batch_NDEImportService + { + /// + /// 一次性保存检测单主表、明细和委托检测状态 + /// + public static void Import(string projectId, string unitWorkId, string personId, IList importItems) + { + if (importItems == null || importItems.Count == 0) + { + throw new InvalidOperationException("没有可导入的数据!"); + } + + Model.SGGLDB db = Funs.DB; + bool isValidUnitWork = db.WBS_UnitWork.Any(x => x.UnitWorkId == unitWorkId + && x.ProjectId == projectId + && x.SuperUnitWork == null); + if (!isValidUnitWork) + { + throw new InvalidOperationException("单位工程不存在或不属于当前项目!"); + } + + List trustBatchIds = importItems.Select(x => x.TrustBatchId).Distinct().ToList(); + List trustBatchItemIds = importItems.Select(x => x.TrustBatchItemId).Distinct().ToList(); + + List trusts = db.HJGL_Batch_BatchTrust + .Where(x => trustBatchIds.Contains(x.TrustBatchId) + && x.ProjectId == projectId + && x.UnitWorkId == unitWorkId) + .ToList(); + if (trusts.Count != trustBatchIds.Count) + { + throw new InvalidOperationException("导入数据包含不属于当前单位工程的委托单,请重新审核文件!"); + } + + if (trustBatchItemIds.Count != importItems.Count) + { + throw new InvalidOperationException("导入数据包含重复的委托明细,请重新审核文件!"); + } + + List trustItems = db.HJGL_Batch_BatchTrustItem + .Where(x => trustBatchItemIds.Contains(x.TrustBatchItemId) + && trustBatchIds.Contains(x.TrustBatchId)) + .ToList(); + if (trustItems.Count != trustBatchItemIds.Count + || importItems.Any(x => !trustItems.Any(y => y.TrustBatchItemId == x.TrustBatchItemId + && y.TrustBatchId == x.TrustBatchId))) + { + throw new InvalidOperationException("导入数据包含无效的委托明细,请重新审核文件!"); + } + + List importedTrustBatchIds = db.HJGL_Batch_NDE + .Where(x => trustBatchIds.Contains(x.TrustBatchId)) + .Select(x => x.TrustBatchId) + .ToList(); + if (importedTrustBatchIds.Count > 0) + { + string codes = string.Join("、", importItems + .Where(x => importedTrustBatchIds.Contains(x.TrustBatchId)) + .Select(x => x.TrustBatchCode) + .Distinct()); + throw new InvalidOperationException("委托单[" + codes + "]已存在检测结果,不能重复导入!"); + } + + List ndeList = new List(); + List ndeItemList = new List(); + DateTime submitDate = DateTime.Now; + + foreach (IGrouping group in importItems.GroupBy(x => x.TrustBatchId)) + { + Model.HJGL_Batch_BatchTrust trust = trusts.First(x => x.TrustBatchId == group.Key); + string ndeId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_NDE)); + + // 检测流水号沿用检测单编辑页的委托编号转换规则。 + string ndeCode = trust.TrustType == "R" + ? trust.TrustBatchCode.Replace("-FXWT-", "-FXJC-") + : trust.TrustBatchCode.Replace("-WT-", "-JC-"); + ndeList.Add(new Model.HJGL_Batch_NDE + { + NDEID = ndeId, + TrustBatchId = trust.TrustBatchId, + ProjectId = projectId, + UnitId = trust.UnitId, + UnitWorkId = unitWorkId, + NDEUnit = trust.NDEUnit, + NDECode = ndeCode, + NDEMan = personId + }); + + foreach (UnitWorkNDEImportItem importItem in group) + { + ndeItemList.Add(new Model.HJGL_Batch_NDEItem + { + NDEItemID = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_NDEItem)), + NDEID = ndeId, + TrustBatchItemId = importItem.TrustBatchItemId, + DetectionTypeId = trust.DetectionTypeId, + TotalFilm = importItem.TotalFilm, + PassFilm = importItem.PassFilm, + CheckResult = importItem.CheckResult, + JudgeGrade = importItem.JudgeGrade, + CheckDefects = importItem.CheckDefects, + RepairLocation = importItem.RepairLocation, + Remark = importItem.Remark, + FilmDate = importItem.FilmDate, + ReportDate = importItem.ReportDate, + SubmitDate = submitDate + }); + } + + trust.IsCheck = true; + } + + // 同一 DataContext 只提交一次,保证主表、明细和委托状态要么全部成功,要么全部失败。 + db.HJGL_Batch_NDE.InsertAllOnSubmit(ndeList); + db.HJGL_Batch_NDEItem.InsertAllOnSubmit(ndeItemList); + db.SubmitChanges(); + } + } +} diff --git a/SGGL/BLL/HJGL/WeldingManage/WeldAppearanceCheckService.cs b/SGGL/BLL/HJGL/WeldingManage/WeldAppearanceCheckService.cs index c4ee56c8..920677ad 100644 --- a/SGGL/BLL/HJGL/WeldingManage/WeldAppearanceCheckService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/WeldAppearanceCheckService.cs @@ -13,6 +13,7 @@ namespace BLL /// 分页查询焊缝外观检测记录。 /// /// 项目ID。 + /// 检测编号。 /// 管线号查询条件。 /// 焊口号查询条件。 /// 合格状态,1为合格,0为不合格,空为全部。 @@ -20,7 +21,7 @@ namespace BLL /// 每页记录数。 /// 外观检测记录及总记录数。 public static Tuple, int> GetList(string projectId, - string pipelineCode, string weldJointCode, string qualified, int pageIndex, int pageSize) + string checkCode, string pipelineCode, string weldJointCode, string qualified, int pageIndex, int pageSize) { var db = Funs.DB; var query = from c in db.HJGL_WeldAppearanceCheck @@ -30,6 +31,10 @@ namespace BLL where string.IsNullOrEmpty(projectId) || c.ProjectId == projectId select new { c, w, CheckPersonName = p == null ? string.Empty : p.PersonName }; + if (!string.IsNullOrWhiteSpace(checkCode)) + { + query = query.Where(x => x.c.CheckCode == checkCode); + } if (!string.IsNullOrWhiteSpace(pipelineCode)) { query = query.Where(x => x.w.PipelineCode.Contains(pipelineCode)); @@ -71,10 +76,93 @@ namespace BLL InterpassTemperature = x.c.InterpassTemperature, CreateTime = x.c.CreateTime }).ToList(); + PopulateReportFields(data); PopulateAttachUrls(data); return Tuple.Create(data, total); } + private static void PopulateReportFields(List data) + { + List weldJointIds = data.Select(x => x.WeldJointId).Distinct().ToList(); + if (weldJointIds.Count == 0) + { + return; + } + + var details = Funs.DB.View_HJGL_WeldJoint + .Where(x => weldJointIds.Contains(x.WeldJointId)) + .Select(x => new + { + x.WeldJointId, + x.UnitWorkId, + x.UnitWorkName, + x.WelderCode, + x.Specification, + x.MaterialCode, + x.WeldingLocationCode, + x.WeldingMethodCode, + x.WeldingRod, + x.WeldingRodCode, + x.WeldingWire, + x.WeldingWireCode + }).ToList(); + + List consumablesIds = details + .SelectMany(x => new[] { x.WeldingWire, x.WeldingRod }) + .Where(x => !string.IsNullOrWhiteSpace(x)) + .Distinct() + .ToList(); + var consumablesById = new Dictionary(); + if (consumablesIds.Count > 0) + { + consumablesById = Funs.DB.Base_Consumables + .Where(x => consumablesIds.Contains(x.ConsumablesId)) + .ToDictionary(x => x.ConsumablesId, x => x.ConsumablesName); + } + + foreach (Model.WeldAppearanceCheckItem item in data) + { + var detail = details.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); + if (detail == null) + { + continue; + } + + item.UnitWorkId = detail.UnitWorkId; + item.UnitWorkName = detail.UnitWorkName; + item.WelderCode = detail.WelderCode; + item.Specification = detail.Specification; + item.MaterialCode = detail.MaterialCode; + item.WeldingLocation = detail.WeldingLocationCode; + item.WeldingMethodCode = detail.WeldingMethodCode; + item.WeldingRodCode = detail.WeldingRodCode; + item.WeldingWireCode = detail.WeldingWireCode; + string wireName; + string rodName; + consumablesById.TryGetValue(detail.WeldingWire ?? string.Empty, out wireName); + consumablesById.TryGetValue(detail.WeldingRod ?? string.Empty, out rodName); + // 焊材牌号使用焊丝、焊条在耗材基础表中的名称,按既有报表口径以“+”合并并去重。 + item.WeldingMaterial = string.Join("+", new[] { wireName, rodName } + .Where(x => !string.IsNullOrWhiteSpace(x)).Distinct()); + } + } + + /// + /// 查询当前项目可用于筛选和打印的检测编号。 + /// + /// 项目ID。 + /// 检测编号列表。 + public static List GetCheckCodes(string projectId) + { + return Funs.DB.HJGL_WeldAppearanceCheck + .Where(x => (string.IsNullOrEmpty(projectId) || x.ProjectId == projectId) + && x.CheckCode != null && x.CheckCode != string.Empty) + .Select(x => x.CheckCode) + .Distinct() + .OrderByDescending(x => x) + .ToList(); + } + /// /// 分页查询当前项目中已焊接的焊口。 /// diff --git a/SGGL/FineUIPro.Web/File/Excel/DataIn/检测结果导入模板.xlsx b/SGGL/FineUIPro.Web/File/Excel/DataIn/检测结果导入模板.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..69ddd85104e3703d874b6a8aa889cec47cb82a64 GIT binary patch literal 3928 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 literal 0 HcmV?d00001 diff --git a/SGGL/FineUIPro.Web/File/Fastreport/管道焊接接头报检/检查记录.frx b/SGGL/FineUIPro.Web/File/Fastreport/管道焊接接头报检/检查记录.frx new file mode 100644 index 00000000..4575ed08 --- /dev/null +++ b/SGGL/FineUIPro.Web/File/Fastreport/管道焊接接头报检/检查记录.frx @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index 1c442671..bed90116 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -1626,6 +1626,7 @@ + @@ -3659,6 +3660,7 @@ + @@ -3704,6 +3706,7 @@ + @@ -10933,6 +10936,13 @@ NDTBatchImport.aspx + + NDTBatchUnitImport.aspx + ASPXCodeBehind + + + NDTBatchUnitImport.aspx + RepairNotice.aspx ASPXCodeBehind @@ -17342,4 +17352,4 @@ --> - \ No newline at end of file + diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx index fd346d17..888e80be 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx @@ -88,13 +88,12 @@ - - - + + diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs index d852a1e8..1a201d24 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.cs @@ -734,73 +734,6 @@ namespace FineUIPro.Web.HJGL.DataImport #endregion - #region 报表打印 - /// - /// 报表打印 - /// - /// - /// - protected void btnPrint_Click(object sender, EventArgs e) - { - string pipelineId = this.tvControlItem.SelectedNodeID; - var q = BLL.PipelineService.GetPipelineByPipelineId(pipelineId); - - if (q != null) - { - var jotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == pipelineId select x).Count(); - var weldJotCount = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == pipelineId && x.WeldingDailyId != null select x).Count(); - if (jotCount == weldJotCount) - { - string varValue = string.Empty; - var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); - if (project != null) - { - varValue = project.ProjectName; - var unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(q.UnitWorkId); - if (unitWork != null) - { - varValue = varValue + "|" + unitWork.UnitWorkName; - } - } - List listStr = new List(); - listStr.Add(new SqlParameter("@IsoId", pipelineId)); - listStr.Add(new SqlParameter("@Flag", "0")); - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = BLL.SQLHelper.GetDataTableRunProc("HJGL_spJointWorkRecordNew", parameter); - string page = Funs.GetPagesCountByPageSize(11, 16, tb.Rows.Count).ToString(); - - - varValue = varValue + "|" + page; - - if (!string.IsNullOrEmpty(varValue)) - { - varValue = HttpUtility.UrlEncodeUnicode(varValue); - } - if (tb.Rows.Count <= 11) - { - PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReport1Id, pipelineId, varValue, this.CurrUser.LoginProjectId))); - } - else - { - PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReport2Id, pipelineId, varValue, this.CurrUser.LoginProjectId))); - PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReport1Id, pipelineId, varValue, this.CurrUser.LoginProjectId))); - } - } - else - { - ShowNotify("请选择焊接完成管线!", MessageBoxIcon.Warning); - return; - } - } - - else - { - ShowNotify("请选择管线!", MessageBoxIcon.Warning); - return; - } - } - #endregion - #region 关闭弹出窗口及刷新页面 /// /// 关闭弹出窗口 @@ -951,47 +884,17 @@ namespace FineUIPro.Web.HJGL.DataImport /// protected void btnOut_Click(object sender, EventArgs e) { - //var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); - //var workArea = BLL.Project_WorkAreaService.GetProject_WorkAreaByWorkAreaId(this.tvControlItem.SelectedNodeID); - //if (iso != null) - //{ - // PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("JointInfoOut.aspx?PipelineId={0}", this.tvControlItem.SelectedNodeID, "导出 - "))); - //} - //else if (workArea != null) - //{ - // PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("JointInfoOut.aspx?WorkAreaId={0}", this.tvControlItem.SelectedNodeID, "导出 - "))); - //} - //else - //{ - // Alert.ShowInTop("请选择"PipelineOrArea, MessageBoxIcon.Warning); - //} - } - - /// - /// 导出焊口初始信息 - /// - /// - /// - protected void btnOut2_Click(object sender, EventArgs e) - { - //var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(this.tvControlItem.SelectedNodeID); - //if (iso != null) - //{ - // Response.ClearContent(); - // string filename = Funs.GetNewFileName(); - // Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(Resources.Lan.WeldingJointInfo + filename, System.Text.Encoding.UTF8) + ".xls"); - // Response.ContentType = "application/excel"; - // Response.ContentEncoding = System.Text.Encoding.UTF8; - // this.Grid1.PageSize = 100000; - // this.BindGrid(); - // Response.Write(GetGridTableHtml(Grid1)); - // Response.End(); - //} - //else - //{ - // Alert.ShowInTop("请选择"PipelinetFirst, MessageBoxIcon.Warning); - //} + 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; + this.Grid1.PageSize = 500; + this.BindGrid1(this.tvControlItem.SelectedNodeID, this.hdUnitWorkId.Text); + Response.Write(GetGridTableHtml(Grid1)); + Response.End(); } + /// /// 导出方法btnMatImport_Click @@ -1046,9 +949,6 @@ namespace FineUIPro.Web.HJGL.DataImport this.BindGrid2(this.tvControlItem.SelectedNodeID, this.hdUnitWorkId.Text); } - - - #region 管线材料导入 /// @@ -1123,5 +1023,7 @@ namespace FineUIPro.Web.HJGL.DataImport { } + + } } diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.designer.cs index f8071939..c3a08366 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/MaterialInformation.aspx.designer.cs @@ -176,15 +176,6 @@ namespace FineUIPro.Web.HJGL.DataImport /// protected global::FineUIPro.Button btnQuery; - /// - /// btnPrint 控件。 - /// - /// - /// 自动生成的字段。 - /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 - /// - protected global::FineUIPro.Button btnPrint; - /// /// btnMatImport 控件。 /// @@ -194,6 +185,15 @@ namespace FineUIPro.Web.HJGL.DataImport /// protected global::FineUIPro.Button btnMatImport; + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + /// /// TabStrip1 控件。 /// diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx index e40ae9cd..767c5206 100644 --- a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx @@ -44,6 +44,12 @@ + + + + + /// 单位工程级批量导入检测结果 + /// + protected void btnUnitWorkImport_Click(object sender, EventArgs e) + { + if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_NDTBatchMenuId, Const.BtnSave)) + { + ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); + return; + } + + if (this.tvControlItem.SelectedNode == null || this.tvControlItem.SelectedNode.CommandName != "单位工程") + { + ShowNotify("请先选中单位工程节点!", MessageBoxIcon.Warning); + return; + } + + string window = string.Format("NDTBatchUnitImport.aspx?unitWorkId={0}&type={1}", + Server.UrlEncode(this.tvControlItem.SelectedNodeID), Server.UrlEncode(this.Type)); + PageContext.RegisterStartupScript(Window2.GetShowReference(window)); + } } } diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.designer.cs index e042d122..f67e8823 100644 --- a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace FineUIPro.Web.HJGL.NDT { - - - public partial class NDTBatch { - +namespace FineUIPro.Web.HJGL.NDT +{ + + + public partial class NDTBatch + { + /// /// form1 控件。 /// @@ -20,7 +22,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; - + /// /// PageManager1 控件。 /// @@ -29,7 +31,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.PageManager PageManager1; - + /// /// Panel1 控件。 /// @@ -38,7 +40,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel Panel1; - + /// /// panelLeftRegion 控件。 /// @@ -47,7 +49,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel panelLeftRegion; - + /// /// Toolbar1 控件。 /// @@ -56,7 +58,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar Toolbar1; - + /// /// txtNDEDateMonth 控件。 /// @@ -65,7 +67,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DatePicker txtNDEDateMonth; - + /// /// Toolbar3 控件。 /// @@ -74,7 +76,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar Toolbar3; - + /// /// drpUnit 控件。 /// @@ -83,7 +85,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpUnit; - + /// /// Toolbar5 控件。 /// @@ -92,7 +94,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar Toolbar5; - + /// /// txtSearchCode 控件。 /// @@ -101,7 +103,25 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtSearchCode; - + + /// + /// Toolbar6 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar6; + + /// + /// btnUnitWorkImport 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnUnitWorkImport; + /// /// tvControlItem 控件。 /// @@ -110,7 +130,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Tree tvControlItem; - + /// /// panelCenterRegion 控件。 /// @@ -119,7 +139,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel panelCenterRegion; - + /// /// Toolbar2 控件。 /// @@ -128,7 +148,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar Toolbar2; - + /// /// hdTrustBatchId 控件。 /// @@ -137,7 +157,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.HiddenField hdTrustBatchId; - + /// /// ToolbarFill1 控件。 /// @@ -146,7 +166,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarFill ToolbarFill1; - + /// /// BtnRepairRecord 控件。 /// @@ -155,7 +175,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button BtnRepairRecord; - + /// /// SimpleForm1 控件。 /// @@ -164,7 +184,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Form SimpleForm1; - + /// /// txtNDECode 控件。 /// @@ -173,7 +193,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Label txtNDECode; - + /// /// txtUnitName 控件。 /// @@ -182,7 +202,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Label txtUnitName; - + /// /// txtCheckUnit 控件。 /// @@ -191,7 +211,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Label txtCheckUnit; - + /// /// txtDetectionTypeCode 控件。 /// @@ -200,7 +220,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Label txtDetectionTypeCode; - + /// /// txtIsCheck 控件。 /// @@ -209,7 +229,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Label txtIsCheck; - + /// /// txtNDEDate 控件。 /// @@ -218,7 +238,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Label txtNDEDate; - + /// /// Grid1 控件。 /// @@ -227,7 +247,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid Grid1; - + /// /// lbCheckDefects 控件。 /// @@ -236,7 +256,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label lbCheckDefects; - + /// /// ToolbarSeparator1 控件。 /// @@ -245,7 +265,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1; - + /// /// ToolbarText1 控件。 /// @@ -254,7 +274,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarText ToolbarText1; - + /// /// ddlPageSize 控件。 /// @@ -263,7 +283,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList ddlPageSize; - + /// /// Window1 控件。 /// @@ -272,7 +292,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window Window1; - + /// /// Window2 控件。 /// @@ -281,7 +301,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window Window2; - + /// /// WindowRepair 控件。 /// @@ -290,7 +310,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window WindowRepair; - + /// /// Menu1 控件。 /// @@ -299,7 +319,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Menu Menu1; - + /// /// btnDataIn 控件。 /// @@ -308,7 +328,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.MenuButton btnDataIn; - + /// /// btnNew 控件。 /// @@ -317,7 +337,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.MenuButton btnNew; - + /// /// btnEdit 控件。 /// @@ -326,7 +346,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.MenuButton btnEdit; - + /// /// btnAudit 控件。 /// @@ -335,7 +355,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.MenuButton btnAudit; - + /// /// btnView 控件。 /// @@ -344,7 +364,7 @@ namespace FineUIPro.Web.HJGL.NDT { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.MenuButton btnView; - + /// /// btnDelete 控件。 /// diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx new file mode 100644 index 00000000..336e289b --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx @@ -0,0 +1,80 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NDTBatchUnitImport.aspx.cs" Inherits="FineUIPro.Web.HJGL.NDT.NDTBatchUnitImport" %> + + + + + + 检测结果导入 + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.cs b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.cs new file mode 100644 index 00000000..83e0f9c6 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.cs @@ -0,0 +1,496 @@ +using BLL; +using MiniExcelLibs; +using Model; +using System; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Linq; +using System.Web; + +namespace FineUIPro.Web.HJGL.NDT +{ + public partial class NDTBatchUnitImport : PageBase + { + private static readonly string[] TemplateColumns = + { + "序号", "委托编号", "管线号", "检件焊口号", "焊工号", "检测总数", + "合格数", "是否合格", "评定级别", "缺陷", "返修位置", "备注", + "检测日期", "报告日期" + }; + + private string UnitWorkId + { + get { return Convert.ToString(ViewState["UnitWorkId"]); } + set { ViewState["UnitWorkId"] = value; } + } + + private string NDTType + { + get { return Convert.ToString(ViewState["NDTType"]); } + set { ViewState["NDTType"] = value; } + } + + private string ImportCacheKey + { + get { return Convert.ToString(ViewState["ImportCacheKey"]); } + set { ViewState["ImportCacheKey"] = value; } + } + + private List ImportItems + { + get + { + return Session[ImportCacheKey] as List + ?? new List(); + } + set { Session[ImportCacheKey] = value; } + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + UnitWorkId = Request.QueryString["unitWorkId"]; + NDTType = Request.QueryString["type"]; + ImportCacheKey = "NDTBatchUnitImport_" + Guid.NewGuid().ToString("N"); + ImportItems = new List(); + + WBS_UnitWork unitWork = Funs.DB.WBS_UnitWork.FirstOrDefault(x => + x.UnitWorkId == UnitWorkId + && x.ProjectId == CurrUser.LoginProjectId + && x.SuperUnitWork == null); + if (unitWork == null) + { + btnAudit.Enabled = false; + btnSave.Enabled = false; + btnDownLoad.Enabled = false; + ShowNotify("单位工程不存在或不属于当前项目!", MessageBoxIcon.Warning); + return; + } + + lblUnitWork.Text = unitWork.UnitWorkCode + " " + unitWork.UnitWorkName; + BindGrid(); + } + } + + protected void btnDownLoad_Click(object sender, EventArgs e) + { + string templatePath = Server.MapPath("~/" + Const.NDTBatchUnitImportTemplateUrl.Replace("\\", "/")); + if (!File.Exists(templatePath)) + { + ShowNotify("检测结果导入模板不存在,请联系管理员!", MessageBoxIcon.Error); + return; + } + + FileInfo info = new FileInfo(templatePath); + Response.ClearContent(); + Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("检测结果导入模板.xlsx", System.Text.Encoding.UTF8)); + Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + Response.ContentEncoding = System.Text.Encoding.UTF8; + Response.AddHeader("Content-Length", info.Length.ToString()); + Response.TransmitFile(templatePath, 0, info.Length); + Response.Flush(); + Response.Close(); + } + + protected void btnAudit_Click(object sender, EventArgs e) + { + if (!fuAttachUrl.HasFile) + { + ShowNotify("请选择要导入的 Excel 文件!", MessageBoxIcon.Warning); + return; + } + + string extension = Path.GetExtension(fuAttachUrl.FileName).ToLowerInvariant(); + if (extension != ".xlsx") + { + ShowNotify("只能导入 .xlsx 文件!", MessageBoxIcon.Warning); + return; + } + + string rootPath = Server.MapPath("~/"); + string uploadDirectory = Path.Combine(rootPath, Const.ExcelUrl); + if (!Directory.Exists(uploadDirectory)) + { + Directory.CreateDirectory(uploadDirectory); + } + + string filePath = Path.Combine(uploadDirectory, Funs.GetNewFileName() + extension); + try + { + fuAttachUrl.PostedFile.SaveAs(filePath); + DataTable table = MiniExcel.QueryAsDataTable(filePath, useHeaderRow: true); + List errors; + List importItems = ParseImportItems(table, out errors); + if (errors.Count > 0) + { + ImportItems = new List(); + BindGrid(); + ShowErrors(errors); + return; + } + + ImportItems = importItems; + BindGrid(); + ShowNotify("审核完成,共 " + importItems.Count + " 条,请确认后提交导入!", MessageBoxIcon.Success); + } + catch (Exception ex) + { + ImportItems = new List(); + BindGrid(); + ShowNotify("读取导入文件失败:" + ex.Message, MessageBoxIcon.Error); + } + finally + { + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + } + } + + protected void btnSave_Click(object sender, EventArgs e) + { + if (!CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, CurrUser.PersonId, Const.HJGL_NDTBatchMenuId, Const.BtnSave)) + { + ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); + return; + } + + List importItems = ImportItems; + if (importItems.Count == 0) + { + ShowNotify("请先审核要导入的文件!", MessageBoxIcon.Warning); + return; + } + + try + { + Batch_NDEImportService.Import(CurrUser.LoginProjectId, UnitWorkId, CurrUser.PersonId, importItems); + Session.Remove(ImportCacheKey); + ShowNotify("成功导入 " + importItems.Count + " 条检测结果!", MessageBoxIcon.Success); + PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); + } + catch (Exception ex) + { + ShowNotify("导入失败:" + ex.Message, MessageBoxIcon.Error); + } + } + + protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) + { + Grid1.PageIndex = e.NewPageIndex; + BindGrid(); + } + + private List ParseImportItems(DataTable table, out List errors) + { + errors = new List(); + List result = new List(); + if (table == null || table.Rows.Count == 0) + { + errors.Add("导入数据为空!"); + return result; + } + + List missingColumns = TemplateColumns.Where(x => !table.Columns.Contains(x)).ToList(); + if (missingColumns.Count > 0) + { + errors.Add("导入 Excel 格式错误,缺少列:" + string.Join("、", missingColumns)); + return result; + } + + List trustItems = GetUnitWorkTrustItems(); + Dictionary trustMap = Funs.DB.View_Batch_BatchTrust + .Where(x => x.ProjectId == CurrUser.LoginProjectId && x.UnitWorkId == UnitWorkId) + .ToList() + .Where(IsCurrentNDTType) + .GroupBy(x => Normalize(x.TrustBatchCode)) + .ToDictionary(x => x.Key, x => x.First()); + HashSet importedTrustBatchIds = new HashSet(Funs.DB.HJGL_Batch_NDE + .Where(x => x.ProjectId == CurrUser.LoginProjectId && x.UnitWorkId == UnitWorkId) + .Select(x => x.TrustBatchId) + .ToList()); + Dictionary defectMap = Funs.DB.Base_Defect + .ToList() + .GroupBy(x => Normalize(x.DefectName)) + .ToDictionary(x => x.Key, x => x.First()); + HashSet rowKeys = new HashSet(StringComparer.OrdinalIgnoreCase); + + for (int index = 0; index < table.Rows.Count; index++) + { + DataRow row = table.Rows[index]; + int excelRowNumber = index + 2; + string trustBatchCode = GetCellValue(row, "委托编号"); + string pipelineCode = GetCellValue(row, "管线号"); + string weldJointCode = GetCellValue(row, "检件焊口号"); + string totalFilmText = GetCellValue(row, "检测总数"); + string passFilmText = GetCellValue(row, "合格数"); + string filmDateText = GetCellValue(row, "检测日期"); + string reportDateText = GetCellValue(row, "报告日期"); + + if (string.IsNullOrEmpty(trustBatchCode) + && string.IsNullOrEmpty(pipelineCode) + && string.IsNullOrEmpty(weldJointCode) + && string.IsNullOrEmpty(totalFilmText) + && string.IsNullOrEmpty(passFilmText) + && string.IsNullOrEmpty(filmDateText) + && string.IsNullOrEmpty(reportDateText)) + { + continue; + } + + int errorCount = errors.Count; + int sequence = index + 1; + string sequenceText = GetCellValue(row, "序号"); + if (!string.IsNullOrEmpty(sequenceText) + && (!int.TryParse(sequenceText, out sequence) || sequence <= 0)) + { + errors.Add("第" + excelRowNumber + "行:序号必须为大于 0 的整数"); + } + + View_Batch_BatchTrust trust = null; + if (string.IsNullOrEmpty(trustBatchCode) || !trustMap.TryGetValue(Normalize(trustBatchCode), out trust)) + { + errors.Add("第" + excelRowNumber + "行:委托编号[" + trustBatchCode + "]不属于当前单位工程"); + } + else if (importedTrustBatchIds.Contains(trust.TrustBatchId)) + { + errors.Add("第" + excelRowNumber + "行:委托编号[" + trustBatchCode + "]已存在检测结果,不能重复导入"); + } + + View_Batch_BatchTrustItem trustItem = null; + if (trust != null) + { + trustItem = trustItems.FirstOrDefault(x => + x.TrustBatchId == trust.TrustBatchId + && Normalize(x.PipelineCode) == Normalize(pipelineCode) + && Normalize(x.WeldJointCode) == Normalize(weldJointCode)); + if (trustItem == null) + { + errors.Add("第" + excelRowNumber + "行:管线[" + pipelineCode + "]焊口[" + weldJointCode + "]不存在于该委托单"); + } + } + + string welderCode = GetCellValue(row, "焊工号"); + if (trustItem != null && !string.IsNullOrEmpty(welderCode) + && Normalize(trustItem.WelderCode) != Normalize(welderCode)) + { + errors.Add("第" + excelRowNumber + "行:焊工号[" + welderCode + "]与委托明细不一致"); + } + + int totalFilm; + if (!int.TryParse(totalFilmText, out totalFilm) || totalFilm <= 0) + { + errors.Add("第" + excelRowNumber + "行:检测总数必须为大于 0 的整数"); + } + + int passFilm; + if (!int.TryParse(passFilmText, out passFilm) || passFilm < 0) + { + errors.Add("第" + excelRowNumber + "行:合格数必须为不小于 0 的整数"); + } + else if (totalFilm > 0 && passFilm > totalFilm) + { + errors.Add("第" + excelRowNumber + "行:合格数不能大于检测总数"); + } + + string checkResultText = GetCellValue(row, "是否合格"); + string checkResult = ConvertCheckResult(checkResultText); + if (string.IsNullOrEmpty(checkResult)) + { + errors.Add("第" + excelRowNumber + "行:是否合格只能填写“合格”或“不合格”"); + } + + string judgeGrade = ConvertJudgeGrade(GetCellValue(row, "评定级别")); + if (judgeGrade == null) + { + errors.Add("第" + excelRowNumber + "行:评定级别只能填写Ⅰ、Ⅱ、Ⅲ、Ⅳ、Ⅴ或1-5"); + } + + string defectText = GetCellValue(row, "缺陷"); + List defectIds = new List(); + if (!string.IsNullOrEmpty(defectText)) + { + foreach (string defectName in SplitDefects(defectText)) + { + Base_Defect defect; + if (!defectMap.TryGetValue(Normalize(defectName), out defect)) + { + errors.Add("第" + excelRowNumber + "行:缺陷[" + defectName + "]不存在"); + } + else + { + defectIds.Add(Convert.ToString(defect.DefectId)); + } + } + } + + string rowKey = Normalize(trustBatchCode) + "|" + Normalize(pipelineCode) + "|" + Normalize(weldJointCode); + if (!rowKeys.Add(rowKey)) + { + errors.Add("第" + excelRowNumber + "行:同一委托、管线和焊口在文件中重复"); + } + + // 两个日期均为非必填列;兼容 Excel 日期单元格、序列值和常见日期文本。 + DateTime? filmDate = ParseOptionalDate(row, "检测日期", excelRowNumber, errors); + DateTime? reportDate = ParseOptionalDate(row, "报告日期", excelRowNumber, errors); + + if (errors.Count == errorCount && trust != null && trustItem != null) + { + result.Add(new UnitWorkNDEImportItem + { + RowNumber = sequence, + TrustBatchId = trust.TrustBatchId, + TrustBatchCode = trust.TrustBatchCode, + TrustBatchItemId = trustItem.TrustBatchItemId, + PipelineCode = trustItem.PipelineCode, + WeldJointCode = trustItem.WeldJointCode, + WelderCode = trustItem.WelderCode, + TotalFilm = totalFilm, + PassFilm = passFilm, + CheckResult = checkResult, + CheckResultText = checkResultText == "是" ? "合格" : checkResultText == "否" ? "不合格" : checkResultText, + JudgeGrade = judgeGrade, + CheckDefects = string.Join(",", defectIds.Distinct()), + CheckDefectsText = defectText, + RepairLocation = GetCellValue(row, "返修位置"), + Remark = GetCellValue(row, "备注"), + FilmDate = filmDate, + ReportDate = reportDate + }); + } + } + + if (result.Count == 0 && errors.Count == 0) + { + errors.Add("导入数据为空!"); + } + return result; + } + + private List GetUnitWorkTrustItems() + { + return Funs.DB.View_Batch_BatchTrustItem + .Where(x => x.ProjectId == CurrUser.LoginProjectId && x.UnitWorkId == UnitWorkId && x.PipelineCode !=null) + .ToList() + .Where(IsCurrentNDTType) + .ToList(); + } + + private bool IsCurrentNDTType(View_Batch_BatchTrustItem item) + { + return NDTType == "R" ? item.TrustType == "R" : string.IsNullOrEmpty(item.TrustType); + } + + private bool IsCurrentNDTType(View_Batch_BatchTrust item) + { + return NDTType == "R" ? item.TrustType == "R" : string.IsNullOrEmpty(item.TrustType); + } + + private void BindGrid() + { + List items = ImportItems; + Grid1.RecordCount = items.Count; + Grid1.DataSource = items.Skip(Grid1.PageIndex * Grid1.PageSize).Take(Grid1.PageSize).ToList(); + Grid1.DataBind(); + } + + private void ShowErrors(IEnumerable errors) + { + Alert alert = new Alert + { + Message = string.Join("
", errors.Distinct().Select(HttpUtility.HtmlEncode)), + Target = Target.Self + }; + alert.Show(); + } + + private static string GetCellValue(DataRow row, string columnName) + { + return Convert.ToString(row[columnName]).Replace("\n", "").Replace("\t", "").Replace("\r", "").Trim(); + } + + private static DateTime? ParseOptionalDate(DataRow row, string columnName, int excelRowNumber, ICollection errors) + { + object rawValue = row[columnName]; + string value = Convert.ToString(rawValue).Trim(); + if (rawValue == null || rawValue == DBNull.Value || string.IsNullOrEmpty(value)) + { + return null; + } + + if (rawValue is DateTime) + { + return ((DateTime)rawValue).Date; + } + + double oaDate; + if (double.TryParse(value, out oaDate)) + { + try + { + return DateTime.FromOADate(oaDate).Date; + } + catch (ArgumentException) + { + // 无效序列值继续按日期文本处理,最终给出统一提示。 + } + } + + DateTime date; + if (DateTime.TryParse(value, out date)) + { + return date.Date; + } + + errors.Add("第" + excelRowNumber + "行:" + columnName + "格式错误,应填写有效日期"); + return null; + } + + private static string Normalize(string value) + { + return (value ?? string.Empty).Replace(" ", string.Empty).Trim().ToUpperInvariant(); + } + + private static string ConvertCheckResult(string value) + { + if (value == "合格" || value == "是") + { + return "1"; + } + if (value == "不合格" || value == "否") + { + return "2"; + } + return string.Empty; + } + + private static string ConvertJudgeGrade(string value) + { + switch (value) + { + case "": return string.Empty; + case "Ⅰ": + case "1": return "Ⅰ"; + case "Ⅱ": + case "2": return "Ⅱ"; + case "Ⅲ": + case "3": return "Ⅲ"; + case "Ⅳ": + case "4": return "Ⅳ"; + case "Ⅴ": + case "5": return "Ⅴ"; + default: return null; + } + } + + private static IEnumerable SplitDefects(string value) + { + return value.Split(new[] { ',', ',', '、', ';', ';' }, StringSplitOptions.RemoveEmptyEntries) + .Select(x => x.Trim()) + .Where(x => !string.IsNullOrEmpty(x)); + } + } +} diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.designer.cs new file mode 100644 index 00000000..f9c26614 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatchUnitImport.aspx.designer.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.HJGL.NDT +{ + public partial class NDTBatchUnitImport + { + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + protected global::FineUIPro.PageManager PageManager1; + protected global::FineUIPro.Form SimpleForm1; + protected global::FineUIPro.Toolbar Toolbar1; + protected global::FineUIPro.Label lblUnitWork; + protected global::FineUIPro.Button btnDownLoad; + protected global::FineUIPro.Toolbar Toolbar2; + protected global::FineUIPro.FileUpload fuAttachUrl; + protected global::FineUIPro.Button btnAudit; + protected global::FineUIPro.Button btnSave; + protected global::FineUIPro.Grid Grid1; + } +} diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldAppearanceCheck.aspx b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldAppearanceCheck.aspx index 6dd35924..b713ea3b 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldAppearanceCheck.aspx +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldAppearanceCheck.aspx @@ -28,6 +28,11 @@ + + + + +