2026-06-17 14:22:06 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 小程序焊前抽检接口服务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class APIPreWeldInspectionService
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据焊口ID获取焊前抽检基础信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="weldJointId">焊口ID</param>
|
|
|
|
|
/// <returns>焊口基础信息</returns>
|
|
|
|
|
public static Model.PreWeldJointItem GetPreWeldJointByWeldJointId(string weldJointId)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var query = from x in db.HJGL_WeldJoint
|
2026-06-17 18:37:50 +08:00
|
|
|
join p in db.Base_Project on x.ProjectId equals p.ProjectId into projects
|
|
|
|
|
from p in projects.DefaultIfEmpty()
|
2026-06-17 14:22:06 +08:00
|
|
|
join g in db.Base_GrooveType on x.GrooveTypeId equals g.GrooveTypeId into grooveTypes
|
|
|
|
|
from g in grooveTypes.DefaultIfEmpty()
|
|
|
|
|
where x.WeldJointId == weldJointId
|
|
|
|
|
select new Model.PreWeldJointItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointId = x.WeldJointId,
|
|
|
|
|
WeldJointCode = x.WeldJointCode,
|
|
|
|
|
PipelineId = x.PipelineId,
|
|
|
|
|
PipelineCode = x.PipelineCode,
|
|
|
|
|
ProjectId = x.ProjectId,
|
2026-06-17 18:37:50 +08:00
|
|
|
ProjectName = p == null ? string.Empty : p.ProjectName,
|
2026-06-17 14:22:06 +08:00
|
|
|
GrooveTypeId = x.GrooveTypeId,
|
|
|
|
|
GrooveTypeCode = g == null ? string.Empty : g.GrooveTypeCode,
|
|
|
|
|
GrooveTypeName = g == null ? string.Empty : g.GrooveTypeName,
|
|
|
|
|
GrooveProcessType = x.GrooveProcessType,
|
|
|
|
|
GrooveAngle = x.GrooveAngle,
|
|
|
|
|
FitupGap = x.FitupGap,
|
|
|
|
|
Misalignment = x.Misalignment
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return query.FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存下料抽检,已存在同一焊口记录时更新原记录
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">下料抽检参数</param>
|
|
|
|
|
public static void SaveCuttingCheck(Model.PreWeldCuttingCheckItem item)
|
|
|
|
|
{
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("item");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.WeldJointId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("焊口ID不能为空。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId);
|
|
|
|
|
if (weldJoint == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("未找到对应焊口。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var check = db.HJGL_PreWeldCuttingCheck.FirstOrDefault(x => x.WeldJointId == item.WeldJointId);
|
|
|
|
|
if (check == null)
|
|
|
|
|
{
|
|
|
|
|
check = new Model.HJGL_PreWeldCuttingCheck
|
|
|
|
|
{
|
|
|
|
|
CuttingCheckId = Guid.NewGuid().ToString(),
|
|
|
|
|
WeldJointId = item.WeldJointId,
|
|
|
|
|
ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId,
|
|
|
|
|
CreateUser = item.CreateUser ?? item.CheckPerson,
|
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
db.HJGL_PreWeldCuttingCheck.InsertOnSubmit(check);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId;
|
|
|
|
|
check.IsMaterialCodeBatchNoAccurate = item.IsMaterialCodeBatchNoAccurate;
|
|
|
|
|
check.IsMaterialQuantityAccurate = item.IsMaterialQuantityAccurate;
|
|
|
|
|
// 下料抽检合格规则:材料编码及炉批号、材料数量两个检查项均准确才合格。
|
|
|
|
|
check.IsQualified = item.IsMaterialCodeBatchNoAccurate && item.IsMaterialQuantityAccurate;
|
|
|
|
|
check.CheckPerson = item.CheckPerson;
|
|
|
|
|
check.CheckTime = item.CheckTime ?? DateTime.Now;
|
|
|
|
|
check.Remark = item.Remark;
|
|
|
|
|
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存组对抽检,已存在同一焊口记录时更新原记录并回写焊口主表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="item">组对抽检参数</param>
|
|
|
|
|
public static void SaveFitupCheck(Model.PreWeldFitupCheckItem item)
|
|
|
|
|
{
|
|
|
|
|
if (item == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentNullException("item");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.WeldJointId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("焊口ID不能为空。");
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrEmpty(item.GrooveTypeId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("坡口类型不能为空。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId);
|
|
|
|
|
if (weldJoint == null)
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("未找到对应焊口。");
|
|
|
|
|
}
|
|
|
|
|
if (!db.Base_GrooveType.Any(x => x.GrooveTypeId == item.GrooveTypeId))
|
|
|
|
|
{
|
|
|
|
|
throw new ArgumentException("坡口类型不存在。");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var check = db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.WeldJointId == item.WeldJointId);
|
|
|
|
|
if (check == null)
|
|
|
|
|
{
|
|
|
|
|
check = new Model.HJGL_PreWeldFitupCheck
|
|
|
|
|
{
|
|
|
|
|
FitupCheckId = Guid.NewGuid().ToString(),
|
|
|
|
|
WeldJointId = item.WeldJointId,
|
|
|
|
|
ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId,
|
|
|
|
|
CreateUser = item.CreateUser ?? item.CheckPerson,
|
|
|
|
|
CreateTime = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
db.HJGL_PreWeldFitupCheck.InsertOnSubmit(check);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId;
|
|
|
|
|
check.GrooveTypeId = item.GrooveTypeId;
|
|
|
|
|
check.GrooveProcessType = item.GrooveProcessType;
|
|
|
|
|
check.GrooveAngle = item.GrooveAngle;
|
|
|
|
|
check.FitupGap = item.FitupGap;
|
|
|
|
|
check.Misalignment = item.Misalignment;
|
|
|
|
|
check.CheckPerson = item.CheckPerson;
|
|
|
|
|
check.CheckTime = item.CheckTime ?? DateTime.Now;
|
|
|
|
|
check.Remark = item.Remark;
|
|
|
|
|
|
|
|
|
|
// 组对抽检字段需同步回写焊口主表,供焊口台账和后续业务复用。
|
|
|
|
|
weldJoint.GrooveTypeId = item.GrooveTypeId;
|
|
|
|
|
weldJoint.GrooveProcessType = item.GrooveProcessType;
|
|
|
|
|
weldJoint.GrooveAngle = item.GrooveAngle;
|
|
|
|
|
weldJoint.FitupGap = item.FitupGap;
|
|
|
|
|
weldJoint.Misalignment = item.Misalignment;
|
|
|
|
|
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|