feat(hjgl): 完善检测结果导入与焊接质量管理

通过批量导入、标准化打印和材料导出,减少检测结果及材料信息的人工整理,确保检测单、委托状态和焊口质量资料保持一致。
This commit is contained in:
2026-08-21 15:22:24 +08:00
parent 42787c1520
commit fdaf615194
20 changed files with 1236 additions and 171 deletions
@@ -13,6 +13,7 @@ namespace BLL
/// 分页查询焊缝外观检测记录。
/// </summary>
/// <param name="projectId">项目ID。</param>
/// <param name="checkCode">检测编号。</param>
/// <param name="pipelineCode">管线号查询条件。</param>
/// <param name="weldJointCode">焊口号查询条件。</param>
/// <param name="qualified">合格状态,1为合格,0为不合格,空为全部。</param>
@@ -20,7 +21,7 @@ namespace BLL
/// <param name="pageSize">每页记录数。</param>
/// <returns>外观检测记录及总记录数。</returns>
public static Tuple<List<Model.WeldAppearanceCheckItem>, int> GetList(string projectId,
string pipelineCode, string weldJointCode, string qualified, int pageIndex, int pageSize)
string checkCode, string pipelineCode, string weldJointCode, string qualified, int pageIndex, int pageSize)
{
var db = Funs.DB;
var query = from c in db.HJGL_WeldAppearanceCheck
@@ -30,6 +31,10 @@ namespace BLL
where string.IsNullOrEmpty(projectId) || c.ProjectId == projectId
select new { c, w, CheckPersonName = p == null ? string.Empty : p.PersonName };
if (!string.IsNullOrWhiteSpace(checkCode))
{
query = query.Where(x => x.c.CheckCode == checkCode);
}
if (!string.IsNullOrWhiteSpace(pipelineCode))
{
query = query.Where(x => x.w.PipelineCode.Contains(pipelineCode));
@@ -71,10 +76,93 @@ namespace BLL
InterpassTemperature = x.c.InterpassTemperature,
CreateTime = x.c.CreateTime
}).ToList();
PopulateReportFields(data);
PopulateAttachUrls(data);
return Tuple.Create(data, total);
}
private static void PopulateReportFields(List<Model.WeldAppearanceCheckItem> data)
{
List<string> weldJointIds = data.Select(x => x.WeldJointId).Distinct().ToList();
if (weldJointIds.Count == 0)
{
return;
}
var details = Funs.DB.View_HJGL_WeldJoint
.Where(x => weldJointIds.Contains(x.WeldJointId))
.Select(x => new
{
x.WeldJointId,
x.UnitWorkId,
x.UnitWorkName,
x.WelderCode,
x.Specification,
x.MaterialCode,
x.WeldingLocationCode,
x.WeldingMethodCode,
x.WeldingRod,
x.WeldingRodCode,
x.WeldingWire,
x.WeldingWireCode
}).ToList();
List<string> consumablesIds = details
.SelectMany(x => new[] { x.WeldingWire, x.WeldingRod })
.Where(x => !string.IsNullOrWhiteSpace(x))
.Distinct()
.ToList();
var consumablesById = new Dictionary<string, string>();
if (consumablesIds.Count > 0)
{
consumablesById = Funs.DB.Base_Consumables
.Where(x => consumablesIds.Contains(x.ConsumablesId))
.ToDictionary(x => x.ConsumablesId, x => x.ConsumablesName);
}
foreach (Model.WeldAppearanceCheckItem item in data)
{
var detail = details.FirstOrDefault(x => x.WeldJointId == item.WeldJointId);
if (detail == null)
{
continue;
}
item.UnitWorkId = detail.UnitWorkId;
item.UnitWorkName = detail.UnitWorkName;
item.WelderCode = detail.WelderCode;
item.Specification = detail.Specification;
item.MaterialCode = detail.MaterialCode;
item.WeldingLocation = detail.WeldingLocationCode;
item.WeldingMethodCode = detail.WeldingMethodCode;
item.WeldingRodCode = detail.WeldingRodCode;
item.WeldingWireCode = detail.WeldingWireCode;
string wireName;
string rodName;
consumablesById.TryGetValue(detail.WeldingWire ?? string.Empty, out wireName);
consumablesById.TryGetValue(detail.WeldingRod ?? string.Empty, out rodName);
// 焊材牌号使用焊丝、焊条在耗材基础表中的名称,按既有报表口径以“+”合并并去重。
item.WeldingMaterial = string.Join("+", new[] { wireName, rodName }
.Where(x => !string.IsNullOrWhiteSpace(x)).Distinct());
}
}
/// <summary>
/// 查询当前项目可用于筛选和打印的检测编号。
/// </summary>
/// <param name="projectId">项目ID。</param>
/// <returns>检测编号列表。</returns>
public static List<string> GetCheckCodes(string projectId)
{
return Funs.DB.HJGL_WeldAppearanceCheck
.Where(x => (string.IsNullOrEmpty(projectId) || x.ProjectId == projectId)
&& x.CheckCode != null && x.CheckCode != string.Empty)
.Select(x => x.CheckCode)
.Distinct()
.OrderByDescending(x => x)
.ToList();
}
/// <summary>
/// 分页查询当前项目中已焊接的焊口。
/// </summary>