Files
SGGL_SHJ/SGGL/FineUIPro.Web/HJGL/JoinMarking/PDFMarking.aspx.cs
T
lpf 7fb6b255d2 feat(hjgl): 完善图纸识别与材料管段信息管理
扩展图纸识别结果模型和保存流程,按管线及页码替换识别明细,
避免重复导入造成数据累积;同时自动补充材料编码库数据,
新增材料总览、管段长度总览及 PDF 焊口标记功能,提升识别数据
的查询、复核和后续使用效率。
2026-07-17 14:36:32 +08:00

334 lines
16 KiB
C#

using BLL;
using BLL.Common;
using FineUIPro.Web.HJGL.WeldingManage;
using Newtonsoft.Json.Linq;
using NPOI.POIFS.Properties;
using Org.BouncyCastle.Asn1.Tsp;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.Data.SqlClient;
using System.IO;
using System.Linq;
using System.Threading;
namespace FineUIPro.Web.HJGL.JoinMarking
{
public partial class PDFMarking : PageBase
{
public static Dictionary<string, List<Model.HJGL_WeldJoint>> WeldJointlist = new Dictionary<string, List<Model.HJGL_WeldJoint>>();
private string ISO_ID
{
get
{
return (string)ViewState["ISO_ID"];
}
set
{
ViewState["ISO_ID"] = value;
}
}
private string FileId
{
get
{
return (string)ViewState["FileId"];
}
set
{
ViewState["FileId"] = value;
}
}
public string URL
{
get
{
return (string)ViewState["URL"];
}
set
{
ViewState["URL"] = value;
}
}
#region
/// <summary>
/// 是否PDMS
/// </summary>
private string IsPDMS
{
get
{
return (string)ViewState["IsPDMS"];
}
set
{
ViewState["IsPDMS"] = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ISO_ID = Request.Params["ISO_ID"];
FileId = Request.Params["FileId"];
URL = Funs.SGGLUrl + Request.Params["pdfurl"];
//hdjoinInfo.Value = "{\r\n \"version\": \"1.0\",\r\n \"exportDate\": \"2026-07-14T08:14:00.657Z\",\r\n \"sourceFile\": \"12026071310111.pdf\",\r\n \"globalSettings\": {\r\n \"startNumber\": 1,\r\n \"increment\": 1,\r\n \"prefix\": \"\",\r\n \"suffix\": \"\",\r\n \"fontSize\": 10,\r\n \"borderStyle\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n \"annotations\": {\r\n \"1\": [\r\n {\r\n \"x\": 383.8159484863281,\r\n \"y\": 306.50694274902344,\r\n \"x2\": 333.8159484863281,\r\n \"y2\": 356.50694274902344,\r\n \"displayValue\": 1,\r\n \"label\": \"1\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n {\r\n \"x\": 424.8159484863281,\r\n \"y\": 324.50694274902344,\r\n \"x2\": 374.8159484863281,\r\n \"y2\": 374.50694274902344,\r\n \"displayValue\": 2,\r\n \"label\": \"2\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n {\r\n \"x\": 483.8159484863281,\r\n \"y\": 358.50694274902344,\r\n \"x2\": 433.8159484863281,\r\n \"y2\": 408.50694274902344,\r\n \"displayValue\": 3,\r\n \"label\": \"3\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n }\r\n ]\r\n }\r\n}";
//hdworkRecord.Value = "{\r\n \"version\": \"1.0\",\r\n \"exportDate\": \"2026-07-14T08:14:00.657Z\",\r\n \"sourceFile\": \"12026071310111.pdf\",\r\n \"globalSettings\": {\r\n \"startNumber\": 1,\r\n \"increment\": 1,\r\n \"prefix\": \"\",\r\n \"suffix\": \"\",\r\n \"fontSize\": 10,\r\n \"borderStyle\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n \"annotations\": {\r\n \"1\": [\r\n {\r\n \"x\": 383.8159484863281,\r\n \"y\": 306.50694274902344,\r\n \"x2\": 333.8159484863281,\r\n \"y2\": 356.50694274902344,\r\n \"displayValue\": 1,\r\n \"label\": \"1\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n {\r\n \"x\": 424.8159484863281,\r\n \"y\": 324.50694274902344,\r\n \"x2\": 374.8159484863281,\r\n \"y2\": 374.50694274902344,\r\n \"displayValue\": 2,\r\n \"label\": \"2\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n {\r\n \"x\": 483.8159484863281,\r\n \"y\": 358.50694274902344,\r\n \"x2\": 433.8159484863281,\r\n \"y2\": 408.50694274902344,\r\n \"displayValue\": 3,\r\n \"label\": \"3\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n }\r\n ]\r\n }\r\n}";
//annotionData.Value = "{\r\n \"version\": \"1.0\",\r\n \"exportDate\": \"2026-07-14T08:14:00.657Z\",\r\n \"sourceFile\": \"12026071310111.pdf\",\r\n \"globalSettings\": {\r\n \"startNumber\": 1,\r\n \"increment\": 1,\r\n \"prefix\": \"\",\r\n \"suffix\": \"\",\r\n \"fontSize\": 10,\r\n \"borderStyle\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n \"annotations\": {\r\n \"1\": [\r\n {\r\n \"x\": 383.8159484863281,\r\n \"y\": 306.50694274902344,\r\n \"x2\": 333.8159484863281,\r\n \"y2\": 356.50694274902344,\r\n \"displayValue\": 1,\r\n \"label\": \"1\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n {\r\n \"x\": 424.8159484863281,\r\n \"y\": 324.50694274902344,\r\n \"x2\": 374.8159484863281,\r\n \"y2\": 374.50694274902344,\r\n \"displayValue\": 2,\r\n \"label\": \"2\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n },\r\n {\r\n \"x\": 483.8159484863281,\r\n \"y\": 358.50694274902344,\r\n \"x2\": 433.8159484863281,\r\n \"y2\": 408.50694274902344,\r\n \"displayValue\": 3,\r\n \"label\": \"3\",\r\n \"style\": \"none\",\r\n \"annotationStyle\": \"circle-outline\"\r\n }\r\n ]\r\n }\r\n}";
this.IsPDMS = "0";
if (!WeldJointlist.ContainsKey(CurrUser.PersonId))
{
WeldJointlist.Add(CurrUser.PersonId, new List<Model.HJGL_WeldJoint>());
}
else
{
WeldJointlist[ CurrUser.PersonId]= new List<Model.HJGL_WeldJoint>();
}
}
}
#region
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
if (WeldJointlist.ContainsKey(CurrUser.PersonId))
{
Grid1.RecordCount = WeldJointlist[CurrUser.PersonId].Count;
Grid1.DataSource = WeldJointlist[CurrUser.PersonId];
}
else
{
Grid1.RecordCount = 0;
Grid1.DataSource = null;
}
Grid1.DataBind();
}
#endregion
#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.BtnIn))
{
DataInEdit.dic[Grid1.SelectedRowID] = WeldJointlist[CurrUser.PersonId].FirstOrDefault(x => x.WeldJointId == Grid1.SelectedRowID);
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?WeldJointId={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 导入信息编辑
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.HJGL_DataInMenuId, BLL.Const.BtnIn))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录", MessageBoxIcon.Warning);
return;
}
DataInEdit.dic[Grid1.SelectedRowID] = WeldJointlist[CurrUser.PersonId].FirstOrDefault(x=>x.WeldJointId == Grid1.SelectedRowID);
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("DataInEdit.aspx?WeldJointId={0}", Grid1.SelectedRowID, "维护 - ")));
}
else
{
ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 删除按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_DataInMenuId, Const.BtnIn))
{
if (Grid1.SelectedRowIndexArray.Length == 0)
{
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
return;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
var WeldJoint = WeldJointlist[CurrUser.PersonId].FirstOrDefault(x => x.WeldJointId == rowID);
WeldJointlist[CurrUser.PersonId].Remove(WeldJoint);
}
ShowNotify("删除成功!", MessageBoxIcon.Success);
this.BindGrid();
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
/// <summary>
/// 分页
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 保存审核事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
btnSaveMethod(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, this.IsPDMS);
this.BindGrid();
}
protected void btnRefresh_Click(object sender, EventArgs e)
{
this.BindGrid();
}
protected void btnSaveMethod(string LoginProjectId, string UserId, string IsPDMS)
{
//beginProgress();
Funs.DB.HJGL_WeldJoint.InsertAllOnSubmit(WeldJointlist[CurrUser.PersonId]);
Funs.DB.SubmitChanges();
WeldJointlist.Remove(CurrUser.PersonId);
}
#endregion
protected void btnNext_Click(object sender, EventArgs e)
{
btnImport.Hidden = false;
Grid1.Hidden = false;
contentPanel.Hidden = true;
btnNext.Hidden = true;
btnClear.Hidden = false;
var json = hdworkRecord.Value;
if (json != "{}")
{
var jsonObc = JObject.Parse(json);
var jsonArray = jsonObc.Value<JObject>("annotations").Value<JArray>("1");
var iso = Funs.DB.HJGL_Pipeline.FirstOrDefault(x => x.PipelineId == ISO_ID);
if (iso != null)
{
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitId == iso.UnitId);
WeldJointlist[CurrUser.PersonId] = new List<Model.HJGL_WeldJoint>();
for (int i = 0; i < jsonArray.Count; i++)
{
JObject item = jsonArray[i] as JObject;
Model.HJGL_WeldJoint newDataInTemp = new Model.HJGL_WeldJoint();
newDataInTemp.WeldJointId = SQLHelper.GetNewID(typeof(Model.HJGL_WeldJoint));
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
newDataInTemp.PipelineId = iso.PipelineId;
newDataInTemp.PipelineCode = iso.PipelineCode;
newDataInTemp.WeldJointCode = item.Value<string>("label");
newDataInTemp.X = item.Value<string>("x");
newDataInTemp.Y = item.Value<string>("y");
newDataInTemp.X2 = item.Value<string>("x2");
newDataInTemp.Y2 = item.Value<string>("y2");
newDataInTemp.AttachSourceId = FileId;
newDataInTemp.WeldingMode = "手动";
WeldJointlist[CurrUser.PersonId].Add(newDataInTemp);
}
}
}
BindGrid();
}
public static string ConvertMaterial(object MaterialId)
{
if (MaterialId != null)
{
var material = Funs.DB.Base_Material.FirstOrDefault(x => x.MaterialId == MaterialId.ToString());
if (material != null)
{
return material.MaterialCode;
}
}
return null;
}
public static string ConvertWeldType(object WeldTypeId)
{
if (WeldTypeId != null)
{
var weldType = Funs.DB.Base_WeldType.FirstOrDefault(x => x.WeldTypeId == WeldTypeId.ToString());
if (weldType != null)
{
return weldType.WeldTypeCode;
}
}
return null;
}
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
BindGrid();
}
protected void btnClear_Click(object sender, EventArgs e)
{ ////先删除临时表中 该人员以前导入的数据
WeldJointlist.Clear();
this.BindGrid();
ShowNotify("删除成功!", MessageBoxIcon.Success);
}
}
}