2026-05-27 23:13:02 +08:00
|
|
|
using Aspose.Words.Rendering;
|
|
|
|
|
using BLL;
|
|
|
|
|
using BLL.Common;
|
|
|
|
|
using Model;
|
2026-07-17 14:36:32 +08:00
|
|
|
using Newtonsoft.Json;
|
2026-05-27 23:13:02 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Text;
|
2026-07-17 14:36:32 +08:00
|
|
|
using System.Transactions;
|
2026-05-27 23:13:02 +08:00
|
|
|
using UglyToad.PdfPig;
|
|
|
|
|
using UglyToad.PdfPig.Content;
|
|
|
|
|
using UglyToad.PdfPig.Writer;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.HJGL.DataIn
|
|
|
|
|
{
|
|
|
|
|
public partial class DrawingRecognitionContent : PageBase
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
internal const string MaterialSessionSuffix = ":DrawingRecognitionMaterials";
|
|
|
|
|
internal const string PipeLengthSessionSuffix = ":DrawingRecognitionPipeLengths";
|
|
|
|
|
|
2026-05-27 23:13:02 +08:00
|
|
|
public string URL
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (string)ViewState["URL"];
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ViewState["URL"] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public string fileUrl
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return (string)ViewState["fileUrl"];
|
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
ViewState["fileUrl"] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
private string RecognitionDataKey
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
return (string)ViewState["RecognitionDataKey"];
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
ViewState["RecognitionDataKey"] = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string MaterialSessionKey
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return RecognitionDataKey + MaterialSessionSuffix;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string PipeLengthSessionKey
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return RecognitionDataKey + PipeLengthSessionSuffix;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
|
|
|
|
|
private List<HJGL_DrawingRecognition_Material> MaterialEntities
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
return Session[MaterialSessionKey] as List<HJGL_DrawingRecognition_Material>;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
Session[MaterialSessionKey] = value;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
|
|
|
|
|
private List<HJGL_DrawingRecognition_PipeLengths> PipeLengthEntities
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
return Session[PipeLengthSessionKey] as List<HJGL_DrawingRecognition_PipeLengths>;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
Session[PipeLengthSessionKey] = value;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
|
2026-05-27 23:13:02 +08:00
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!IsPostBack)
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
UnitWorkService.InitUnitWorkDownList(drpUnitWork, this.CurrUser.LoginProjectId, true);
|
|
|
|
|
RecognitionDataKey = Guid.NewGuid().ToString("N");
|
2026-05-27 23:13:02 +08:00
|
|
|
if (!string.IsNullOrEmpty(Request.Params["fileUrl"]))
|
|
|
|
|
{
|
|
|
|
|
URL = Funs.SGGLUrl + Request.Params["fileUrl"].Replace("\\", "/");
|
|
|
|
|
string rootPath = Server.MapPath("~/");
|
|
|
|
|
fileUrl = rootPath + Request.Params["fileUrl"];
|
|
|
|
|
|
|
|
|
|
// 加载PDF文档
|
|
|
|
|
|
|
|
|
|
if (!File.Exists(fileUrl))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
DrawingRecognitionResult recognitionResult;
|
|
|
|
|
List<HJGL_DrawingRecognition_Material> materialEntities;
|
|
|
|
|
List<HJGL_DrawingRecognition_PipeLengths> pipeLengthEntities;
|
|
|
|
|
Dictionary<string, HJGL_Pipeline> pipelinesByCode;
|
|
|
|
|
if(drpUnitWork.SelectedValue == null|| drpUnitWork.SelectedValue==Const._Null)
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
Alert.ShowInTop("请选择单位工程", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
recognitionResult = DeserializeRecognitionResult();
|
|
|
|
|
materialEntities = MaterialEntities;
|
|
|
|
|
pipeLengthEntities = PipeLengthEntities;
|
|
|
|
|
if (materialEntities == null || pipeLengthEntities == null)
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
throw new InvalidOperationException("实体数据已失效,请重新审核识别结果");
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
|
|
|
|
|
// DrawingInfo 以原始页码关联 C3 管线号,并同步当前项目的管线基础信息。
|
|
|
|
|
pipelinesByCode = UpsertPipelinesFromDrawingInfo(recognitionResult);
|
|
|
|
|
Funs.DB.SubmitChanges();
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
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<string, List<int>> 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);
|
2026-05-27 23:13:02 +08:00
|
|
|
using (var pdf = PdfDocument.Open(fileUrl))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < pdf.NumberOfPages; i++)
|
|
|
|
|
{
|
|
|
|
|
var page = pdf.GetPage(i + 1);
|
|
|
|
|
var rotation = page.Rotation;
|
|
|
|
|
|
|
|
|
|
string outputPath = "";
|
|
|
|
|
string isono = "";
|
|
|
|
|
foreach (string key in dic.Keys)
|
|
|
|
|
{
|
|
|
|
|
if (dic[key].IndexOf(i + 1) >= 0)
|
|
|
|
|
{
|
|
|
|
|
isono = key;
|
|
|
|
|
outputPath = $"{rootPath}/File/PDF/Pipe/" + key;
|
|
|
|
|
if (!Directory.Exists(outputPath))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(outputPath);
|
|
|
|
|
}
|
|
|
|
|
string fileName = key;
|
|
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
var pipePageRegion = recognitionResult.OtherRegions.FirstOrDefault(x =>
|
|
|
|
|
x.Page == i + 1 && string.Equals(x.RegionCode, "C1", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
if (pipePageRegion != null)
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
if (!string.IsNullOrWhiteSpace(pipePageRegion.Text))
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
fileName = pipePageRegion.Text.Trim();
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-05-30 12:29:12 +08:00
|
|
|
outputPath = $"{outputPath}/" + fileName + DateTime.Now.ToString("yyyyMMddHHmm")+(i + 1) + ".pdf";
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(outputPath))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
|
|
|
|
|
using (var writer = new PdfDocumentBuilder())
|
|
|
|
|
{
|
|
|
|
|
PdfPageBuilder newPage = null;
|
|
|
|
|
if (rotation.Value != 0 && rotation.Value != 180)
|
|
|
|
|
{
|
|
|
|
|
newPage = writer.AddPage(page.Height, page.Width);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newPage = writer.AddPage(page.Width, page.Height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
newPage.CopyFrom(page);
|
|
|
|
|
// 3. 关键:清除旋转标记 + 反向旋转内容(修正视觉方向)
|
|
|
|
|
// 清除 /Rotate 标记
|
|
|
|
|
newPage.SetRotation(new PageRotationDegrees(rotation.Value));
|
|
|
|
|
var newPdf = writer.Build();
|
|
|
|
|
File.WriteAllBytes(outputPath, newPdf);
|
|
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
if (pipelinesByCode.TryGetValue(isono, out var isoInfo))
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
|
|
|
|
//保存文件到附件
|
2026-05-30 12:29:12 +08:00
|
|
|
var attatch = AttachFileService.GetAttachFileByToKeyId(isoInfo.PipelineId);
|
|
|
|
|
if (attatch != null)
|
|
|
|
|
{
|
|
|
|
|
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(outputPath.Replace(rootPath, ""), 10, attatch.AttachSource), attatch.AttachUrl+","+ outputPath.Replace(rootPath, ""), Const.HJGL_PipelineMenuId, isoInfo.PipelineId);
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-05-30 12:29:12 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(outputPath.Replace(rootPath, ""), 10, null), outputPath.Replace(rootPath, ""), Const.HJGL_PipelineMenuId, isoInfo.PipelineId);
|
|
|
|
|
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
ReplaceRecognitionDetails(materialEntities, pipeLengthEntities);
|
|
|
|
|
|
|
|
|
|
List<Tw_InputDataIn> tw_InputDataIns = new List<Tw_InputDataIn>();
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按管线号和管线页码替换本次识别范围内的材料及管长数据。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static void ReplaceRecognitionDetails(
|
|
|
|
|
List<HJGL_DrawingRecognition_Material> materialEntities,
|
|
|
|
|
List<HJGL_DrawingRecognition_PipeLengths> 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<int>(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<string, HashSet<int>> pageNumbersByPipeNo,
|
|
|
|
|
string pipeNo,
|
|
|
|
|
int? pipePageNo)
|
|
|
|
|
{
|
|
|
|
|
return !string.IsNullOrWhiteSpace(pipeNo) &&
|
|
|
|
|
pipePageNo.HasValue &&
|
|
|
|
|
pageNumbersByPipeNo.TryGetValue(pipeNo.Trim(), out var pageNumbers) &&
|
|
|
|
|
pageNumbers.Contains(pipePageNo.Value);
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
public static string HeaderCorrespondence(string uploadUrl, string data, string method, string contenttype)
|
|
|
|
|
{
|
|
|
|
|
// 5. 创建HTTP请求
|
|
|
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uploadUrl);
|
|
|
|
|
request.Method = string.IsNullOrEmpty(method) ? "GET" : method;
|
|
|
|
|
request.ContentType = string.IsNullOrEmpty(contenttype) ? "application/json;charset=utf-8" : contenttype;
|
|
|
|
|
if (uploadUrl.IndexOf("https") >= 0)
|
|
|
|
|
{
|
|
|
|
|
request.ProtocolVersion = HttpVersion.Version10;
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(data))
|
|
|
|
|
{
|
|
|
|
|
Stream RequestStream = request.GetRequestStream();
|
|
|
|
|
byte[] bytes = Encoding.UTF8.GetBytes(data);
|
|
|
|
|
RequestStream.Write(bytes, 0, bytes.Length);
|
|
|
|
|
RequestStream.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpWebResponse response = null;
|
|
|
|
|
Stream ResponseStream = null;
|
|
|
|
|
StreamReader StreamReader = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
response = (HttpWebResponse)request.GetResponse();
|
|
|
|
|
ResponseStream = response.GetResponseStream();
|
|
|
|
|
StreamReader = new StreamReader(ResponseStream, Encoding.GetEncoding("utf-8"));
|
|
|
|
|
|
|
|
|
|
string re = StreamReader.ReadToEnd();
|
|
|
|
|
StreamReader.Close();
|
|
|
|
|
ResponseStream.Close();
|
|
|
|
|
return re;
|
|
|
|
|
}
|
|
|
|
|
catch (WebException ex)
|
|
|
|
|
{
|
|
|
|
|
response = (HttpWebResponse)ex.Response;
|
|
|
|
|
ResponseStream = response.GetResponseStream();
|
|
|
|
|
StreamReader = new StreamReader(ResponseStream, Encoding.GetEncoding("utf-8"));
|
|
|
|
|
|
|
|
|
|
string re = StreamReader.ReadToEnd();
|
|
|
|
|
return re;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (StreamReader != null)
|
|
|
|
|
{
|
|
|
|
|
StreamReader.Close();
|
|
|
|
|
}
|
|
|
|
|
if (ResponseStream != null)
|
|
|
|
|
{
|
|
|
|
|
ResponseStream.Close();
|
|
|
|
|
}
|
|
|
|
|
if (response != null)
|
|
|
|
|
{
|
|
|
|
|
response.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void btnAudit_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(resultdata.Value))
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
try
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
var recognitionResult = DeserializeRecognitionResult();
|
|
|
|
|
var pageRegions = BuildPageRegionMap(recognitionResult.OtherRegions);
|
|
|
|
|
MaterialEntities = MapMaterialEntities(recognitionResult.MaterialRows, pageRegions);
|
|
|
|
|
PipeLengthEntities = MapPipeLengthEntities(recognitionResult.PipeLengthRows, pageRegions);
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("识别结果解析失败:" + ex.Message, MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Grid1.Hidden = false;
|
|
|
|
|
Grid2.Hidden = false;
|
|
|
|
|
contentPanel1.Hidden = true;
|
|
|
|
|
btnAudit.Hidden = true;
|
|
|
|
|
btnSave.Hidden = false;
|
|
|
|
|
BindGrids();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private DrawingRecognitionResult DeserializeRecognitionResult()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(resultdata.Value))
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("识别结果为空");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var recognitionResult = JsonConvert.DeserializeObject<DrawingRecognitionResult>(resultdata.Value);
|
|
|
|
|
if (recognitionResult == null)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("识别结果格式不正确");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recognitionResult.MaterialRows = recognitionResult.MaterialRows ?? new List<DrawingRecognitionMaterialRow>();
|
|
|
|
|
recognitionResult.PipeLengthRows = recognitionResult.PipeLengthRows ?? new List<DrawingRecognitionPipeLengthRow>();
|
|
|
|
|
recognitionResult.OtherRegions = recognitionResult.OtherRegions ?? new List<DrawingRecognitionOtherRegion>();
|
|
|
|
|
recognitionResult.DrawingInfo = recognitionResult.DrawingInfo ?? new List<DrawingRecognitionInfoRow>();
|
|
|
|
|
return recognitionResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 构建原始页码与识别区域的映射,供 C1、C3 等区域统一取值。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static Dictionary<int, Dictionary<string, string>> BuildPageRegionMap(
|
|
|
|
|
IEnumerable<DrawingRecognitionOtherRegion> 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));
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
private static string GetPageRegionValueOrDefault(
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> 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;
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
return value.Trim();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string GetRequiredPageRegionValue(
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取 C1 中的管线页码,并校验其必须为整数。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static int GetRequiredPipePageNo(
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据识别数据的原始页码获取 C3 管线号。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static string GetPipelineCodeByPageNo(
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> pageRegions,
|
|
|
|
|
int? pageNo)
|
|
|
|
|
{
|
|
|
|
|
// 管线号统一通过原始页码匹配 C3,避免各类识别数据重复实现映射逻辑。
|
|
|
|
|
return GetRequiredPageRegionValue(pageRegions, pageNo, "C3");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将材料识别结果映射为待保存的材料实体。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static List<HJGL_DrawingRecognition_Material> MapMaterialEntities(
|
|
|
|
|
IEnumerable<DrawingRecognitionMaterialRow> materialRows,
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> 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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将管段长度识别结果映射为待保存的管段长度实体。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static List<HJGL_DrawingRecognition_PipeLengths> MapPipeLengthEntities(
|
|
|
|
|
IEnumerable<DrawingRecognitionPipeLengthRow> pipeLengthRows,
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按当前项目和管线号新增或更新管线,仅同步 DrawingInfo 中识别到的字段。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private Dictionary<string, HJGL_Pipeline> 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))
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
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);
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
|
|
|
|
|
// 识别结果为空时保留已有值,避免不完整识别覆盖管线原数据。
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(item.Value.PipingClassCode))
|
2026-05-30 10:09:22 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
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;
|
2026-05-30 10:09:22 +08:00
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
|
|
|
|
|
return pipelinesByCode;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 按页码取得管线号后聚合 DrawingInfo,同一管线跨页数据合并处理。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static Dictionary<string, PipelineDrawingData> BuildPipelineDrawingData(
|
|
|
|
|
IEnumerable<DrawingRecognitionInfoRow> drawingInfo,
|
|
|
|
|
Dictionary<int, Dictionary<string, string>> pageRegions)
|
|
|
|
|
{
|
|
|
|
|
// 同一管线可能对应多个 PDF 页,按 C3 管线号分组后统一校验和取值。
|
|
|
|
|
var pipelineGroups = drawingInfo
|
|
|
|
|
.Where(x => x != null)
|
|
|
|
|
.GroupBy(
|
|
|
|
|
x => GetPipelineCodeByPageNo(pageRegions, x.PageNo),
|
|
|
|
|
StringComparer.OrdinalIgnoreCase);
|
|
|
|
|
|
|
|
|
|
var result = new Dictionary<string, PipelineDrawingData>(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;
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 获取管线字段的唯一非空值;跨页识别值不一致时阻止保存。
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static string GetUniqueDrawingFieldValue(
|
|
|
|
|
IEnumerable<DrawingRecognitionInfoRow> rows,
|
|
|
|
|
string pipelineCode,
|
|
|
|
|
string fieldName,
|
|
|
|
|
bool startsWith = false)
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
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)));
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
return values.FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将识别结果中的 PWHT Yes/No 标记转换为是否需要焊后热处理。
|
|
|
|
|
/// </summary>
|
|
|
|
|
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; }
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
public string DesignPress { get; set; }
|
2026-05-27 23:13:02 +08:00
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
public string DesignTemperature { get; set; }
|
|
|
|
|
|
|
|
|
|
public bool? DesignIsHotProess { get; set; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void BindGrids()
|
|
|
|
|
{
|
|
|
|
|
Grid1.DataSource = MaterialEntities ?? new List<HJGL_DrawingRecognition_Material>();
|
|
|
|
|
Grid1.DataBind();
|
|
|
|
|
Grid2.DataSource = PipeLengthEntities ?? new List<HJGL_DrawingRecognition_PipeLengths>();
|
|
|
|
|
Grid2.DataBind();
|
|
|
|
|
}
|
2026-05-27 23:13:02 +08:00
|
|
|
#region 双击事件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Grid行双击事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="e"></param>
|
|
|
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_DataInMenuId, Const.BtnAdd))
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
if (MaterialEntities == null)
|
2026-05-27 23:13:02 +08:00
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
Alert.ShowInTop("实体数据已失效,请重新审核识别结果!", MessageBoxIcon.Warning);
|
|
|
|
|
return;
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
|
2026-07-17 14:36:32 +08:00
|
|
|
string editUrl = string.Format(
|
|
|
|
|
"DrawingRecognitionContentEdit.aspx?Index={0}&DataKey={1}",
|
|
|
|
|
Grid1.SelectedRowIndex,
|
|
|
|
|
RecognitionDataKey);
|
|
|
|
|
PageContext.RegisterStartupScript(
|
|
|
|
|
Window1.GetSaveStateReference(hdIds.ClientID) + Window1.GetShowReference(editUrl));
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
|
|
|
{
|
2026-07-17 14:36:32 +08:00
|
|
|
BindGrids();
|
2026-05-27 23:13:02 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-07-17 14:36:32 +08:00
|
|
|
}
|