feat(hjgl): 完善焊前检查和防腐检查流程
焊前检查需要同时覆盖下料、组对和防腐检查,并支持移动端查询与保存。 扩展焊前检查模型、服务和页面字段,补充检查结果、不合格原因、整改要求、 附件和防腐检查记录,便于按焊口和材料追溯检查过程。
This commit is contained in:
@@ -1,28 +1,35 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 小程序焊前抽检接口服务
|
||||
/// 小程序焊前检查接口服务
|
||||
/// </summary>
|
||||
public static class APIPreWeldInspectionService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据焊口ID获取焊前抽检基础信息
|
||||
/// 根据焊口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 getweldJointPaintId = (from x in db.HJGL_WeldJoint
|
||||
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
|
||||
where x.WeldJointId == weldJointId
|
||||
select y.PaintId).FirstOrDefault();
|
||||
var getweldJointMaterialCode = (from x in db.HJGL_PipeLineMat
|
||||
where x.WeldJointId == weldJointId
|
||||
select x.MaterialCode).FirstOrDefault();
|
||||
var query = from x in db.HJGL_WeldJoint
|
||||
join p in db.Base_Project on x.ProjectId equals p.ProjectId into projects
|
||||
from p in projects.DefaultIfEmpty()
|
||||
join g in db.Base_GrooveType on x.GrooveTypeId equals g.GrooveTypeId into grooveTypes
|
||||
from g in grooveTypes.DefaultIfEmpty()
|
||||
from p in projects.DefaultIfEmpty()
|
||||
join pl in db.HJGL_Pipeline on x.PipelineId equals pl.PipelineId into pipelines
|
||||
from pl in pipelines.DefaultIfEmpty()
|
||||
join paint in db.Tw_PaintCodeDict on pl.PaintId equals paint.Id into paints
|
||||
from paint in paints.DefaultIfEmpty()
|
||||
where x.WeldJointId == weldJointId
|
||||
select new Model.PreWeldJointItem
|
||||
{
|
||||
@@ -30,15 +37,25 @@ namespace BLL
|
||||
WeldJointCode = x.WeldJointCode,
|
||||
PipelineId = x.PipelineId,
|
||||
PipelineCode = x.PipelineCode,
|
||||
PaintId= pl.PaintId,
|
||||
PaintCode = paint == null ? string.Empty : paint.PaintCode,
|
||||
ProjectId = x.ProjectId,
|
||||
ProjectName = p == null ? string.Empty : p.ProjectName,
|
||||
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
|
||||
preWeldMaterialItems = (from m in db.HJGL_PipeLineMat
|
||||
join lib in db.HJGL_MaterialCodeLib on m.MaterialCode equals lib.MaterialCode into libs
|
||||
from lib in libs.DefaultIfEmpty()
|
||||
where m.WeldJointId == weldJointId
|
||||
select new Model.PreWeldMaterialItem
|
||||
{
|
||||
MaterialCode = lib.MaterialCode,
|
||||
MaterialName = lib.MaterialName,
|
||||
MaterialSpec = lib.MaterialSpec,
|
||||
MaterialMade = lib.MaterialMade,
|
||||
MaterialDef = lib.MaterialDef,
|
||||
MaterialUnit = lib.MaterialUnit,
|
||||
HeatNo = lib.HeatNo,
|
||||
BatchNo = lib.BatchNo,
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
var item = query.FirstOrDefault();
|
||||
@@ -52,14 +69,166 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回填下料、组对抽检附件路径
|
||||
/// 获取焊口下料记录列表
|
||||
/// </summary>
|
||||
public static List<Model.PreWeldCuttingCheckItem> GetCuttingChecksByWeldJointId(string weldJointId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var data = (from c in db.HJGL_PreWeldCuttingCheck
|
||||
join w in db.HJGL_WeldJoint on c.WeldJointId equals w.WeldJointId
|
||||
join p in db.Person_Persons on c.CheckPerson equals p.PersonId into persons
|
||||
from p in persons.DefaultIfEmpty()
|
||||
where c.WeldJointId == weldJointId
|
||||
orderby c.CheckTime descending
|
||||
select new Model.PreWeldCuttingCheckItem
|
||||
{
|
||||
CuttingCheckId = c.CuttingCheckId,
|
||||
ProjectId = c.ProjectId,
|
||||
WeldJointId = c.WeldJointId,
|
||||
PipelineCode = w.PipelineCode,
|
||||
WeldJointCode = w.WeldJointCode,
|
||||
CuttingLength = c.CuttingLength,
|
||||
GrooveForm = c.GrooveForm,
|
||||
GrooveAngle = c.GrooveAngle,
|
||||
IsMaterialCodeBatchNoAccurate = c.IsMaterialCodeBatchNoAccurate,
|
||||
IsMaterialQuantityAccurate = c.IsMaterialQuantityAccurate,
|
||||
IsQualified = c.IsQualified,
|
||||
CheckPerson = c.CheckPerson,
|
||||
CheckPersonName = p == null ? string.Empty : p.PersonName,
|
||||
CheckTime = c.CheckTime,
|
||||
CreateUser = c.CreateUser,
|
||||
CreateTime = c.CreateTime,
|
||||
AttachUrl1 = null,
|
||||
CheckResult = c.CheckResult,
|
||||
UnqualifiedReason = c.UnqualifiedReason,
|
||||
RectifyRequirement = c.RectifyRequirement,
|
||||
Remark = c.Remark
|
||||
}).ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetAttachUrl(db, Const.HJGL_PreWeldCuttingCheckMenuId, item.CuttingCheckId);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取焊口组对记录列表
|
||||
/// </summary>
|
||||
public static List<Model.PreWeldFitupCheckItem> GetFitupChecksByWeldJointId(string weldJointId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var data = (from f in db.HJGL_PreWeldFitupCheck
|
||||
join w in db.HJGL_WeldJoint on f.WeldJointId equals w.WeldJointId
|
||||
join g in db.Base_GrooveType on f.GrooveTypeId equals g.GrooveTypeId into grooveTypes
|
||||
from g in grooveTypes.DefaultIfEmpty()
|
||||
join p in db.Person_Persons on f.CheckPerson equals p.PersonId into persons
|
||||
from p in persons.DefaultIfEmpty()
|
||||
where f.WeldJointId == weldJointId
|
||||
orderby f.CheckTime descending
|
||||
select new Model.PreWeldFitupCheckItem
|
||||
{
|
||||
FitupCheckId = f.FitupCheckId,
|
||||
ProjectId = f.ProjectId,
|
||||
WeldJointId = f.WeldJointId,
|
||||
PipelineCode = w.PipelineCode,
|
||||
WeldJointCode = w.WeldJointCode,
|
||||
GrooveTypeId = f.GrooveTypeId,
|
||||
GrooveTypeCode = g == null ? string.Empty : g.GrooveTypeCode,
|
||||
GrooveTypeName = g == null ? string.Empty : g.GrooveTypeName,
|
||||
GrooveProcessType = f.GrooveProcessType,
|
||||
GrooveAngle = f.GrooveAngle,
|
||||
FitupGap = f.FitupGap,
|
||||
Misalignment = f.Misalignment,
|
||||
WeldReinforcement = f.WeldReinforcement,
|
||||
WeldHeight = f.WeldHeight,
|
||||
WeldWidth = f.WeldWidth,
|
||||
SurfaceDefect = f.SurfaceDefect,
|
||||
CheckPerson = f.CheckPerson,
|
||||
CheckPersonName = p == null ? string.Empty : p.PersonName,
|
||||
CheckTime = f.CheckTime,
|
||||
CreateUser = f.CreateUser,
|
||||
CreateTime = f.CreateTime,
|
||||
AttachUrl1 = null,
|
||||
CheckResult = f.CheckResult,
|
||||
UnqualifiedReason = f.UnqualifiedReason,
|
||||
RectifyRequirement = f.RectifyRequirement,
|
||||
Remark = f.Remark
|
||||
}).ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetAttachUrl(db, Const.HJGL_PreWeldFitupCheckMenuId, item.FitupCheckId);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按材料编码获取防腐检查记录
|
||||
/// </summary>
|
||||
public static List<Model.AntiCorrosionCheckRecordItem> GetAntiCorrosionChecksByMaterialCode(string materialCode, string projectId)
|
||||
{
|
||||
return PreWeldInspectionService.GetAntiCorrosionChecksByMaterialCode(materialCode, projectId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 按焊口获取防腐检查记录列表
|
||||
/// </summary>
|
||||
/// <param name="weldJointId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.AntiCorrosionCheckRecordItem> GetAntiCorrosionChecksByWeldJointId(string weldJointId)
|
||||
{
|
||||
return PreWeldInspectionService.GetAntiCorrosionChecksByWeldJointId(weldJointId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 保存下料检查
|
||||
/// </summary>
|
||||
public static string SaveCuttingCheck(Model.PreWeldCuttingCheckInput item)
|
||||
{
|
||||
return PreWeldInspectionService.SaveCuttingCheck(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存组对检查
|
||||
/// </summary>
|
||||
public static string SaveFitupCheck(Model.PreWeldFitupCheckInput item)
|
||||
{
|
||||
return PreWeldInspectionService.SaveFitupCheck(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存防腐检查
|
||||
/// </summary>
|
||||
public static string SaveAntiCorrosionCheck(Model.AntiCorrosionCheckRecordInput item)
|
||||
{
|
||||
return PreWeldInspectionService.SaveAntiCorrosionCheck(item);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取防腐代码字典
|
||||
/// </summary>
|
||||
public static List<Model.PaintCodeDictOutput> GetPaintCodeList()
|
||||
{
|
||||
return TwAntiCorrosionTrustService.GetPaintCodeList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 兼容旧接口:按焊口获取组对记录最新一条
|
||||
/// </summary>
|
||||
public static Model.HJGL_PreWeldFitupCheck GetFitupCheckByWeldJointId(string weldJointId)
|
||||
{
|
||||
return PreWeldInspectionService.GetFitupCheckByWeldJointId(weldJointId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回写下料、组对附件地址
|
||||
/// </summary>
|
||||
/// <param name="db">数据库上下文</param>
|
||||
/// <param name="item">焊前抽检基础信息</param>
|
||||
private static void SetInspectionAttachUrl(Model.SGGLDB db, Model.PreWeldJointItem item)
|
||||
{
|
||||
var cuttingCheckId = db.HJGL_PreWeldCuttingCheck
|
||||
.Where(x => x.WeldJointId == item.WeldJointId)
|
||||
.OrderByDescending(x => x.CheckTime)
|
||||
.Select(x => x.CuttingCheckId)
|
||||
.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(cuttingCheckId))
|
||||
@@ -69,6 +238,7 @@ namespace BLL
|
||||
|
||||
var fitupCheckId = db.HJGL_PreWeldFitupCheck
|
||||
.Where(x => x.WeldJointId == item.WeldJointId)
|
||||
.OrderByDescending(x => x.CheckTime)
|
||||
.Select(x => x.FitupCheckId)
|
||||
.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(fitupCheckId))
|
||||
@@ -78,12 +248,8 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按菜单和业务ID获取附件路径
|
||||
/// 根据菜单和业务ID获取附件地址
|
||||
/// </summary>
|
||||
/// <param name="db">数据库上下文</param>
|
||||
/// <param name="menuId">菜单ID</param>
|
||||
/// <param name="toKeyId">业务ID</param>
|
||||
/// <returns>附件路径</returns>
|
||||
private static string GetAttachUrl(Model.SGGLDB db, string menuId, string toKeyId)
|
||||
{
|
||||
var attachUrl = db.AttachFile
|
||||
@@ -92,149 +258,5 @@ namespace BLL
|
||||
.FirstOrDefault();
|
||||
return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/');
|
||||
}
|
||||
|
||||
/// <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();
|
||||
|
||||
SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldCuttingCheckMenuId, check.CuttingCheckId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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();
|
||||
|
||||
SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldFitupCheckMenuId, check.FitupCheckId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存焊前抽检附件,空附件时清理原附件。
|
||||
/// </summary>
|
||||
/// <param name="attachUrl">附件路径</param>
|
||||
/// <param name="menuId">菜单ID</param>
|
||||
/// <param name="dataId">业务数据ID</param>
|
||||
private static void SaveInspectionAttachUrl(string attachUrl, string menuId, string dataId)
|
||||
{
|
||||
// AttachUrl1 为 null 表示旧调用方未传附件参数,避免误删已有附件;空字符串表示明确清空附件。
|
||||
if (attachUrl == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(attachUrl))
|
||||
{
|
||||
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(attachUrl, 10, null), attachUrl, menuId, dataId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonService.DeleteAttachFileById(menuId, dataId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user