feat(hjgl): 完善管线预制与焊接业务

同步管线组件、材料和焊口关联数据,优化预制组件打印及焊接相关查询,减少业务台账与实际关联信息不一致。
This commit is contained in:
2026-09-16 15:49:02 +08:00
parent d090c174b9
commit 7b5b060ffc
13 changed files with 179 additions and 195 deletions
@@ -194,9 +194,6 @@ namespace BLL
from aunit in aunitJoin.DefaultIfEmpty()
join unitwork in db.WBS_UnitWork on pipe.UnitWorkId equals unitwork.UnitWorkId into unitworkJoin
from unitwork in unitworkJoin.DefaultIfEmpty()
join mater in db.Base_Material on pipe.MaterialId equals mater.MaterialId into materJoin
from mater in materJoin.DefaultIfEmpty()
where com.QRCode != ""
orderby com.PipelineComponentCode, com.PipelineId
select new PipelineComponentPrintDto
{
@@ -208,13 +205,10 @@ namespace BLL
PreUnit = punit.UnitName,
AssembleUnit = aunit.UnitName,
PrefabricatedComponents = mat.PrefabricatedComponents,
QRCode = com.QRCode,
State = com.State,
PlanStartDate = string.Format("yyyy-MM-dd", pipe.PlanStartDate),
PipelineCode = pipe.PipelineCode,
FlowingSection = pipe.FlowingSection,
QRCode2 = "PrePipeline$" + com.PipelineComponentId,
MaterialCode = mater.MaterialCode,
IsPrint = com.IsPrint
};
@@ -278,14 +272,15 @@ namespace BLL
return;
}
var model_mat = BLL.PipelineMatService.GetPipeLineMat(pipeLineMatId);
Model.SGGLDB db = Funs.DB;
var model_mat = db.HJGL_PipeLineMat.FirstOrDefault(x => x.PipeLineMatId == pipeLineMatId);
if (model_mat == null || string.IsNullOrEmpty(model_mat.PipelineId))
{
return;
}
var PipelineId = model_mat.PipelineId;
var pipelineModel = BLL.PipelineService.GetPipelineByPipelineId(PipelineId);
var pipelineModel = db.HJGL_Pipeline.FirstOrDefault(x => x.PipelineId == PipelineId);
if (pipelineModel == null)
{
return;
@@ -294,37 +289,64 @@ namespace BLL
var PipeArea = pipelineModel.PipeArea;
if (PipeArea == PipelineService.PipeArea_SHOP && !string.IsNullOrEmpty(model_mat.PrefabricatedComponents))
{
// var model = GetPipelineComponentByMatId(pipeLineMatId);
var model = GetPipelineComponentByCodeandpipelineId(model_mat.PrefabricatedComponents, PipelineId);
var model = db.HJGL_Pipeline_Component.FirstOrDefault(x => x.PipelineComponentCode == model_mat.PrefabricatedComponents
&& x.PipelineId == PipelineId);
// 组件号可能来自导入数据,未包含分隔符时直接使用原值,避免截取时报错。
var drawingName = GetDrawingNameByComponentCode(model_mat.PrefabricatedComponents);
if (model != null)
if (model == null)
{
model.PipelineId = PipelineId;
model.PipelineComponentCode = model_mat.PrefabricatedComponents;
model.DrawingName = drawingName;
model.State = State0;
model.ProductionState = 0;
UpdatePipelineComponent(model);
}
else
{
model = new Model.HJGL_Pipeline_Component();
model.PipelineComponentId = SQLHelper.GetNewID();
model.PipelineId = PipelineId;
model.PipelineComponentCode = model_mat.PrefabricatedComponents;
model.DrawingName = drawingName;
model.State = State0;
model.ProductionState = 0;
model.IsPrint = false;
AddPipelineComponent(model);
model = new Model.HJGL_Pipeline_Component
{
PipelineComponentId = SQLHelper.GetNewID(),
IsPrint = false
};
db.HJGL_Pipeline_Component.InsertOnSubmit(model);
}
model.PipelineId = PipelineId;
model.PipelineComponentCode = model_mat.PrefabricatedComponents;
model.DrawingName = drawingName;
model.State = State0;
model.ProductionState = 0;
// 材料导入同步组件时,同时按焊口幂等维护组件关联,避免只生成组件主数据。
SyncPipelineComponentJoint(db, model, model_mat.WeldJointId);
db.SubmitChanges();
}
}
/// <summary>
/// 按焊口同步预制组件关联。
/// </summary>
private static void SyncPipelineComponentJoint(Model.SGGLDB db, Model.HJGL_Pipeline_Component pipelineComponent, string weldJointId)
{
if (pipelineComponent == null || string.IsNullOrEmpty(weldJointId))
{
return;
}
var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId);
if (weldJoint == null)
{
return;
}
var componentJoint = db.HJGL_Pipeline_ComponentJoint.FirstOrDefault(x => x.WeldJointId == weldJointId);
if (componentJoint == null)
{
componentJoint = new Model.HJGL_Pipeline_ComponentJoint
{
Id = SQLHelper.GetNewID(),
WeldJointId = weldJoint.WeldJointId,
State = State0
};
db.HJGL_Pipeline_ComponentJoint.InsertOnSubmit(componentJoint);
}
// 已存在的关联保留生产状态,只刷新组件及焊口标识。
componentJoint.PipelineComponentId = pipelineComponent.PipelineComponentId;
componentJoint.PipelineComponentCode = pipelineComponent.PipelineComponentCode;
componentJoint.WeldJointCode = weldJoint.WeldJointCode;
}
private static string GetDrawingNameByComponentCode(string pipelineComponentCode)
@@ -371,6 +393,53 @@ namespace BLL
db.SubmitChanges();
}
/// <summary>
/// 修改管线预制组件基础信息,并同步材料及焊口关联中的组件编号。
/// </summary>
public static void UpdatePipelineComponentBasicInfo(Model.HJGL_Pipeline_Component pipeline)
{
if (pipeline == null || string.IsNullOrEmpty(pipeline.PipelineComponentId))
{
return;
}
Model.SGGLDB db = Funs.DB;
var current = db.HJGL_Pipeline_Component.FirstOrDefault(e => e.PipelineComponentId == pipeline.PipelineComponentId);
if (current == null)
{
return;
}
string oldPipelineComponentCode = current.PipelineComponentCode;
current.PipelineId = pipeline.PipelineId;
current.PreUnit = pipeline.PreUnit;
current.AssembleUnit = pipeline.AssembleUnit;
current.PipelineComponentCode = pipeline.PipelineComponentCode;
current.BoxNumber = pipeline.BoxNumber;
if (!string.Equals(oldPipelineComponentCode, pipeline.PipelineComponentCode, StringComparison.Ordinal))
{
// 组件编号是材料和组件焊口关联的逻辑键,编辑时必须同步更新。
if (!string.IsNullOrEmpty(oldPipelineComponentCode))
{
var pipelineMaterials = db.HJGL_PipeLineMat.Where(x => x.PipelineId == current.PipelineId
&& x.PrefabricatedComponents == oldPipelineComponentCode);
foreach (var pipelineMaterial in pipelineMaterials)
{
pipelineMaterial.PrefabricatedComponents = pipeline.PipelineComponentCode;
}
}
var componentJoints = db.HJGL_Pipeline_ComponentJoint.Where(x => x.PipelineComponentId == current.PipelineComponentId);
foreach (var componentJoint in componentJoints)
{
componentJoint.PipelineComponentCode = pipeline.PipelineComponentCode;
}
}
db.SubmitChanges();
}
/// <summary>
/// 修改管线预制组件
/// </summary>
@@ -507,10 +576,14 @@ namespace BLL
public static void DeletePipelineComponentBypipelineId(string pipelineId)
{
Model.SGGLDB db = Funs.DB;
var mdoel = db.HJGL_Pipeline_Component.Where(e => e.PipelineId == pipelineId);
if (mdoel != null)
var components = db.HJGL_Pipeline_Component.Where(e => e.PipelineId == pipelineId).ToList();
if (components.Count > 0)
{
db.HJGL_Pipeline_Component.DeleteAllOnSubmit(mdoel);
// 更新导入会重建管线组件,先清理旧组件焊口关联,避免遗留孤儿数据。
var componentIds = components.Select(x => x.PipelineComponentId).ToArray();
var componentJoints = db.HJGL_Pipeline_ComponentJoint.Where(x => componentIds.Contains(x.PipelineComponentId));
db.HJGL_Pipeline_ComponentJoint.DeleteAllOnSubmit(componentJoints);
db.HJGL_Pipeline_Component.DeleteAllOnSubmit(components);
db.SubmitChanges();
}
}
@@ -6,6 +6,42 @@ namespace BLL
public static class PipelineMatService
{
/// <summary>
/// 按焊口编号顺序,先左后右校准零数量材料的主编码。
/// </summary>
public static int CalibrateSharedMaterialCodes(string pipelineId)
{
Model.SGGLDB db = Funs.DB;
var materials = db.HJGL_PipeLineMat.Where(x => x.PipelineId == pipelineId).ToList();
var joints = db.HJGL_WeldJoint.Where(x => x.PipelineId == pipelineId)
.OrderBy(x => x.WeldJointCode).ToList();
int count = 0;
foreach (var material in materials.Where(x => x.Number == 0m))
{
int jointIndex = joints.FindIndex(x => x.WeldJointId == material.WeldJointId);
HJGL_PipeLineMat source = null;
if (jointIndex > 0)
{
source = materials.FirstOrDefault(x => x.WeldJointId == joints[jointIndex - 1].WeldJointId
&& x.MaterialCode2 == material.MaterialCode2 && x.MaterialCode != null);
}
if (source == null && jointIndex < joints.Count - 1)
{
source = materials.FirstOrDefault(x => x.WeldJointId == joints[jointIndex + 1].WeldJointId
&& x.MaterialCode2 == material.MaterialCode2 && x.MaterialCode != null);
}
if (source != null)
{
material.MaterialCode = source.MaterialCode;
count++;
}
}
db.SubmitChanges();
return count;
}
/// <summary>
///获取管线材料信息
/// </summary>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+7 -5
View File
@@ -312,11 +312,13 @@ namespace FineUIPro.Web.HJGL.NDT
}
foreach (var trust in trusts)
{
string code = string.Empty;
Model.HJGL_Batch_PointBatch batch = BLL.PointBatchService.GetPointBatchById(trust.PointBatchId);
var pointBatch = PointBatchService.GetPointBatchById(batch.PointBatchId);
code = "DK-" + pointBatch.PointBatchCode.Substring(pointBatch.PointBatchCode.Length - 4) + "【" + string.Format("{0:yyyy-MM-dd}", pointBatch.StartDate) + "】" + "【" + UnitService.GetUnitNameByUnitId(pointBatch.UnitId) + "】";
string code = trust.TrustBatchCode;
Model.HJGL_Batch_PointBatch batch = null;
if (this.Type != "R")
{
batch = BLL.PointBatchService.GetPointBatchById(trust.PointBatchId);
code = "DK-" + batch.PointBatchCode.Substring(batch.PointBatchCode.Length - 4) + "【" + string.Format("{0:yyyy-MM-dd}", batch.StartDate) + "】" + "【" + UnitService.GetUnitNameByUnitId(batch.UnitId) + "】";
}
TreeNode newNode = new TreeNode();
//string code = trust.TrustBatchCode;
// 未检测委托红色显示
@@ -646,13 +646,13 @@ namespace FineUIPro.Web.HJGL.PointTrust
DataRow dr = dt.NewRow();
if (this.tvControlItem.SelectedNode == null)
if (string.IsNullOrEmpty(this.tvControlItem.SelectedNodeID))
{
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
return;
}
string reportId = this.tvControlItem.SelectedNode.NodeID;
var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewByPointBatchId(reportId);
string reportId = this.tvControlItem.SelectedNodeID;
var trust = BLL.Batch_BatchTrustService.GetBatchTrustViewById(reportId);
if (trust == null)
{
Alert.ShowInTop("请选择要打印的委托单!", MessageBoxIcon.Warning);
@@ -61,10 +61,6 @@
<f:DropDownList ID="drpWeldingDailyCode" Label="日报编号" runat="server" AutoSelectFirstItem="true"
ShowRedStar="true" Required="true" EnableEdit="true" LabelWidth="100px">
</f:DropDownList>
<f:DropDownList ID="drpFlowingSection" Label="流水段" AutoPostBack="true"
runat="server" LabelWidth="80px"
Width="180px" LabelAlign="Left">
</f:DropDownList>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
<f:Button ID="btnNew" Text="新增" Icon="Add" runat="server" OnClick="btnNew_Click" Hidden="true">
@@ -86,8 +82,6 @@
</f:Button>
<f:Button ID="btnAccept" Text="验收" ToolTip="验收" Icon="Accept" runat="server" OnClick="btnAccept_Click">
</f:Button>
<f:Button ID="btnImportQRCode" Text="导入二维码信息" ToolTip="导入二维码信息" Icon="PackageIn" runat="server" OnClick="btnImportQRCode_Click">
</f:Button>
<f:Button ID="btnImportComponentJoint" Text="导入组件焊口信息" ToolTip="导入组件焊口信息" Icon="PackageIn" runat="server" OnClick="btnImportComponentJoint_Click">
</f:Button>
<f:Button ID="btnBatchAdd" Text="批量增加" Icon="TableAdd" Hidden="true"
@@ -145,13 +139,6 @@
HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<%-- <f:TemplateField ColumnID="tfImageUrl1" Width="180px" HeaderText="组件二维码" HeaderTextAlign="Center"
TextAlign="Left">
<ItemTemplate>
<asp:Label ID="lbImageUrl" runat="server" Text='<%# ConvertImageUrlByImage(Eval("QRCode"),Eval("PipelineComponentId")) %>'></asp:Label>
</ItemTemplate>
</f:TemplateField>--%>
<f:LinkButtonField Width="100px" TextAlign="Center" CommandName="PreviewQRCode" Text="二维码" EnableAjax="false" />
<f:RenderField Width="200px" ColumnID="DrawingName" DataField="DrawingName" SortField="DrawingName"
FieldType="String" HeaderText="预制图纸名称" HeaderTextAlign="Center"
TextAlign="Left">
@@ -166,7 +153,7 @@
FieldType="String" HeaderText="备注" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:LinkButtonField Width="120px" TextAlign="Center" CommandName="cmd_print" Text="预览打印" />
<f:LinkButtonField Width="120px" TextAlign="Center" CommandName="cmd_print" Text="预览打印" EnableAjax="false" />
</Columns>
<PageItems>
@@ -24,14 +24,6 @@ namespace FineUIPro.Web.HJGL.PreDesign
HJGL_PipelineComponentService.InitMainItemDownList(drpState, true);
HJGL_PipelineComponentService.InitMainItemDownProductionStateList(drpProductionState, true);
var pipeline = (from x in Funs.DB.HJGL_Pipeline
where x.ProjectId == this.CurrUser.LoginProjectId
select x.FlowingSection).Distinct().ToList();
this.drpFlowingSection.DataTextField = "Value";
this.drpFlowingSection.DataValueField = "Value";
this.drpFlowingSection.DataSource = pipeline;
this.drpFlowingSection.DataBind();
Funs.FineUIPleaseSelect(drpFlowingSection);
}
}
@@ -298,7 +290,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
if (tvControlItem.SelectedNode == null) return;
string strSql = @" SELECT distinct com.PipelineComponentId,com.PipelineComponentCode,com.BoxNumber,com.Remark,
com.PipelineId, punit.UnitName AS PreUnit,aunit.UnitName AS AssembleUnit,com.IsPrint,
com.QRCode,com.State,com.ProductionState,pipe.PlanStartDate,pipe.FlowingSection,com.DrawingName,com.ReceiveDate,
com.State,com.ProductionState,pipe.PlanStartDate,pipe.FlowingSection,com.DrawingName,com.ReceiveDate,
person.PersonName
FROM HJGL_Pipeline_Component com
LEFT JOIN HJGL_Pipeline pipe ON pipe.PipelineId =com.PipelineId
@@ -352,11 +344,6 @@ namespace FineUIPro.Web.HJGL.PreDesign
listStr.Add(new SqlParameter("@ProductionState", drpProductionState.SelectedValue.ToString()));
}
if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.SelectedValue != Const._Null)
{
strSql += " AND pipe.FlowingSection =@FlowingSection";
listStr.Add(new SqlParameter("@FlowingSection", drpFlowingSection.SelectedValue.ToString()));
}
// 过滤组件编号值为"裕-量"的行
strSql += " AND com.PipelineComponentCode != @ExcludeYuliang";
listStr.Add(new SqlParameter("@ExcludeYuliang", "裕-量"));
@@ -448,7 +435,7 @@ if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.
}
else
{
ShowNotify("请查看组件是否上传二维码!", MessageBoxIcon.Question);
ShowNotify("未找到可打印的组件!", MessageBoxIcon.Question);
return false;
}
BLL.FastReportService.AddFastreportTable(tb);
@@ -459,7 +446,11 @@ if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.
if (File.Exists(rootPath + initTemplatePath))
{
PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("~/Controls/Fastreport.aspx?ReportPath={0}", rootPath + initTemplatePath)));
}
else
{
ShowNotify("打印模板不存在!", MessageBoxIcon.Warning);
return false;
}
return true;
@@ -549,24 +540,11 @@ if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
{
if (e.CommandName == "PreviewQRCode")
if (e.CommandName == "cmd_print")
{
var ID = e.RowID;
var q = HJGL_PipelineComponentService.GetPipelineComponentById(ID);
string path = "";
if (!string.IsNullOrEmpty(q.QRCode))
{
path = BLL.CreateQRCodeService.CreateCode_Simple(q.QRCode, ID);
if (!string.IsNullOrEmpty(path))
{
string filepath = Funs.SGGLUrl + path.Replace("\\", "//");
ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script type='text/javascript'>window.open('" + filepath + "');</script>");
}
}
string[] pipelineComponentIds = { e.RowID };
Print(pipelineComponentIds);
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
@@ -603,22 +581,6 @@ if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.
}
#endregion
/// <summary>
/// 搜索
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public string ConvertImageUrlByImage(object str, object id)
{
string path = string.Empty;
if (!string.IsNullOrEmpty(str.ToString()))
{
path = BLL.CreateQRCodeService.CreateCode_Simple(str.ToString(), id.ToString());
path = HttpUtility.HtmlDecode(BLL.UploadAttachmentService.ShowImage("../../", path));
}
return path;
}
public string ConvertState(object state)
{
string StateName = string.Empty;
@@ -650,12 +612,6 @@ if (!string.IsNullOrEmpty(drpFlowingSection.SelectedValue) && drpFlowingSection.
return StateName;
}
protected void btnImportQRCode_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("PrePipelineQRCodeIn.aspx?", "导入 - ")));
}
protected void btnImportComponentJoint_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("PrePipelineComponentJointIn.aspx?", "导入 - ")));
@@ -149,15 +149,6 @@ namespace FineUIPro.Web.HJGL.PreDesign
/// </remarks>
protected global::FineUIPro.DropDownList drpWeldingDailyCode;
/// <summary>
/// drpFlowingSection 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DropDownList drpFlowingSection;
/// <summary>
/// ToolbarFill1 控件。
/// </summary>
@@ -230,15 +221,6 @@ namespace FineUIPro.Web.HJGL.PreDesign
/// </remarks>
protected global::FineUIPro.Button btnAccept;
/// <summary>
/// btnImportQRCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnImportQRCode;
/// <summary>
/// btnImportComponentJoint 控件。
/// </summary>
@@ -78,7 +78,7 @@ namespace FineUIPro.Web.HJGL.PreDesign
if (!string.IsNullOrEmpty(Request.Params["PipelineComponentId"]))
{
pipeline.PipelineComponentId = Request.Params["PipelineComponentId"];
BLL.HJGL_PipelineComponentService.UpdatePipelineComponent(pipeline);
BLL.HJGL_PipelineComponentService.UpdatePipelineComponentBasicInfo(pipeline);
}
else
{
@@ -98,4 +98,4 @@ namespace FineUIPro.Web.HJGL.PreDesign
}
}
}
}
}
@@ -90,12 +90,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
{
Alert.ShowInTop("请选择检测编号!", MessageBoxIcon.Warning);
return;
}
if (!HasPower(Const.BtnPrint))
{
return;
}
}
var printResult = WeldAppearanceCheckService.GetList(CurrUser.LoginProjectId, checkCode,
txtPipelineCode.Text.Trim(), txtWeldJointCode.Text.Trim(), ddlQualified.SelectedValue,
0, int.MaxValue);
@@ -884,7 +884,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
protected void btnPendingTeamAudit_Click(object sender, EventArgs e)
{
if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId,
Const.HJGL_WeldReportMenuId, Const.BtnAuditing))
Const.HJGL_WeldReportMenuId, Const.BtnModify))
{
ShowNotify("您没有审核权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
@@ -913,7 +913,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
protected void btnPendingProfessionalAudit_Click(object sender, EventArgs e)
{
if (!CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId,
Const.HJGL_WeldReportMenuId, Const.BtnAuditing))
Const.HJGL_WeldReportMenuId, Const.BtnModify))
{
ShowNotify("您没有审核权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
@@ -10,13 +10,10 @@
public string PreUnit { get; set; }
public string AssembleUnit { get; set; }
public string PrefabricatedComponents { get; set; }
public string QRCode { get; set; }
public int? State { get; set; }
public string PlanStartDate { get; set; }
public string PipelineCode { get; set; }
public string FlowingSection { get; set; }
public string QRCode2 { get; set; }
public string MaterialCode { get; set; }
public bool? IsPrint { get; set; }
}