feat: 完善材料管理与焊接业务功能

This commit is contained in:
2026-08-06 15:33:11 +08:00
parent e418b60fdb
commit 1de898812e
49 changed files with 2566 additions and 555 deletions
@@ -59,7 +59,8 @@
PipeGrade = codeLib.PipeGrade,
MaterialUnit = codeLib.MaterialUnit,
ProjectId = codeLib.ProjectId,
Code = codeLib.Code
Code = codeLib.Code,
DesignInstitute = codeLib.DesignInstitute
};
db.HJGL_MaterialCodeLib.InsertOnSubmit(newCodeLib);
db.SubmitChanges();
@@ -89,6 +90,7 @@
newCodeLib.PipeGrade = codeLib.PipeGrade;
newCodeLib.MaterialUnit = codeLib.MaterialUnit;
newCodeLib.Code = codeLib.Code;
newCodeLib.DesignInstitute = codeLib.DesignInstitute;
db.SubmitChanges();
}
}
@@ -231,6 +233,12 @@
///</summary>
[ExcelColumnName("类型")]
public string MaterialName { get; set; }
/// <summary>
/// 材料编码来源设计院。
/// </summary>
[ExcelColumnName("所属设计院")]
public string DesignInstitute { get; set; }
}
}
@@ -36,6 +36,7 @@ namespace BLL
PipelineId = pipelineMat.PipelineId,
Number = pipelineMat.Number,
PrefabricatedComponents = pipelineMat.PrefabricatedComponents,
PipeArea = pipelineMat.PipeArea,
};
db.HJGL_PipeLineMat.InsertOnSubmit(newPipelineMat);
db.SubmitChanges();
@@ -57,6 +58,7 @@ namespace BLL
newPipelineMat.PipelineId = pipelineMat.PipelineId;
newPipelineMat.Number = pipelineMat.Number;
newPipelineMat.PrefabricatedComponents = pipelineMat.PrefabricatedComponents;
newPipelineMat.PipeArea = pipelineMat.PipeArea;
db.SubmitChanges();
}
}
@@ -80,6 +82,20 @@ namespace BLL
}
}
/// <summary>
/// 更新材料用途,1 为工厂预制,2 为现场安装。
/// </summary>
public static void UpdatePipeArea(string pipelineMatId, string pipeArea)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PipeLineMat pipeLineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == pipelineMatId);
if (pipeLineMat != null)
{
pipeLineMat.PipeArea = pipeArea;
db.SubmitChanges();
}
}
/// <summary>
/// 根据材料匹配结果反写材料主编码
/// </summary>
@@ -295,6 +295,179 @@ namespace BLL
}
#region
/// <summary>
/// 获取焊接日报待审核明细列表。
/// </summary>
/// <param name="projectId">项目ID</param>
/// <param name="unitWorkId">单位工程ID,为空时不按单位工程过滤</param>
/// <param name="weldingDate">焊接日期,为空时不按日期过滤</param>
/// <param name="pipelineCode">管线编号关键字</param>
/// <param name="welderCode">焊工编号关键字</param>
/// <returns>待审核明细列表</returns>
public static List<Model.WeldingDailyTempDetailItem> GetWeldingDailyTempDetailList(string projectId,
string unitWorkId, DateTime? weldingDate, string pipelineCode, string welderCode)
{
if (string.IsNullOrEmpty(projectId))
{
return new List<Model.WeldingDailyTempDetailItem>();
}
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var query = QueryPendingWeldingDailyTempDetails(db);
query = query.Where(x => x.ProjectId == projectId);
if (!string.IsNullOrEmpty(unitWorkId))
{
query = query.Where(x => x.UnitWorkId == unitWorkId);
}
if (weldingDate.HasValue)
{
DateTime startDate = weldingDate.Value.Date;
DateTime endDate = startDate.AddDays(1);
query = query.Where(x => x.WeldingDate >= startDate && x.WeldingDate < endDate);
}
if (!string.IsNullOrEmpty(pipelineCode))
{
query = query.Where(x => x.PipelineCode != null && x.PipelineCode.Contains(pipelineCode));
}
if (!string.IsNullOrEmpty(welderCode))
{
query = query.Where(x => (x.CoverWelderCode != null && x.CoverWelderCode.Contains(welderCode))
|| (x.BackingWelderCode != null && x.BackingWelderCode.Contains(welderCode)));
}
var data = query.OrderBy(x => x.PipelineCode).ThenBy(x => x.WeldJointCode).ToList();
SetWeldingDailyTempDetailAttachUrls(db, data);
return data;
}
}
/// <summary>
/// 获取单条焊接日报待审核明细。
/// </summary>
/// <param name="tempDetailId">待审核明细ID</param>
/// <returns>待审核明细,不存在时返回空</returns>
public static Model.WeldingDailyTempDetailItem GetWeldingDailyTempDetailById(string tempDetailId)
{
if (string.IsNullOrEmpty(tempDetailId))
{
return null;
}
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var data = QueryPendingWeldingDailyTempDetails(db)
.Where(x => x.TempDetailId == tempDetailId)
.Take(1)
.ToList();
SetWeldingDailyTempDetailAttachUrls(db, data);
return data.FirstOrDefault();
}
}
/// <summary>
/// 构造待审核查询。PC端列表和接口列表、明细均从这里读取,确保字段映射和待审核状态一致。
/// </summary>
private static System.Linq.IQueryable<Model.WeldingDailyTempDetailItem> QueryPendingWeldingDailyTempDetails(Model.SGGLDB db)
{
// 待审核模块只展示 AuditState=0;审核、删除仍复用本类下方已有批量业务方法。
return from temp in db.HJGL_WeldingDailyTempDetail
join jotItem in db.View_HJGL_WeldJoint on temp.WeldJointId equals jotItem.WeldJointId into jotItems
from jot in jotItems.DefaultIfEmpty()
join coverItem in db.SitePerson_Person on temp.CoverWelderId equals coverItem.PersonId into coverItems
from coverWelder in coverItems.DefaultIfEmpty()
join backingItem in db.SitePerson_Person on temp.BackingWelderId equals backingItem.PersonId into backingItems
from backingWelder in backingItems.DefaultIfEmpty()
join locationItem in db.Base_WeldingLocation on temp.WeldingLocationId equals locationItem.WeldingLocationId into locationItems
from location in locationItems.DefaultIfEmpty()
join submitItem in db.Person_Persons on temp.SubmitPersonId equals submitItem.PersonId into submitItems
from submitPerson in submitItems.DefaultIfEmpty()
where temp.AuditState == 0
select new Model.WeldingDailyTempDetailItem
{
TempDetailId = temp.TempDetailId,
ProjectId = temp.ProjectId,
UnitId = temp.UnitId,
UnitWorkId = temp.UnitWorkId,
WeldJointId = temp.WeldJointId,
PipelineId = jot == null ? null : jot.PipelineId,
PipelineCode = jot == null ? null : jot.PipelineCode,
WeldJointCode = jot == null ? null : jot.WeldJointCode,
WeldingDate = temp.WeldingDate,
CoverWelderId = temp.CoverWelderId,
CoverWelderCode = coverWelder == null ? null : coverWelder.WelderCode,
BackingWelderId = temp.BackingWelderId,
BackingWelderCode = backingWelder == null ? null : backingWelder.WelderCode,
JointAttribute = temp.JointAttribute,
WeldingLocationId = temp.WeldingLocationId,
WeldingLocationCode = location == null ? null : location.WeldingLocationCode,
WeldingMode = temp.WeldingMode,
Material1Code = jot == null ? null : jot.Material1Code,
Material2Code = jot == null ? null : jot.Material2Code,
DNDia = jot == null ? null : jot.DNDia,
Size = jot == null ? (decimal?)null : jot.Size,
Dia = jot == null ? (decimal?)null : jot.Dia,
Thickness = jot == null ? (decimal?)null : jot.Thickness,
WeldTypeCode = jot == null ? null : jot.WeldTypeCode,
WeldingMethodCode = jot == null ? null : jot.WeldingMethodCode,
WeldingWireCode = jot == null ? null : jot.WeldingWireCode,
WeldingRodCode = jot == null ? null : jot.WeldingRodCode,
SubmitPersonId = temp.SubmitPersonId,
SubmitPersonName = submitPerson == null ? null : submitPerson.PersonName,
SubmitDate = temp.SubmitDate,
AttachUrl = temp.AttachUrl,
AuditState = temp.AuditState,
AuditMan = temp.AuditMan,
AuditDate = temp.AuditDate,
AuditRemark = temp.AuditRemark
};
}
/// <summary>
/// 按待审核明细ID批量回写焊前、焊后附件地址。
/// </summary>
private static void SetWeldingDailyTempDetailAttachUrls(Model.SGGLDB db,
List<Model.WeldingDailyTempDetailItem> data)
{
if (data == null || data.Count == 0)
{
return;
}
var toKeyIds = data.SelectMany(x => new[]
{
x.TempDetailId + "#Before",
x.TempDetailId + "#After"
}).ToList();
var attachUrlMap = db.AttachFile
.Where(x => x.MenuId == Const.HJGL_WeldReportMenuId && toKeyIds.Contains(x.ToKeyId))
.Select(x => new { x.ToKeyId, x.AttachUrl })
.ToList()
.GroupBy(x => x.ToKeyId)
.ToDictionary(x => x.Key, x => x.Select(y => y.AttachUrl).FirstOrDefault());
foreach (var item in data)
{
string beforeUrl;
if (attachUrlMap.TryGetValue(item.TempDetailId + "#Before", out beforeUrl))
{
// API统一返回斜杠路径,PC端继续兼容原有反斜杠路径显示逻辑。
item.BeforePhotoUrl = NormalizeAttachUrl(beforeUrl);
}
string afterUrl;
if (attachUrlMap.TryGetValue(item.TempDetailId + "#After", out afterUrl))
{
item.AfterPhotoUrl = NormalizeAttachUrl(afterUrl);
}
}
}
private static string NormalizeAttachUrl(string attachUrl)
{
return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/');
}
/// <summary>
/// 移动端按焊口保存焊接日报待审核明细
/// </summary>
@@ -610,9 +783,9 @@ namespace BLL
return weldingDaily;
}
var submitPerson = Funs.DB.Person_Persons.FirstOrDefault(x => x.PersonId == tempDetail.SubmitPersonId);
string personName = submitPerson != null ? submitPerson.PersonName : string.Empty;
string perfix = string.Format("{0:yyyyMMdd}", tempDetail.WeldingDate) + "-" + personName + "-";
var submitUnitwork = Funs.DB.WBS_UnitWork.FirstOrDefault(x => x.UnitWorkId == tempDetail.UnitWorkId);
string unitWorkName = submitUnitwork != null ? submitUnitwork.UnitWorkName : string.Empty;
string perfix = string.Format("{0:yyyyMMdd}", tempDetail.WeldingDate) + "-" + unitWorkName + "-";
weldingDaily = new Model.HJGL_WeldingDaily
{
WeldingDailyId = Guid.NewGuid().ToString(),