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 00000000..69ddd851
Binary files /dev/null and b/SGGL/FineUIPro.Web/File/Excel/DataIn/检测结果导入模板.xlsx differ
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 5b440e5a..160acddc 100644
--- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
+++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj
@@ -1626,6 +1626,7 @@
+
@@ -3660,6 +3661,7 @@
+
@@ -3705,6 +3707,7 @@
+
@@ -10934,6 +10937,13 @@
NDTBatchImport.aspx
+
+ NDTBatchUnitImport.aspx
+ ASPXCodeBehind
+
+
+ NDTBatchUnitImport.aspx
+
RepairNotice.aspx
ASPXCodeBehind
@@ -17350,4 +17360,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 @@
+
+
+
+
+
+