diff --git a/DataBase/版本日志/SGGLDB_V2026-07-13-lpf.sql b/DataBase/版本日志/SGGLDB_V2026-07-13-lpf.sql index e90c52f3..d08c4b9e 100644 --- a/DataBase/版本日志/SGGLDB_V2026-07-13-lpf.sql +++ b/DataBase/版本日志/SGGLDB_V2026-07-13-lpf.sql @@ -33,7 +33,7 @@ GO -- 创建 HJGL_DrawingRecognition_PipeLengths 表 CREATE TABLE HJGL_DrawingRecognition_PipeLengths ( id NVARCHAR(50) NOT NULL, -- 记录ID - pipe_no INT NULL, -- 管线号 + pipe_no NVARCHAR(200) NULL, -- 管线号 pipe_page_no INT NULL, -- 管线号页码 group_index INT NULL, -- 组索引 pos_no NVARCHAR(50) NULL, -- 位置编号(如 "<1>") diff --git a/DataBase/版本日志/SGGLDB_V2026-07-14-lpf.sql b/DataBase/版本日志/SGGLDB_V2026-07-14-lpf.sql new file mode 100644 index 00000000..d3ac31e0 --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2026-07-14-lpf.sql @@ -0,0 +1,6 @@ +INSERT INTO Sys_Menu (MenuId,MenuName,Icon,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) +VALUES (N'E642C8A1-5D56-4A0C-89E2-304E0421D281',N'管道材料信息总览',NULL,N'HJGL/InfoQuery/MaterialOverview.aspx',30,N'43F92EA7-462F-41E6-8D8A-243C03A5317E',N'Menu_HJGL',0,1,1); +GO +INSERT INTO Sys_Menu (MenuId,MenuName,Icon,Url,SortIndex,SuperMenu,MenuType,IsOffice,IsEnd,IsUsed) +VALUES (N'B5DD3FA8-28F9-49F4-AF3E-9916A65A1C7F',N'管长信息总览',NULL,N'HJGL/InfoQuery/PipeLengthOverview.aspx',40,N'43F92EA7-462F-41E6-8D8A-243C03A5317E',N'Menu_HJGL',0,1,1); +GO \ No newline at end of file diff --git a/DataBase/版本日志/SGGLDB_V2026-07-16-lpf.sql b/DataBase/版本日志/SGGLDB_V2026-07-16-lpf.sql new file mode 100644 index 00000000..72bc9537 --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2026-07-16-lpf.sql @@ -0,0 +1,12 @@ +update Sys_Menu set SortIndex='10' where MenuId='ADC7EA61-6313-4DF9-913F-E9207F6525CA' +update Sys_Menu set SortIndex='20' where MenuId='164E056C-30C9-4C29-A6B6-AF0F0C943A59' +update Sys_Menu set SortIndex='30' where MenuId='C1EACB23-A029-4DE7-886D-7772D9DDE735' +update Sys_Menu set SortIndex='40' where MenuId='6ce0b6bc-aa4d-4f0d-9f1f-75a553810793' +update Sys_Menu set SuperMenu='4D36E99E-B3D8-4C61-826A-CBD98EC51515', SortIndex='50' where MenuId='D1B5A8B7-5D2A-4C51-9B7E-6A2F15B7F002' +update Sys_Menu set SuperMenu='4D36E99E-B3D8-4C61-826A-CBD98EC51515', SortIndex='60' where MenuId='D1B5A8B7-5D2A-4C51-9B7E-6A2F15B7F003' +update Sys_Menu set SortIndex='70' where MenuId='5TYHMD2F-2582-4DEB-905E-6E9DCFEFBGHO' +update Sys_Menu set IsUsed=0 where MenuId='E6F6982A-48C7-455C-8EBB-CC7088EBF15A' +update Sys_Menu set IsUsed=0 where MenuId='D1B5A8B7-5D2A-4C51-9B7E-6A2F15B7F001' +update Sys_Menu set IsUsed=0 where MenuId='53948077-B51D-4FF3-BFB0-AB4E27C42875' +update Sys_Menu set IsUsed=0 where MenuId='EFD1E914-E79C-4F5E-A2F7-CFF4F7821284' +update Sys_Menu set SortIndex='130' where MenuId='43F92EA7-462F-41E6-8D8A-243C03A5317E' \ No newline at end of file diff --git a/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs b/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs index 5a6f49f5..1972854d 100644 --- a/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs +++ b/SGGL/BLL/HJGL/BaseInfo/MaterialCodeLibService.cs @@ -147,6 +147,60 @@ db.SubmitChanges(); } } + + public static void AddListByDraw(List list) + { + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + // 图纸材料编码同时作为材料库主键和业务编码,不能为空且同批次只允许新增一次。 + var existingMaterials = db.HJGL_MaterialCodeLib + .Select(x => new { x.MaterialCode, x.Code }) + .ToList(); + var materialCodes = new HashSet(System.StringComparer.OrdinalIgnoreCase); + foreach (var existingMaterial in existingMaterials) + { + if (!string.IsNullOrWhiteSpace(existingMaterial.MaterialCode)) + { + materialCodes.Add(existingMaterial.MaterialCode); + } + if (!string.IsNullOrWhiteSpace(existingMaterial.Code)) + { + materialCodes.Add(existingMaterial.Code); + } + } + List details = new List(); + foreach (var item in list) + { + if (item == null || string.IsNullOrWhiteSpace(item.MaterialCode)) + { + continue; + } + + string materialCode = item.MaterialCode.Trim(); + if (!materialCodes.Add(materialCode)) + { + continue; + } + + Model.HJGL_MaterialCodeLib table = new Model.HJGL_MaterialCodeLib + { + MaterialCode = materialCode, + MaterialName = item.MaterialName, + MaterialSpec = item.MaterialSpec, + MaterialUnit = item.MaterialUnit, + MaterialDef = item.MaterialDef, + Code = materialCode + }; + details.Add(table); + } + + if (details.Count > 0) + { + db.HJGL_MaterialCodeLib.InsertAllOnSubmit(details); + db.SubmitChanges(); + } + } + } } public class MaterialCodeLibDtoIn diff --git a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs index a1357456..d9454e8e 100644 --- a/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/InPlanMaster.aspx.cs @@ -170,12 +170,7 @@ namespace FineUIPro.Web.CLGL foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); - var model = BLL.TwInOutplanmasterService.GetById(rowID); - if (!string.IsNullOrEmpty(model.TransferBatchId)) - { - Alert.ShowInTop("已提交的调拨申请不允许单独删除!", MessageBoxIcon.Warning); - return; - } + var model = BLL.TwInOutplanmasterService.GetById(rowID); if (model.State == (int)TwConst.State.已审核 || model.State == (int)TwConst.State.已完成) { Alert.ShowInTop("请选择有效的计划!", MessageBoxIcon.Warning); diff --git a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs index cd6f5a62..f7e5be7d 100644 --- a/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs +++ b/SGGL/FineUIPro.Web/CLGL/OutPlanMaster.aspx.cs @@ -443,12 +443,7 @@ namespace FineUIPro.Web.CLGL foreach (int rowIndex in Grid1.SelectedRowIndexArray) { string rowID = Grid1.DataKeys[rowIndex][0].ToString(); - var model = BLL.TwInOutplanmasterService.GetById(rowID); - if (!string.IsNullOrEmpty(model.TransferBatchId) && model.State != (int)TwConst.State.待提交) - { - Alert.ShowInTop("已提交的调拨申请不允许单独删除!", MessageBoxIcon.Warning); - return; - } + var model = BLL.TwInOutplanmasterService.GetById(rowID); if (model.State == (int)TwConst.State.已审核 || model.State == (int)TwConst.State.已完成) { Alert.ShowInTop("请选择有效的计划!", MessageBoxIcon.Warning); diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index fcc4dd55..66a80cd3 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -1572,12 +1572,25 @@ + + + + + + + + + + + + + @@ -1601,6 +1614,8 @@ + + @@ -3689,6 +3704,175 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -10744,6 +10928,20 @@ JointQuery.aspx + + MaterialOverview.aspx + ASPXCodeBehind + + + MaterialOverview.aspx + + + PipeLengthOverview.aspx + ASPXCodeBehind + + + PipeLengthOverview.aspx + JointQueryChart.aspx ASPXCodeBehind diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx index 96a507e6..c8a3e19b 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx @@ -4,85 +4,115 @@ - - + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <title> - - - - + +
- - + + - - + + - - - - - - - -
-
-
- - - - + + diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.cs index 712641d3..1546289a 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.cs @@ -2,16 +2,14 @@ using BLL; using BLL.Common; using Model; -using Newtonsoft.Json.Linq; -using NPOI.SS.Formula.Functions; +using Newtonsoft.Json; using System; using System.Collections.Generic; -using System.Data; using System.IO; using System.Linq; using System.Net; using System.Text; -using System.Text.RegularExpressions; +using System.Transactions; using UglyToad.PdfPig; using UglyToad.PdfPig.Content; using UglyToad.PdfPig.Writer; @@ -20,6 +18,9 @@ namespace FineUIPro.Web.HJGL.DataIn { public partial class DrawingRecognitionContent : PageBase { + internal const string MaterialSessionSuffix = ":DrawingRecognitionMaterials"; + internal const string PipeLengthSessionSuffix = ":DrawingRecognitionPipeLengths"; + public string URL { get @@ -42,44 +43,64 @@ namespace FineUIPro.Web.HJGL.DataIn ViewState["fileUrl"] = value; } } - public DataTable dt + private string RecognitionDataKey { get { - return (DataTable)ViewState["DataTable"]; + return (string)ViewState["RecognitionDataKey"]; } set { - ViewState["DataTable"] = value; + ViewState["RecognitionDataKey"] = value; } } - public DataTable dtOther + + private string MaterialSessionKey { get { - return (DataTable)ViewState["dtOther"]; - } - set - { - ViewState["dtOther"] = value; + return RecognitionDataKey + MaterialSessionSuffix; } } - public DataTable dtIsoInfo + + private string PipeLengthSessionKey { get { - return (DataTable)ViewState["dtIsoInfo"]; + return RecognitionDataKey + PipeLengthSessionSuffix; + } + } + + private List MaterialEntities + { + get + { + return Session[MaterialSessionKey] as List; } set { - ViewState["dtIsoInfo"] = value; + Session[MaterialSessionKey] = value; } } - + + private List PipeLengthEntities + { + get + { + return Session[PipeLengthSessionKey] as List; + } + set + { + Session[PipeLengthSessionKey] = value; + } + } + protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { + UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true); + RecognitionDataKey = Guid.NewGuid().ToString("N"); if (!string.IsNullOrEmpty(Request.Params["fileUrl"])) { URL = Funs.SGGLUrl + Request.Params["fileUrl"].Replace("\\", "/"); @@ -99,18 +120,49 @@ namespace FineUIPro.Web.HJGL.DataIn protected void btnSave_Click(object sender, EventArgs e) { - Grid1.Hidden = true; - contentPanel1.Hidden =false ; - string rootPath = Server.MapPath("~/"); - Dictionary> dic= new Dictionary>(); - foreach (DataRow row in dt.Rows) + DrawingRecognitionResult recognitionResult; + List materialEntities; + List pipeLengthEntities; + Dictionary pipelinesByCode; + if(drpUnitWork.SelectedValue == null|| drpUnitWork.SelectedValue==Const._Null) { - if (!dic.ContainsKey(row["pipe_no"].ToString())) - { - dic.Add(row["pipe_no"].ToString().Trim(),new List()); - } - dic[row["pipe_no"].ToString().Trim()].Add(int.Parse(row["page_no"].ToString())); + Alert.ShowInTop("请选择单位工程", MessageBoxIcon.Warning); + return; } + + try + { + recognitionResult = DeserializeRecognitionResult(); + materialEntities = MaterialEntities; + pipeLengthEntities = PipeLengthEntities; + if (materialEntities == null || pipeLengthEntities == null) + { + throw new InvalidOperationException("实体数据已失效,请重新审核识别结果"); + } + + // DrawingInfo 以原始页码关联 C3 管线号,并同步当前项目的管线基础信息。 + pipelinesByCode = UpsertPipelinesFromDrawingInfo(recognitionResult); + Funs.DB.SubmitChanges(); + } + catch (Exception ex) + { + Alert.ShowInTop("识别数据校验或管线保存失败:" + ex.Message, MessageBoxIcon.Warning); + return; + } + + Grid1.Hidden = true; + Grid2.Hidden = true; + contentPanel1.Hidden = false; + string rootPath = Server.MapPath("~/"); + // PDF 原始页与管线号的关系来自 C3,实体中的 pipe_page_no 保存的是 C1,不能替代原始页码。 + Dictionary> dic = recognitionResult.OtherRegions + .Where(x => x.Page.HasValue && string.Equals(x.RegionCode, "C3", StringComparison.OrdinalIgnoreCase) + && !string.IsNullOrWhiteSpace(x.Text)) + .GroupBy(x => x.Text.Trim(), StringComparer.OrdinalIgnoreCase) + .ToDictionary( + group => group.Key, + group => group.Select(x => x.Page.Value).Distinct().ToList(), + StringComparer.OrdinalIgnoreCase); using (var pdf = PdfDocument.Open(fileUrl)) { @@ -133,17 +185,23 @@ namespace FineUIPro.Web.HJGL.DataIn } string fileName = key; - var row = dtOther.Select(" page='" + (i + 1) + "' and region_type='C' ").FirstOrDefault(); - if (row != null) + var pipePageRegion = recognitionResult.OtherRegions.FirstOrDefault(x => + x.Page == i + 1 && string.Equals(x.RegionCode, "C1", StringComparison.OrdinalIgnoreCase)); + if (pipePageRegion != null) { - if (!string.IsNullOrEmpty(row["text"].ToString())) + if (!string.IsNullOrWhiteSpace(pipePageRegion.Text)) { - fileName = row["text"].ToString(); + fileName = pipePageRegion.Text.Trim(); } } outputPath = $"{outputPath}/" + fileName + DateTime.Now.ToString("yyyyMMddHHmm")+(i + 1) + ".pdf"; } - } + } + + if (string.IsNullOrEmpty(outputPath)) + { + continue; + } using (var writer = new PdfDocumentBuilder()) { @@ -164,82 +222,8 @@ namespace FineUIPro.Web.HJGL.DataIn var newPdf = writer.Build(); File.WriteAllBytes(outputPath, newPdf); - var isoInfo = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineCode == isono && x.ProjectId==CurrUser.LoginProjectId); - if (isoInfo != null) + if (pipelinesByCode.TryGetValue(isono, out var isoInfo)) { - Regex NumberRegex = new Regex(@"\d+\.?\d*"); - DataRow[] rows = dt.Select(" pipe_no='" + isono + "' and category='PIPE'"); - if (rows != null && rows.Length > 0) - { - //string description = rows[0]["description"].ToString(); - - //if (!isoInfo.ISO_Dia.HasValue || !isoInfo.ISO_Sch.HasValue || string.IsNullOrEmpty(isoInfo.MaterialStandardId)) - //{ - // string res = OpenAIhelper.ChatCompletion("请根据 " + description + ",识别外径,壁厚,材质标准(请严格按照国家标准返回),结果仅以JSON格式返回,不要解释,不要多余文字,不要markdown,例如 {\r\n \"外径\": \"33.4 mm\",\r\n \"壁厚\": \"6.35 mm\",\r\n \"材质标准\": \"GB/T 9948\"\r\n}"); - // ErrLogInfo.WriteLog(res); - // JObject jobject = JObject.Parse(res); - // string dia = jobject.Value("外径"); - // string sch = jobject.Value("壁厚"); - // string materialStandard = jobject.Value("材质标准"); - // MatchCollection matchCollection1 = NumberRegex.Matches(dia); - // foreach (var match in matchCollection1) - // { - // // 使用 TryParse 确保转换安全,避免异常 - // if (decimal.TryParse(match.ToString(), out decimal number)) - // { - // isoInfo.ISO_Dia = number; - // } - // } - - // MatchCollection matchCollection2 = NumberRegex.Matches(sch); - // foreach (var match in matchCollection2) - // { - // // 使用 TryParse 确保转换安全,避免异常 - // if (decimal.TryParse(match.ToString(), out decimal number)) - // { - // isoInfo.ISO_Sch = number; - // } - // } - - // isoInfo.MaterialStandardId = Funs.DB.HJGL_BS_MaterialStandard.Where(x => x.MaterialStandardCode == materialStandard).Select(x => x.MaterialStandardId).FirstOrDefault(); - //} - - - //decimal length = 0; - //foreach (DataRow row in rows) - //{ - - // MatchCollection matches = NumberRegex.Matches(row["qty"].ToString()); - // foreach (var match in matches) - // { - // // 使用 TryParse 确保转换安全,避免异常 - // if (decimal.TryParse(match.ToString(), out decimal number)) - // { - // length += number; - // } - // } - //} - - //isoInfo.PipeLineLength = length; - - } - //DataRow[] rowsPipe = dtIsoInfo.Select(" pipeline_id='" + isono + "' "); - //if (rowsPipe != null && rowsPipe.Length > 0) - //{ - // string isNeedHead = rowsPipe[0]["post_weld_heat_treatment"].ToString(); - // if (isNeedHead == "N") - // { - // isoInfo.IsHot = "0"; - // isoInfo.IsHotType = null; - // } - // else - // { - // isoInfo.IsHot = "1"; - // } - - - //} - Funs.DB.SubmitChanges(); //保存文件到附件 var attatch = AttachFileService.GetAttachFileByToKeyId(isoInfo.PipelineId); if (attatch != null) @@ -257,7 +241,91 @@ namespace FineUIPro.Web.HJGL.DataIn } } - + ReplaceRecognitionDetails(materialEntities, pipeLengthEntities); + + List tw_InputDataIns = new List(); + + foreach (var item in materialEntities) + { + var model = new Tw_InputDataIn() + { + MaterialCode = item.Code, + MaterialUnit = item.Unit!=null? item.Unit.Contains("M") ? "米" : "个":null, + MaterialDef = item.Description, + MaterialSpec = item.Spec, + }; + if(!tw_InputDataIns.Contains(model)) tw_InputDataIns.Add(model); + + } + MaterialCodeLibService.AddListByDraw(tw_InputDataIns); + Session.Remove(MaterialSessionKey); + Session.Remove(PipeLengthSessionKey); + btnSave.Hidden = true; + ShowNotify("管线、材料表和管段长度表保存成功!", MessageBoxIcon.Success); + } + + /// + /// 按管线号和管线页码替换本次识别范围内的材料及管长数据。 + /// + private static void ReplaceRecognitionDetails( + List materialEntities, + List pipeLengthEntities) + { + var recognitionPages = materialEntities + .Select(x => new { PipeNo = x.Pipe_no, PipePageNo = x.Pipe_page_no }) + .Concat(pipeLengthEntities.Select(x => new { PipeNo = x.Pipe_no, PipePageNo = x.Pipe_page_no })) + .ToList(); + if (recognitionPages.Any(x => string.IsNullOrWhiteSpace(x.PipeNo) || !x.PipePageNo.HasValue)) + { + throw new InvalidOperationException("材料或管长数据存在缺少管线号、管线页码的记录"); + } + if (recognitionPages.Count == 0) + { + return; + } + + // 两类识别结果共用替换范围,确保某页本次未识别到其中一类数据时也能清理旧记录。 + var pageNumbersByPipeNo = recognitionPages + .GroupBy(x => x.PipeNo.Trim(), StringComparer.OrdinalIgnoreCase) + .ToDictionary( + group => group.Key, + group => new HashSet(group.Select(x => x.PipePageNo.Value)), + StringComparer.OrdinalIgnoreCase); + var pipeNumbers = pageNumbersByPipeNo.Keys.ToList(); + + var oldMaterials = Funs.DB.HJGL_DrawingRecognition_Material + .Where(x => pipeNumbers.Contains(x.Pipe_no)) + .ToList() + .Where(x => IsRecognitionPage(pageNumbersByPipeNo, x.Pipe_no, x.Pipe_page_no)) + .ToList(); + var oldPipeLengths = Funs.DB.HJGL_DrawingRecognition_PipeLengths + .Where(x => pipeNumbers.Contains(x.Pipe_no)) + .ToList() + .Where(x => IsRecognitionPage(pageNumbersByPipeNo, x.Pipe_no, x.Pipe_page_no)) + .ToList(); + + using (var scope = new TransactionScope()) + { + Funs.DB.HJGL_DrawingRecognition_Material.DeleteAllOnSubmit(oldMaterials); + Funs.DB.HJGL_DrawingRecognition_PipeLengths.DeleteAllOnSubmit(oldPipeLengths); + Funs.DB.SubmitChanges(); + + Funs.DB.HJGL_DrawingRecognition_Material.InsertAllOnSubmit(materialEntities); + Funs.DB.HJGL_DrawingRecognition_PipeLengths.InsertAllOnSubmit(pipeLengthEntities); + Funs.DB.SubmitChanges(); + scope.Complete(); + } + } + + private static bool IsRecognitionPage( + Dictionary> pageNumbersByPipeNo, + string pipeNo, + int? pipePageNo) + { + return !string.IsNullOrWhiteSpace(pipeNo) && + pipePageNo.HasValue && + pageNumbersByPipeNo.TryGetValue(pipeNo.Trim(), out var pageNumbers) && + pageNumbers.Contains(pipePageNo.Value); } public static string HeaderCorrespondence(string uploadUrl, string data, string method, string contenttype) { @@ -320,129 +388,394 @@ namespace FineUIPro.Web.HJGL.DataIn protected void btnAudit_Click(object sender, EventArgs e) { - Grid1.Hidden = false; - contentPanel1.Hidden = true; - btnAudit.Hidden = true; - btnSave.Hidden = false; if (!string.IsNullOrEmpty(resultdata.Value)) { - JObject jobject = JObject.Parse(resultdata.Value); - JArray jArray = jobject.Value("material_rows"); - JArray jArrayOther = jobject.Value("other_regions"); - JArray jArrayIsoInfo = jobject.Value("drawing_info"); - dt = new DataTable(); - dt.Columns.Add("id"); - dt.Columns.Add("pipe_no"); - dt.Columns.Add("drawing_number"); - dt.Columns.Add("seq_no"); - dt.Columns.Add("category"); - dt.Columns.Add("description"); - dt.Columns.Add("spec"); - dt.Columns.Add("qty"); - dt.Columns.Add("code"); - dt.Columns.Add("page_no"); - dt.Columns.Add("remark"); - - dtOther = new DataTable(); - dtOther.Columns.Add("id"); - dtOther.Columns.Add("region_type"); - dtOther.Columns.Add("region_label"); - dtOther.Columns.Add("page"); - dtOther.Columns.Add("text"); - - - dtIsoInfo = new DataTable(); - dtIsoInfo.Columns.Add("id"); - dtIsoInfo.Columns.Add("page_no"); - dtIsoInfo.Columns.Add("drawing_number"); - dtIsoInfo.Columns.Add("pipeline_id"); - dtIsoInfo.Columns.Add("operation_pressure_mpa"); - dtIsoInfo.Columns.Add("operation_temp_c"); - dtIsoInfo.Columns.Add("design_pressure_mpa"); - dtIsoInfo.Columns.Add("design_temp_c"); - dtIsoInfo.Columns.Add("test_pressure_mpa"); - dtIsoInfo.Columns.Add("hydraulic_test_pressure"); - dtIsoInfo.Columns.Add("pipe_diameter_dn"); - dtIsoInfo.Columns.Add("pipe_spec_grade"); - dtIsoInfo.Columns.Add("heat_insulation"); - dtIsoInfo.Columns.Add("insulation_thickness_mm"); - dtIsoInfo.Columns.Add("post_weld_heat_treatment"); - dtIsoInfo.Columns.Add("radiographic_examination"); - foreach (JObject item in jArrayOther) + try { - var row = dtOther.NewRow(); - row["id"] = item.Value("id"); - row["region_type"] = item.Value("region_type"); - row["region_label"] = item.Value("region_label"); - row["page"] = item.Value("page"); - row["text"] = item.Value("text"); - dtOther.Rows.Add(row); + var recognitionResult = DeserializeRecognitionResult(); + var pageRegions = BuildPageRegionMap(recognitionResult.OtherRegions); + MaterialEntities = MapMaterialEntities(recognitionResult.MaterialRows, pageRegions); + PipeLengthEntities = MapPipeLengthEntities(recognitionResult.PipeLengthRows, pageRegions); + } + catch (Exception ex) + { + Alert.ShowInTop("识别结果解析失败:" + ex.Message, MessageBoxIcon.Warning); + return; } - - - - foreach (JObject item in jArrayIsoInfo) - { - - - var row = dtIsoInfo.NewRow(); - row["id"] = item.Value("id"); - row["page_no"] = item.Value("page_no"); - row["drawing_number"] = item.Value("drawing_number"); - row["pipeline_id"] = item.Value("pipeline_id"); - row["operation_temp_c"] = item.Value("operation_temp_c"); - row["design_pressure_mpa"] = item.Value("design_pressure_mpa"); - row["design_temp_c"] = item.Value("design_temp_c"); - row["test_pressure_mpa"] = item.Value("test_pressure_mpa"); - row["hydraulic_test_pressure"] = item.Value("hydraulic_test_pressure"); - row["pipe_diameter_dn"] = item.Value("pipe_diameter_dn"); - row["pipe_spec_grade"] = item.Value("pipe_spec_grade"); - row["heat_insulation"] = item.Value("heat_insulation"); - row["insulation_thickness_mm"] = item.Value("insulation_thickness_mm"); - row["post_weld_heat_treatment"] = item.Value("post_weld_heat_treatment"); - row["radiographic_examination"] = item.Value("radiographic_examination"); - dtIsoInfo.Rows.Add(row); - } - - // 遍历并提取数据 - foreach (JObject item in jArray) - { - var row = dt.NewRow(); - row["id"] = item.Value("id"); - row["pipe_no"] = item.Value("pipe_no"); - row["drawing_number"] = item.Value("drawing_number"); - - row["code"] = item.Value("code"); - row["seq_no"] = item.Value("seq_no"); - row["category"] = item.Value("category"); - row["description"] = item.Value("description"); - row["spec"] = item.Value("spec"); - row["qty"] = item.Value("qty"); - row["page_no"] = item.Value("page_no"); - row["remark"] = item.Value("remark"); - if (string.IsNullOrEmpty(row["pipe_no"].ToString())) - { - var rowOther = dtOther.Select("page= " + row["page_no"].ToString()).FirstOrDefault(); - row["pipe_no"] = rowOther["text"]; - } - dt.Rows.Add(row); - } - - BindGrid(); + Grid1.Hidden = false; + Grid2.Hidden = false; + contentPanel1.Hidden = true; + btnAudit.Hidden = true; + btnSave.Hidden = false; + BindGrids(); } } - - private void BindGrid() + private DrawingRecognitionResult DeserializeRecognitionResult() { - + if (string.IsNullOrWhiteSpace(resultdata.Value)) + { + throw new InvalidOperationException("识别结果为空"); + } - Grid1.DataSource = dt; + var recognitionResult = JsonConvert.DeserializeObject(resultdata.Value); + if (recognitionResult == null) + { + throw new InvalidOperationException("识别结果格式不正确"); + } + + recognitionResult.MaterialRows = recognitionResult.MaterialRows ?? new List(); + recognitionResult.PipeLengthRows = recognitionResult.PipeLengthRows ?? new List(); + recognitionResult.OtherRegions = recognitionResult.OtherRegions ?? new List(); + recognitionResult.DrawingInfo = recognitionResult.DrawingInfo ?? new List(); + return recognitionResult; + } + + /// + /// 构建原始页码与识别区域的映射,供 C1、C3 等区域统一取值。 + /// + private static Dictionary> BuildPageRegionMap( + IEnumerable otherRegions) + { + // 同一页以 region_code 区分 C1 管线页码和 C3 管线号,避免依赖区域返回顺序。 + return otherRegions + .Where(x => x != null && x.Page.HasValue && !string.IsNullOrWhiteSpace(x.RegionCode)) + .GroupBy(x => x.Page.Value) + .ToDictionary( + pageGroup => pageGroup.Key, + pageGroup => pageGroup + .GroupBy(x => x.RegionCode.Trim(), StringComparer.OrdinalIgnoreCase) + .ToDictionary( + regionGroup => regionGroup.Key, + regionGroup => regionGroup.Select(x => x.Text).FirstOrDefault(), + StringComparer.OrdinalIgnoreCase)); + } + + private static string GetPageRegionValueOrDefault( + Dictionary> pageRegions, + int? pageNo, + string regionCode) + { + if (!pageNo.HasValue || !pageRegions.TryGetValue(pageNo.Value, out var regions) || + !regions.TryGetValue(regionCode, out var value) || string.IsNullOrWhiteSpace(value)) + { + return null; + } + + return value.Trim(); + } + + private static string GetRequiredPageRegionValue( + Dictionary> pageRegions, + int? pageNo, + string regionCode) + { + if (!pageNo.HasValue) + { + throw new InvalidOperationException("存在缺少 page_no 的识别数据"); + } + + string value = GetPageRegionValueOrDefault(pageRegions, pageNo, regionCode); + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException(string.Format("第 {0} 页未识别到区域 {1}", pageNo.Value, regionCode)); + } + + return value; + } + + /// + /// 获取 C1 中的管线页码,并校验其必须为整数。 + /// + private static int GetRequiredPipePageNo( + Dictionary> pageRegions, + int? sourcePageNo) + { + string pipePageNoText = GetRequiredPageRegionValue(pageRegions, sourcePageNo, "C1"); + if (!int.TryParse(pipePageNoText, out var pipePageNo)) + { + throw new InvalidOperationException(string.Format("第 {0} 页区域 C1 的值“{1}”不是有效整数", sourcePageNo, pipePageNoText)); + } + + return pipePageNo; + } + + /// + /// 根据识别数据的原始页码获取 C3 管线号。 + /// + private static string GetPipelineCodeByPageNo( + Dictionary> pageRegions, + int? pageNo) + { + // 管线号统一通过原始页码匹配 C3,避免各类识别数据重复实现映射逻辑。 + return GetRequiredPageRegionValue(pageRegions, pageNo, "C3"); + } + + /// + /// 将材料识别结果映射为待保存的材料实体。 + /// + private static List MapMaterialEntities( + IEnumerable materialRows, + Dictionary> pageRegions) + { + return materialRows.Select(row => new HJGL_DrawingRecognition_Material + { + Id = SQLHelper.GetNewID(), + Pipe_no = GetPipelineCodeByPageNo(pageRegions, row.PageNo), + Pipe_page_no = GetRequiredPipePageNo(pageRegions, row.PageNo), + Seq_no = GetNullableInt(row.SeqNo), + Category = row.Category, + Description = row.Description, + Spec = row.Spec, + Code = row.Code, + Qty = row.Qty, + Unit = row.Unit, + Material = row.Material, + Drawing_number = row.DrawingNumber, + Remark = row.Remark + }).ToList(); + } + + /// + /// 将管段长度识别结果映射为待保存的管段长度实体。 + /// + private static List MapPipeLengthEntities( + IEnumerable pipeLengthRows, + Dictionary> pageRegions) + { + return pipeLengthRows.Select(row => new HJGL_DrawingRecognition_PipeLengths + { + Id = SQLHelper.GetNewID(), + Pipe_no = GetPipelineCodeByPageNo(pageRegions, row.PageNo), + Pipe_page_no = GetRequiredPipePageNo(pageRegions, row.PageNo), + Group_index = row.GroupIndex, + Pos_no = row.PosNo, + Length_mm = row.LengthMm, + Dn = row.Dn + }).ToList(); + } + + private static int? GetNullableInt(object value) + { + return int.TryParse(Convert.ToString(value), out var number) ? number : (int?)null; + } + + /// + /// 按当前项目和管线号新增或更新管线,仅同步 DrawingInfo 中识别到的字段。 + /// + private Dictionary UpsertPipelinesFromDrawingInfo( + DrawingRecognitionResult recognitionResult) + { + var pageRegions = BuildPageRegionMap(recognitionResult.OtherRegions); + var pipelineDrawingData = BuildPipelineDrawingData(recognitionResult.DrawingInfo, pageRegions); + if (pipelineDrawingData.Count == 0) + { + throw new InvalidOperationException("未从区域 C3 识别到管线号"); + } + + var pipelineCodes = pipelineDrawingData.Keys.ToList(); + var existingPipelines = Funs.DB.HJGL_Pipeline + .Where(x => x.ProjectId == CurrUser.LoginProjectId && pipelineCodes.Contains(x.PipelineCode)) + .ToList(); + + var duplicatePipeline = existingPipelines + .GroupBy(x => x.PipelineCode, StringComparer.OrdinalIgnoreCase) + .FirstOrDefault(group => group.Count() > 1); + if (duplicatePipeline != null) + { + throw new InvalidOperationException("当前项目存在重复管线号:" + duplicatePipeline.Key); + } + + var pipelinesByCode = existingPipelines.ToDictionary( + x => x.PipelineCode, + StringComparer.OrdinalIgnoreCase); + + // HJGL_Pipeline 保存 PipingClassId,识别到的等级编码必须先按当前项目批量转换。 + var pipingClassCodes = pipelineDrawingData.Values + .Select(x => x.PipingClassCode) + .Where(x => !string.IsNullOrWhiteSpace(x)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToList(); + var pipingClasses = Funs.DB.Base_PipingClass + .Where(x => x.ProjectId == CurrUser.LoginProjectId && pipingClassCodes.Contains(x.PipingClassCode)) + .ToList() + .GroupBy(x => x.PipingClassCode, StringComparer.OrdinalIgnoreCase) + .ToDictionary(group => group.Key, group => group.First(), StringComparer.OrdinalIgnoreCase); + + var missingPipingClassCodes = pipingClassCodes + .Where(code => !pipingClasses.ContainsKey(code)) + .ToList(); + if (missingPipingClassCodes.Count > 0) + { + throw new InvalidOperationException( + "当前项目不存在以下管道等级:" + string.Join("、", missingPipingClassCodes)); + } + + foreach (var item in pipelineDrawingData) + { + if (!pipelinesByCode.TryGetValue(item.Key, out var pipeline)) + { + pipeline = new HJGL_Pipeline + { + PipelineId = SQLHelper.GetNewID(), + ProjectId = CurrUser.LoginProjectId, + PipelineCode = item.Key, + UnitWorkId= drpUnitWork.SelectedValue + }; + Funs.DB.HJGL_Pipeline.InsertOnSubmit(pipeline); + pipelinesByCode.Add(item.Key, pipeline); + } + + // 识别结果为空时保留已有值,避免不完整识别覆盖管线原数据。 + if (!string.IsNullOrWhiteSpace(item.Value.PipingClassCode)) + { + pipeline.PipingClassId = pipingClasses[item.Value.PipingClassCode].PipingClassId; + } + if (!string.IsNullOrWhiteSpace(item.Value.DesignPress)) + { + pipeline.DesignPress = item.Value.DesignPress; + } + if (!string.IsNullOrWhiteSpace(item.Value.DesignTemperature)) + { + pipeline.DesignTemperature = item.Value.DesignTemperature; + } + if (item.Value.DesignIsHotProess.HasValue) + { + pipeline.DesignIsHotProess = item.Value.DesignIsHotProess; + } + } + + return pipelinesByCode; + } + + /// + /// 按页码取得管线号后聚合 DrawingInfo,同一管线跨页数据合并处理。 + /// + private static Dictionary BuildPipelineDrawingData( + IEnumerable drawingInfo, + Dictionary> pageRegions) + { + // 同一管线可能对应多个 PDF 页,按 C3 管线号分组后统一校验和取值。 + var pipelineGroups = drawingInfo + .Where(x => x != null) + .GroupBy( + x => GetPipelineCodeByPageNo(pageRegions, x.PageNo), + StringComparer.OrdinalIgnoreCase); + + var result = new Dictionary(StringComparer.OrdinalIgnoreCase); + foreach (var pipelineGroup in pipelineGroups) + { + string pwht = GetUniqueDrawingFieldValue( + pipelineGroup, + pipelineGroup.Key, + "PWHT"); + result.Add(pipelineGroup.Key, new PipelineDrawingData + { + PipingClassCode = GetUniqueDrawingFieldValue( + pipelineGroup, + pipelineGroup.Key, + "Piping class"), + DesignPress = GetUniqueDrawingFieldValue( + pipelineGroup, + pipelineGroup.Key, + "Design pressure, MPag"), + DesignTemperature = GetUniqueDrawingFieldValue( + pipelineGroup, + pipelineGroup.Key, + "Design temperature", + true), + DesignIsHotProess = string.IsNullOrWhiteSpace(pwht) + ? (bool?)null + : ParsePwht(pwht, pipelineGroup.Key) + }); + } + + + return result; + } + + /// + /// 获取管线字段的唯一非空值;跨页识别值不一致时阻止保存。 + /// + private static string GetUniqueDrawingFieldValue( + IEnumerable rows, + string pipelineCode, + string fieldName, + bool startsWith = false) + { + var values = rows + .Where(x => !string.IsNullOrWhiteSpace(x.FieldName) && + (startsWith + ? x.FieldName.Trim().StartsWith(fieldName, StringComparison.OrdinalIgnoreCase) + : string.Equals(x.FieldName.Trim(), fieldName, StringComparison.OrdinalIgnoreCase))) + .Select(x => x.FieldValue == null ? null : x.FieldValue.Trim()) + .Where(x => !string.IsNullOrWhiteSpace(x)) + .Distinct(StringComparer.OrdinalIgnoreCase) + .ToList(); + if (values.Count > 1) + { + throw new InvalidOperationException(string.Format( + "管线“{0}”的字段“{1}”识别值不一致:{2}", + pipelineCode, + fieldName, + string.Join("、", values))); + } + + return values.FirstOrDefault(); + } + + /// + /// 将识别结果中的 PWHT Yes/No 标记转换为是否需要焊后热处理。 + /// + private static bool ParsePwht(string value, string pipelineCode) + { + string normalizedValue = value.Trim(); + if (normalizedValue.IndexOf("(Yes)", StringComparison.OrdinalIgnoreCase) >= 0 || + string.Equals(normalizedValue, "Yes", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "Y", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "1", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "是", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "True", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + + if (normalizedValue.IndexOf("(No)", StringComparison.OrdinalIgnoreCase) >= 0 || + string.Equals(normalizedValue, "No", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "N", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "0", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "否", StringComparison.OrdinalIgnoreCase) || + string.Equals(normalizedValue, "False", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + + throw new InvalidOperationException(string.Format( + "管线“{0}”的 PWHT 值“{1}”无法识别为是或否", + pipelineCode, + value)); + } + + private sealed class PipelineDrawingData + { + public string PipingClassCode { get; set; } + + public string DesignPress { get; set; } + + public string DesignTemperature { get; set; } + + public bool? DesignIsHotProess { get; set; } + } + + + private void BindGrids() + { + Grid1.DataSource = MaterialEntities ?? new List(); Grid1.DataBind(); - - - } + Grid2.DataSource = PipeLengthEntities ?? new List(); + Grid2.DataBind(); + } #region 双击事件 /// /// Grid行双击事件 @@ -458,18 +791,18 @@ namespace FineUIPro.Web.HJGL.DataIn } if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_DataInMenuId, Const.BtnAdd)) { - if (DrawingRecognitionContentEdit.dicDt.ContainsKey(CurrUser.PersonId)) + if (MaterialEntities == null) { - DrawingRecognitionContentEdit.dicDt[CurrUser.PersonId] = dt; + Alert.ShowInTop("实体数据已失效,请重新审核识别结果!", MessageBoxIcon.Warning); + return; } - else - { - DrawingRecognitionContentEdit.dicDt.Add(CurrUser.PersonId, dt); - } - PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdIds.ClientID) + Window1.GetShowReference(String.Format("DrawingRecognitionContentEdit.aspx?Index={0}", Grid1.SelectedRowIndex, "编辑 - "))); - - //PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DrawingRecognitionContentEdit.aspx?Index={0}", Grid1.SelectedRowIndex, "维护 - "))); + string editUrl = string.Format( + "DrawingRecognitionContentEdit.aspx?Index={0}&DataKey={1}", + Grid1.SelectedRowIndex, + RecognitionDataKey); + PageContext.RegisterStartupScript( + Window1.GetSaveStateReference(hdIds.ClientID) + Window1.GetShowReference(editUrl)); } else { @@ -480,8 +813,7 @@ namespace FineUIPro.Web.HJGL.DataIn protected void Window1_Close(object sender, WindowCloseEventArgs e) { - Grid1.DataSource = dt; - Grid1.DataBind(); + BindGrids(); } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.designer.cs index 77edb7e7..4d853f5e 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContent.aspx.designer.cs @@ -77,6 +77,15 @@ namespace FineUIPro.Web.HJGL.DataIn /// protected global::FineUIPro.ToolbarFill ToolbarFill1; + /// + /// drpUnitWork 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpUnitWork; + /// /// btnAudit 控件。 /// @@ -113,6 +122,15 @@ namespace FineUIPro.Web.HJGL.DataIn /// protected global::FineUIPro.Grid Grid1; + /// + /// Grid2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid2; + /// /// Window1 控件。 /// diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx index 2cf9f8f6..3215d941 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx @@ -25,9 +25,9 @@ - + - + @@ -40,7 +40,7 @@ - + diff --git a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx.cs b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx.cs index 3d34288b..b68a19d7 100644 --- a/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/DataImport/DrawingRecognitionContentEdit.aspx.cs @@ -2,18 +2,11 @@ { using System; using System.Collections.Generic; - using System.Data; - using System.Data.SqlClient; - using System.Linq; - using BLL; + using Model; public partial class DrawingRecognitionContentEdit : PageBase { #region 定义项 - /// - /// 临时表主键 - /// - public static Dictionary dicDt = new Dictionary(); public int Index { get @@ -25,6 +18,27 @@ ViewState["Index"] = value; } } + + public string DataKey + { + get + { + return (string)ViewState["DataKey"]; + } + set + { + ViewState["DataKey"] = value; + } + } + + private List MaterialEntities + { + get + { + return Session[DataKey + DrawingRecognitionContent.MaterialSessionSuffix] + as List; + } + } #endregion #region 加载页面 @@ -38,20 +52,22 @@ if (!IsPostBack) { this.Index = int.Parse(Request.Params["Index"]); - DataTable dt = dicDt[CurrUser.PersonId]; - var dataInTemp = dt.Rows[this.Index]; - if (dataInTemp != null) + this.DataKey = Request.Params["DataKey"]; + var materialEntities = MaterialEntities; + if (materialEntities == null || this.Index < 0 || this.Index >= materialEntities.Count) { - this.txtPipeNo.Text = dataInTemp["pipe_no"].ToString(); - this.txtDrawingNumber.Text = dataInTemp["drawing_number"].ToString(); - this.txtCategory.Text = dataInTemp["category"].ToString(); - this.txtQty.Text = dataInTemp["qty"].ToString(); - this.txtSpec.Text = dataInTemp["spec"].ToString(); - this.txtPageNo.Text = dataInTemp["page_no"].ToString(); - this.txtDescription.Text = dataInTemp["description"].ToString(); - - + Alert.ShowInTop("材料实体数据已失效,请关闭窗口后重新审核!", MessageBoxIcon.Warning); + return; } + + var material = materialEntities[this.Index]; + this.txtPipeNo.Text = material.Pipe_no; + this.txtDrawingNumber.Text = material.Drawing_number; + this.txtCategory.Text = material.Category; + this.txtQty.Text = material.Qty; + this.txtSpec.Text = material.Spec; + this.txtPageNo.Text = Convert.ToString(material.Pipe_page_no); + this.txtDescription.Text = material.Description; } } #endregion @@ -64,15 +80,27 @@ /// protected void btnSave_Click(object sender, EventArgs e) { - DataTable dt = dicDt[CurrUser.PersonId]; - var dataInTemp = dt.Rows[this.Index]; - dataInTemp["pipe_no"] = this.txtPipeNo.Text; - dataInTemp["drawing_number"] = this.txtDrawingNumber.Text; - dataInTemp["category"] = this.txtCategory.Text; - dataInTemp["qty"] = this.txtQty.Text; - dataInTemp["spec"] = this.txtSpec.Text; - dataInTemp["page_no"] = this.txtPageNo.Text; - dataInTemp["description"] = this.txtDescription; + var materialEntities = MaterialEntities; + if (materialEntities == null || this.Index < 0 || this.Index >= materialEntities.Count) + { + Alert.ShowInTop("材料实体数据已失效,请关闭窗口后重新审核!", MessageBoxIcon.Warning); + return; + } + + if (!int.TryParse(this.txtPageNo.Text, out var pipePageNo)) + { + Alert.ShowInTop("管线页码必须为整数!", MessageBoxIcon.Warning); + return; + } + + var material = materialEntities[this.Index]; + material.Pipe_no = this.txtPipeNo.Text; + material.Drawing_number = this.txtDrawingNumber.Text; + material.Category = this.txtCategory.Text; + material.Qty = this.txtQty.Text; + material.Spec = this.txtSpec.Text; + material.Pipe_page_no = pipePageNo; + material.Description = this.txtDescription.Text; Alert.ShowInTop("信息修改完成!", MessageBoxIcon.Success); if (ckAll.Checked) @@ -84,8 +112,7 @@ PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference("") + ActiveWindow.GetHidePostBackReference()); } - dicDt.Remove(CurrUser.PersonId); } #endregion } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx b/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx index 82b8473b..9b77e328 100644 --- a/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx @@ -202,6 +202,9 @@ DataField="CoverWelderTeamGroupName" FieldType="String" HeaderTextAlign="Center" TextAlign="Center" Width="90px"> + + diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs b/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs index 7c39b8ff..37e4847f 100644 --- a/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs @@ -623,6 +623,7 @@ namespace FineUIPro.Web.HJGL.InfoQuery var q = (from x in View_HJGL_WeldJoint select new { + 管线号 = x.PipelineCode, 焊口号 = x.WeldJointCode, 完成状态 = x.IsWeldOK, 单位名称 = x.UnitName, @@ -647,6 +648,7 @@ namespace FineUIPro.Web.HJGL.InfoQuery 打底焊工班组 = x.BackingWelderTeamGroupName, 盖面焊工号 = x.CoverWelderCode, 盖面焊工班组 = x.CoverWelderTeamGroupName, + 是否热处理 = x.IsHotProessStr, 热处理报告编号 = x.HotProessReportNo, 热处理检测结果 = x.HotProessResult, 硬度报告编号 = x.HardReportNo, diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx b/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx new file mode 100644 index 00000000..3143a4e9 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx @@ -0,0 +1,78 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MaterialOverview.aspx.cs" Inherits="FineUIPro.Web.HJGL.InfoQuery.MaterialOverview" %> + + + + + 管道材信息总览 + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx.cs b/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx.cs new file mode 100644 index 00000000..3c95a77d --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx.cs @@ -0,0 +1,163 @@ +using BLL; +using MiniExcelLibs; +using Model; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace FineUIPro.Web.HJGL.InfoQuery +{ + public partial class MaterialOverview : PageBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); + InitTreeMenu(); + } + } + + private void InitTreeMenu() + { + tvControlItem.Nodes.Clear(); + TreeNode civilNode = new TreeNode { NodeID = "1", Text = "建筑工程", Selectable = false }; + TreeNode installNode = new TreeNode { NodeID = "2", Text = "安装工程", Selectable = false, Expanded = true }; + tvControlItem.Nodes.Add(civilNode); + tvControlItem.Nodes.Add(installNode); + + string projectId = CurrUser.LoginProjectId; + // 识别结果未保存项目和WBS字段,按管线号关联项目管线后才能实现项目隔离和WBS筛选。 + var recordCounts = (from material in Funs.DB.HJGL_DrawingRecognition_Material + join pipeline in Funs.DB.HJGL_Pipeline on material.Pipe_no equals pipeline.PipelineCode + where pipeline.ProjectId == projectId && pipeline.UnitWorkId != null + group material by pipeline.UnitWorkId into groupItem + select new { UnitWorkId = groupItem.Key, Count = groupItem.Count() }).ToDictionary(x => x.UnitWorkId, x => x.Count); + var unitWorks = (from unitWork in Funs.DB.WBS_UnitWork + where unitWork.ProjectId == projectId && unitWork.SuperUnitWork == null && unitWork.UnitId != null && unitWork.ProjectType != null + orderby unitWork.UnitWorkCode + select unitWork).ToList(); + var unitIds = unitWorks.Where(x => x.UnitId != null).Select(x => x.UnitId).Distinct().ToList(); + var unitNames = (from unit in Funs.DB.Base_Unit where unitIds.Contains(unit.UnitId) select unit).ToDictionary(x => x.UnitId, x => x.UnitName); + + foreach (var unitWork in unitWorks) + { + int count = recordCounts.ContainsKey(unitWork.UnitWorkId) ? recordCounts[unitWork.UnitWorkId] : 0; + TreeNode node = new TreeNode(); + node.NodeID = unitWork.UnitWorkId; + node.Text = unitWork.UnitWorkName + "【" + count + "】材料"; + node.ToolTip = "施工单位:" + (unitNames.ContainsKey(unitWork.UnitId) ? unitNames[unitWork.UnitId] : ""); + node.EnableClickEvent = true; + (unitWork.ProjectType == "1" ? civilNode : installNode).Nodes.Add(node); + } + } + + protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) + { + Grid1.PageIndex = 0; + BindGrid(); + } + + private void BindGrid() + { + string unitWorkId = tvControlItem.SelectedNodeID; + if (string.IsNullOrEmpty(unitWorkId)) + { + Grid1.RecordCount = 0; + Grid1.DataSource = new List(); + Grid1.DataBind(); + return; + } + + var query = ApplySort(GetCurrentQuery(unitWorkId)); + Grid1.RecordCount = query.Count(); + Grid1.DataSource = query.Skip(Grid1.PageIndex * Grid1.PageSize).Take(Grid1.PageSize).ToList(); + Grid1.DataBind(); + } + + /// + /// 汇总当前WBS节点和页面筛选条件,保证列表与导出数据完全一致。 + /// + private IQueryable GetCurrentQuery(string unitWorkId) + { + string pipeNo = txtPipeNo.Text.Trim(); + string materialCode = txtMaterialCode.Text.Trim(); + var query = from material in Funs.DB.HJGL_DrawingRecognition_Material + join pipeline in Funs.DB.HJGL_Pipeline on material.Pipe_no equals pipeline.PipelineCode + where pipeline.ProjectId == CurrUser.LoginProjectId && pipeline.UnitWorkId == unitWorkId + select material; + if (!string.IsNullOrEmpty(pipeNo)) query = query.Where(x => x.Pipe_no.Contains(pipeNo)); + if (!string.IsNullOrEmpty(materialCode)) query = query.Where(x => x.Code.Contains(materialCode)); + return query; + } + + private IQueryable ApplySort(IQueryable query) + { + bool descending = Grid1.SortDirection == "DESC"; + switch (Grid1.SortField) + { + case "Pipe_page_no": return descending ? query.OrderByDescending(x => x.Pipe_page_no) : query.OrderBy(x => x.Pipe_page_no); + case "Seq_no": return descending ? query.OrderByDescending(x => x.Seq_no) : query.OrderBy(x => x.Seq_no); + case "Code": return descending ? query.OrderByDescending(x => x.Code) : query.OrderBy(x => x.Code); + case "Drawing_number": return descending ? query.OrderByDescending(x => x.Drawing_number) : query.OrderBy(x => x.Drawing_number); + case "Category": return descending ? query.OrderByDescending(x => x.Category) : query.OrderBy(x => x.Category); + case "Spec": return descending ? query.OrderByDescending(x => x.Spec) : query.OrderBy(x => x.Spec); + case "Qty": return descending ? query.OrderByDescending(x => x.Qty) : query.OrderBy(x => x.Qty); + case "Unit": return descending ? query.OrderByDescending(x => x.Unit) : query.OrderBy(x => x.Unit); + case "Material": return descending ? query.OrderByDescending(x => x.Material) : query.OrderBy(x => x.Material); + case "Description": return descending ? query.OrderByDescending(x => x.Description) : query.OrderBy(x => x.Description); + case "Remark": return descending ? query.OrderByDescending(x => x.Remark) : query.OrderBy(x => x.Remark); + default: return descending ? query.OrderByDescending(x => x.Pipe_no) : query.OrderBy(x => x.Pipe_no); + } + } + + protected void btnQuery_Click(object sender, EventArgs e) { Grid1.PageIndex = 0; BindGrid(); } + protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } + protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortField = e.SortField; Grid1.SortDirection = e.SortDirection; BindGrid(); } + protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); Grid1.PageIndex = 0; BindGrid(); } + + protected void btnOut_Click(object sender, EventArgs e) + { + string unitWorkId = tvControlItem.SelectedNodeID; + if (string.IsNullOrEmpty(unitWorkId)) + { + ShowNotify("请先选择WBS目录", MessageBoxIcon.Warning); + return; + } + + // 导出所有满足当前筛选条件的记录,不受列表分页大小限制。 + var data = ApplySort(GetCurrentQuery(unitWorkId)).Select(x => new + { + 管线号 = x.Pipe_no, + 管线页码 = x.Pipe_page_no, + 序号 = x.Seq_no, + 材料编码 = x.Code, + 图号 = x.Drawing_number, + 类型 = x.Category, + 规格 = x.Spec, + 数量 = x.Qty, + 单位 = x.Unit, + 材质 = x.Material, + 描述 = x.Description, + 备注 = x.Remark + }).ToList(); + string path = Path.Combine(Funs.RootPath, "File", "Excel", "Temp", "MaterialOverview" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".xlsx"); + MiniExcel.SaveAs(path, data); + DownloadExcel(path, "管道材料信息总览.xlsx"); + } + + private void DownloadExcel(string path, string fileName) + { + FileInfo info = new FileInfo(path); + System.Web.HttpContext.Current.Response.Clear(); + System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed"; + System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + System.Web.HttpContext.Current.Response.AddHeader("Content-Length", info.Length.ToString()); + System.Web.HttpContext.Current.Response.TransmitFile(path, 0, info.Length); + System.Web.HttpContext.Current.Response.Flush(); + System.Web.HttpContext.Current.Response.Close(); + File.Delete(path); + } + } +} diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx.designer.cs new file mode 100644 index 00000000..34c50ec5 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/MaterialOverview.aspx.designer.cs @@ -0,0 +1,161 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.HJGL.InfoQuery +{ + + + public partial class MaterialOverview + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Panel1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel Panel1; + + /// + /// panelLeftRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelLeftRegion; + + /// + /// tvControlItem 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Tree tvControlItem; + + /// + /// panelCenterRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelCenterRegion; + + /// + /// Toolbar1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar1; + + /// + /// txtPipeNo 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtPipeNo; + + /// + /// txtMaterialCode 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtMaterialCode; + + /// + /// ToolbarFill1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarFill ToolbarFill1; + + /// + /// btnQuery 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnQuery; + + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + + /// + /// Grid1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid1; + + /// + /// ToolbarSeparator1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1; + + /// + /// ToolbarText1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarText ToolbarText1; + + /// + /// ddlPageSize 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList ddlPageSize; + } +} diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx b/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx new file mode 100644 index 00000000..8da72036 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx @@ -0,0 +1,72 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PipeLengthOverview.aspx.cs" Inherits="FineUIPro.Web.HJGL.InfoQuery.PipeLengthOverview" %> + + + + + 管长信息总览 + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx.cs b/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx.cs new file mode 100644 index 00000000..d9a6d9a2 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx.cs @@ -0,0 +1,151 @@ +using BLL; +using MiniExcelLibs; +using Model; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace FineUIPro.Web.HJGL.InfoQuery +{ + public partial class PipeLengthOverview : PageBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + ddlPageSize.SelectedValue = Grid1.PageSize.ToString(); + InitTreeMenu(); + } + } + + private void InitTreeMenu() + { + tvControlItem.Nodes.Clear(); + TreeNode civilNode = new TreeNode { NodeID = "1", Text = "建筑工程", Selectable = false }; + TreeNode installNode = new TreeNode { NodeID = "2", Text = "安装工程", Selectable = false, Expanded = true }; + tvControlItem.Nodes.Add(civilNode); + tvControlItem.Nodes.Add(installNode); + + string projectId = CurrUser.LoginProjectId; + // 管长识别表无项目归属,必须通过管线号关联项目管线,防止跨项目展示同名管线的识别结果。 + var recordCounts = (from pipeLength in Funs.DB.HJGL_DrawingRecognition_PipeLengths + join pipeline in Funs.DB.HJGL_Pipeline on pipeLength.Pipe_no equals pipeline.PipelineCode + where pipeline.ProjectId == projectId && pipeline.UnitWorkId != null + group pipeLength by pipeline.UnitWorkId into groupItem + select new { UnitWorkId = groupItem.Key, Count = groupItem.Count() }).ToDictionary(x => x.UnitWorkId, x => x.Count); + var unitWorks = (from unitWork in Funs.DB.WBS_UnitWork + where unitWork.ProjectId == projectId && unitWork.SuperUnitWork == null && unitWork.UnitId != null && unitWork.ProjectType != null + orderby unitWork.UnitWorkCode + select unitWork).ToList(); + var unitIds = unitWorks.Where(x => x.UnitId != null).Select(x => x.UnitId).Distinct().ToList(); + var unitNames = (from unit in Funs.DB.Base_Unit where unitIds.Contains(unit.UnitId) select unit).ToDictionary(x => x.UnitId, x => x.UnitName); + + foreach (var unitWork in unitWorks) + { + int count = recordCounts.ContainsKey(unitWork.UnitWorkId) ? recordCounts[unitWork.UnitWorkId] : 0; + TreeNode node = new TreeNode(); + node.NodeID = unitWork.UnitWorkId; + node.Text = unitWork.UnitWorkName + "【" + count + "】管段"; + node.ToolTip = "施工单位:" + (unitNames.ContainsKey(unitWork.UnitId) ? unitNames[unitWork.UnitId] : ""); + node.EnableClickEvent = true; + (unitWork.ProjectType == "1" ? civilNode : installNode).Nodes.Add(node); + } + } + + protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) + { + Grid1.PageIndex = 0; + BindGrid(); + } + + private void BindGrid() + { + string unitWorkId = tvControlItem.SelectedNodeID; + if (string.IsNullOrEmpty(unitWorkId)) + { + Grid1.RecordCount = 0; + Grid1.DataSource = new List(); + Grid1.DataBind(); + return; + } + + var query = ApplySort(GetCurrentQuery(unitWorkId)); + Grid1.RecordCount = query.Count(); + Grid1.DataSource = query.Skip(Grid1.PageIndex * Grid1.PageSize).Take(Grid1.PageSize).ToList(); + Grid1.DataBind(); + } + + /// + /// 汇总当前WBS节点和页面筛选条件,保证列表与导出数据完全一致。 + /// + private IQueryable GetCurrentQuery(string unitWorkId) + { + string pipeNo = txtPipeNo.Text.Trim(); + string dn = txtDn.Text.Trim(); + var query = from pipeLength in Funs.DB.HJGL_DrawingRecognition_PipeLengths + join pipeline in Funs.DB.HJGL_Pipeline on pipeLength.Pipe_no equals pipeline.PipelineCode + where pipeline.ProjectId == CurrUser.LoginProjectId && pipeline.UnitWorkId == unitWorkId + select pipeLength; + if (!string.IsNullOrEmpty(pipeNo)) query = query.Where(x => x.Pipe_no.Contains(pipeNo)); + if (!string.IsNullOrEmpty(dn)) query = query.Where(x => x.Dn.Contains(dn)); + return query; + } + + private IQueryable ApplySort(IQueryable query) + { + bool descending = Grid1.SortDirection == "DESC"; + switch (Grid1.SortField) + { + case "Pipe_page_no": return descending ? query.OrderByDescending(x => x.Pipe_page_no) : query.OrderBy(x => x.Pipe_page_no); + case "Group_index": return descending ? query.OrderByDescending(x => x.Group_index) : query.OrderBy(x => x.Group_index); + case "Pos_no": return descending ? query.OrderByDescending(x => x.Pos_no) : query.OrderBy(x => x.Pos_no); + case "Length_mm": return descending ? query.OrderByDescending(x => x.Length_mm) : query.OrderBy(x => x.Length_mm); + case "Dn": return descending ? query.OrderByDescending(x => x.Dn) : query.OrderBy(x => x.Dn); + default: return descending ? query.OrderByDescending(x => x.Pipe_no) : query.OrderBy(x => x.Pipe_no); + } + } + + protected void btnQuery_Click(object sender, EventArgs e) { Grid1.PageIndex = 0; BindGrid(); } + protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) { Grid1.PageIndex = e.NewPageIndex; BindGrid(); } + protected void Grid1_Sort(object sender, GridSortEventArgs e) { Grid1.SortField = e.SortField; Grid1.SortDirection = e.SortDirection; BindGrid(); } + protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) { Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); Grid1.PageIndex = 0; BindGrid(); } + + protected void btnOut_Click(object sender, EventArgs e) + { + string unitWorkId = tvControlItem.SelectedNodeID; + if (string.IsNullOrEmpty(unitWorkId)) + { + ShowNotify("请先选择WBS目录", MessageBoxIcon.Warning); + return; + } + + // 导出所有满足当前筛选条件的记录,不受列表分页大小限制。 + var data = ApplySort(GetCurrentQuery(unitWorkId)).Select(x => new + { + 管线号 = x.Pipe_no, + 管线页码 = x.Pipe_page_no, + 分组序号 = x.Group_index, + 位置编号 = x.Pos_no, + 长度毫米 = x.Length_mm, + 公称直径DN = x.Dn + }).ToList(); + string path = Path.Combine(Funs.RootPath, "File", "Excel", "Temp", "PipeLengthOverview" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + ".xlsx"); + MiniExcel.SaveAs(path, data); + DownloadExcel(path, "管长信息总览.xlsx"); + } + + private void DownloadExcel(string path, string fileName) + { + FileInfo info = new FileInfo(path); + System.Web.HttpContext.Current.Response.Clear(); + System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed"; + System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + System.Web.HttpContext.Current.Response.AddHeader("Content-Length", info.Length.ToString()); + System.Web.HttpContext.Current.Response.TransmitFile(path, 0, info.Length); + System.Web.HttpContext.Current.Response.Flush(); + System.Web.HttpContext.Current.Response.Close(); + File.Delete(path); + } + } +} diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx.designer.cs new file mode 100644 index 00000000..012254d5 --- /dev/null +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/PipeLengthOverview.aspx.designer.cs @@ -0,0 +1,161 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.HJGL.InfoQuery +{ + + + public partial class PipeLengthOverview + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Panel1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel Panel1; + + /// + /// panelLeftRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelLeftRegion; + + /// + /// tvControlItem 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Tree tvControlItem; + + /// + /// panelCenterRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelCenterRegion; + + /// + /// Toolbar1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar1; + + /// + /// txtPipeNo 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtPipeNo; + + /// + /// txtDn 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.TextBox txtDn; + + /// + /// ToolbarFill1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarFill ToolbarFill1; + + /// + /// btnQuery 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnQuery; + + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + + /// + /// Grid1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid1; + + /// + /// ToolbarSeparator1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1; + + /// + /// ToolbarText1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarText ToolbarText1; + + /// + /// ddlPageSize 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList ddlPageSize; + } +} diff --git a/SGGL/FineUIPro.Web/HJGL/JoinMarking/PDFMarking.aspx b/SGGL/FineUIPro.Web/HJGL/JoinMarking/PDFMarking.aspx index 3a0f6a1e..453638e6 100644 --- a/SGGL/FineUIPro.Web/HJGL/JoinMarking/PDFMarking.aspx +++ b/SGGL/FineUIPro.Web/HJGL/JoinMarking/PDFMarking.aspx @@ -15,12 +15,14 @@ --%> - + - - - + + + + +