feat(hjgl): 增强焊口匹配与任务单打印

焊口台账、材料匹配和任务单打印需要统一到焊口维度处理。
新增焊口查询、匹配保存和打印模板适配,便于按焊口追溯材料和任务。
This commit is contained in:
2026-06-26 00:40:55 +08:00
parent bd9b5a6f4d
commit 02b524b895
14 changed files with 836 additions and 121 deletions
@@ -1533,33 +1533,64 @@ namespace FineUIPro.Web.HJGL.WeldingManage
// 添加列
dataTable.Columns.Add("PipelineCode", typeof(string));
dataTable.Columns.Add("FlowingSection", typeof(string));
dataTable.Columns.Add("WeldJointCode", typeof(string));
dataTable.Columns.Add("MaterialCode", typeof(string));
dataTable.Columns.Add("BatchNo", typeof(string));
dataTable.Columns.Add("NeedNum", typeof(string));
dataTable.Columns.Add("MaterialMade", typeof(string));
dataTable.Columns.Add("MaterialSpec", typeof(string));
dataTable.Columns.Add("MatchRate", typeof(string));
dataTable.Columns.Add("Dia", typeof(string));
dataTable.Columns.Add("PaintCode", typeof(string));
dataTable.Columns.Add("WeldingSize", typeof(string));
dataTable.Columns.Add("Remark", typeof(string));
foreach (string pipeline in pipelines)
var taskWeldJointIds = weldTaskList.Where(x => !string.IsNullOrEmpty(x.WeldJointId))
.Select(x => x.WeldJointId).Distinct().ToList();
var pipelineList = Funs.DB.HJGL_Pipeline.Where(x => pipelines.Contains(x.PipelineId)).ToList();
var printMaterials = (from x in Funs.DB.HJGL_PipeLineMat
join y in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
where pipelines.Contains(x.PipelineId)
&& taskWeldJointIds.Contains(x.WeldJointId)
&& x.PrefabricatedComponents != null
select new
{
x.PipelineId,
x.WeldJointId,
x.MaterialCode,
x.Number,
y.Code,
y.HeatNo,
y.BatchNo,
y.MaterialMade,
y.MaterialSpec
}).ToList();
var sortedTaskList = weldTaskList.OrderBy(x => x.PipeLineSortIndex).ThenBy(x => x.WeldJointCode).ToList();
foreach (var task in sortedTaskList)
{
DataRow dr = dataTable.NewRow();
var pipelineModel = PipelineService.GetPipelineByPipelineId(pipeline);
if (pipelineModel == null)
var taskMaterials = printMaterials.Where(x => x.WeldJointId == task.WeldJointId)
.OrderBy(x => x.Code).ToList();
if (!taskMaterials.Any())
{
continue;
taskMaterials.Add(null);
}
dr["PipelineCode"] = pipelineModel.PipelineCode;
dr["FlowingSection"] = pipelineModel.FlowingSection;
// 管线基础资料可能未维护材质,打印时保留空值,避免整张任务单打印失败。
var materialModel = string.IsNullOrEmpty(pipelineModel.MaterialId) ? null : Base_MaterialService.GetMaterialByMaterialId(pipelineModel.MaterialId);
dr["MaterialCode"] = materialModel?.MaterialCode ?? string.Empty;
dr["MaterialSpec"] = string.Join(",", weldTaskList.Select(x => x.Specification).Distinct().ToList());
// 匹配率计算依赖管线仓库,未维护仓库时按0显示,避免基础资料缺项阻断打印。
var warehouseModel = string.IsNullOrEmpty(pipelineModel.WarehouseId) ? null : Base_WarehouseService.GetWarehouseByWarehouseId(pipelineModel.WarehouseId);
var matchRate = warehouseModel == null ? 0 : TwArrivalStatisticsService.GetPipeMatch(pipeline) ?? 0;
dr["MatchRate"] = Math.Round(matchRate * 100, 2).ToString() + "%";
dr["Dia"] = weldTaskList.Where(x => x.PipelineId == pipeline).Sum(x => x.Size ?? 0)
.ToString();
dataTable.Rows.Add(dr);
foreach (var material in taskMaterials)
{
DataRow dr = dataTable.NewRow();
dr["PipelineCode"] = task.PipelineCode;
dr["FlowingSection"] = pipelineList.FirstOrDefault(x => x.PipelineId == task.PipelineId)?.FlowingSection ?? string.Empty;
dr["WeldJointCode"] = !string.IsNullOrEmpty(task.PipelineCode) ? task.WeldJointCode.Replace(task.PipelineCode + "/", "") : task.WeldJointCode;
dr["MaterialCode"] = material?.Code ?? material?.MaterialCode ?? string.Empty;
dr["BatchNo"] = material == null ? string.Empty : string.Join("/", new[] { material.HeatNo, material.BatchNo }.Where(x => !string.IsNullOrEmpty(x)));
dr["NeedNum"] = material?.Number != null ? material.Number.Value.ToString("0.##") : string.Empty;
dr["MaterialMade"] = material?.MaterialMade ?? string.Empty;
dr["MaterialSpec"] = material?.MaterialSpec ?? string.Empty;
// 当前焊接任务单取数链路未维护油漆号,先输出空列,避免模板字段缺失。
dr["PaintCode"] = string.Empty;
dr["WeldingSize"] = task.Size.HasValue ? task.Size.Value.ToString("0.##") : string.Empty;
dr["Remark"] = string.Empty;
dataTable.Rows.Add(dr);
}
}
BLL.FastReportService.AddFastreportTable(Table1);
BLL.FastReportService.AddFastreportTable(dataTable);