feat(hjgl): 完善焊前检查和防腐检查流程
焊前检查需要同时覆盖下料、组对和防腐检查,并支持移动端查询与保存。 扩展焊前检查模型、服务和页面字段,补充检查结果、不合格原因、整改要求、 附件和防腐检查记录,便于按焊口和材料追溯检查过程。
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 焊前抽检台账服务
|
||||
/// 焊前检查台账服务
|
||||
/// </summary>
|
||||
public static class PreWeldInspectionService
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取下料抽检台账
|
||||
/// 获取下料检查台账
|
||||
/// </summary>
|
||||
public static Tuple<List<Model.PreWeldCuttingCheckItem>, int> GetCuttingCheckList(string projectId, string pipelineCode, string weldJointCode, int pageIndex, int pageSize)
|
||||
{
|
||||
@@ -48,6 +48,9 @@ namespace BLL
|
||||
WeldJointId = x.c.WeldJointId,
|
||||
PipelineCode = x.w.PipelineCode,
|
||||
WeldJointCode = x.w.WeldJointCode,
|
||||
CuttingLength = x.c.CuttingLength,
|
||||
GrooveForm = x.c.GrooveForm,
|
||||
GrooveAngle = x.c.GrooveAngle,
|
||||
IsMaterialCodeBatchNoAccurate = x.c.IsMaterialCodeBatchNoAccurate,
|
||||
IsMaterialQuantityAccurate = x.c.IsMaterialQuantityAccurate,
|
||||
IsQualified = x.c.IsQualified,
|
||||
@@ -56,16 +59,23 @@ namespace BLL
|
||||
CheckTime = x.c.CheckTime,
|
||||
CreateUser = x.c.CreateUser,
|
||||
CreateTime = x.c.CreateTime,
|
||||
CheckResult = x.c.CheckResult,
|
||||
UnqualifiedReason = x.c.UnqualifiedReason,
|
||||
RectifyRequirement = x.c.RectifyRequirement,
|
||||
Remark = x.c.Remark
|
||||
})
|
||||
.ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetInspectionAttachUrl(db, Const.HJGL_PreWeldCuttingCheckMenuId, item.CuttingCheckId);
|
||||
}
|
||||
|
||||
return Tuple.Create(data, total);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组对抽检台账
|
||||
/// 获取组对检查台账
|
||||
/// </summary>
|
||||
public static Tuple<List<Model.PreWeldFitupCheckItem>, int> GetFitupCheckList(string projectId, string pipelineCode, string weldJointCode, int pageIndex, int pageSize)
|
||||
{
|
||||
@@ -96,14 +106,14 @@ namespace BLL
|
||||
}
|
||||
|
||||
int total = query.Count();
|
||||
var data = query.OrderBy(x => x.w.PipelineCode).ThenBy(x => x.w.WeldJointCode)
|
||||
var data = query.OrderByDescending(x => x.f.CheckTime)
|
||||
.Skip(pageIndex * pageSize)
|
||||
.Take(pageSize)
|
||||
.Select(x => new Model.PreWeldFitupCheckItem
|
||||
{
|
||||
FitupCheckId = x.f.FitupCheckId,
|
||||
ProjectId = x.f.ProjectId,
|
||||
WeldJointId = x.w.WeldJointId,
|
||||
WeldJointId = x.f.WeldJointId,
|
||||
PipelineCode = x.w.PipelineCode,
|
||||
WeldJointCode = x.w.WeldJointCode,
|
||||
GrooveTypeId = x.f.GrooveTypeId,
|
||||
@@ -113,21 +123,32 @@ namespace BLL
|
||||
GrooveAngle = x.f.GrooveAngle,
|
||||
FitupGap = x.f.FitupGap,
|
||||
Misalignment = x.f.Misalignment,
|
||||
WeldReinforcement = x.f.WeldReinforcement,
|
||||
WeldHeight = x.f.WeldHeight,
|
||||
WeldWidth = x.f.WeldWidth,
|
||||
SurfaceDefect = x.f.SurfaceDefect,
|
||||
CheckPerson = x.f.CheckPerson,
|
||||
CheckPersonName = x.CheckPersonName,
|
||||
CheckTime = x.f.CheckTime,
|
||||
CreateUser = x.f.CreateUser,
|
||||
CreateTime = x.f.CreateTime,
|
||||
CheckResult = x.f.CheckResult,
|
||||
UnqualifiedReason = x.f.UnqualifiedReason,
|
||||
RectifyRequirement = x.f.RectifyRequirement,
|
||||
Remark = x.f.Remark
|
||||
})
|
||||
.ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetInspectionAttachUrl(db, Const.HJGL_PreWeldFitupCheckMenuId, item.FitupCheckId);
|
||||
}
|
||||
|
||||
return Tuple.Create(data, total);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取下料抽检实体
|
||||
/// 获取下料检查实体
|
||||
/// </summary>
|
||||
public static Model.HJGL_PreWeldCuttingCheck GetCuttingCheckById(string cuttingCheckId)
|
||||
{
|
||||
@@ -138,14 +159,568 @@ namespace BLL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组对抽检实体
|
||||
/// 获取组对检查实体
|
||||
/// </summary>
|
||||
public static Model.HJGL_PreWeldFitupCheck GetFitupCheckById(string fitupCheckId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.FitupCheckId == fitupCheckId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 兼容旧调用:按焊口获取组对检查记录,返回最新一条
|
||||
/// </summary>
|
||||
public static Model.HJGL_PreWeldFitupCheck GetFitupCheckByWeldJointId(string weldJointId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.WeldJointId == weldJointId);
|
||||
return db.HJGL_PreWeldFitupCheck.Where(x => x.WeldJointId == weldJointId)
|
||||
.OrderByDescending(x => x.CheckTime)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按焊口获取下料记录
|
||||
/// </summary>
|
||||
public static List<Model.HJGL_PreWeldCuttingCheck> GetCuttingChecksByWeldJointId(string weldJointId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return db.HJGL_PreWeldCuttingCheck.Where(x => x.WeldJointId == weldJointId)
|
||||
.OrderByDescending(x => x.CheckTime)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按焊口获取组对记录
|
||||
/// </summary>
|
||||
public static List<Model.HJGL_PreWeldFitupCheck> GetFitupChecksByWeldJointId(string weldJointId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return db.HJGL_PreWeldFitupCheck.Where(x => x.WeldJointId == weldJointId)
|
||||
.OrderByDescending(x => x.CheckTime)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存下料检查;传入主键时修改对应记录,否则新增一条记录
|
||||
/// </summary>
|
||||
public static string SaveCuttingCheck(Model.PreWeldCuttingCheckInput 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 = string.IsNullOrEmpty(item.CuttingCheckId)
|
||||
? null
|
||||
: db.HJGL_PreWeldCuttingCheck.FirstOrDefault(x => x.CuttingCheckId == item.CuttingCheckId);
|
||||
if (check == null)
|
||||
{
|
||||
check = new Model.HJGL_PreWeldCuttingCheck
|
||||
{
|
||||
CuttingCheckId = string.IsNullOrEmpty(item.CuttingCheckId) ? Guid.NewGuid().ToString() : item.CuttingCheckId,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
db.HJGL_PreWeldCuttingCheck.InsertOnSubmit(check);
|
||||
}
|
||||
|
||||
check.WeldJointId = item.WeldJointId;
|
||||
check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId;
|
||||
check.CuttingLength = item.CuttingLength;
|
||||
check.GrooveForm = item.GrooveForm;
|
||||
check.GrooveAngle = item.GrooveAngle;
|
||||
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.CreateUser = item.CreateUser ?? item.CheckPerson;
|
||||
check.CheckResult = item.CheckResult;
|
||||
check.UnqualifiedReason = item.UnqualifiedReason;
|
||||
check.RectifyRequirement = item.RectifyRequirement;
|
||||
check.Remark = item.Remark;
|
||||
db.SubmitChanges();
|
||||
SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldCuttingCheckMenuId, check.CuttingCheckId);
|
||||
return check.CuttingCheckId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存组对检查;传入主键时修改对应记录,否则新增一条记录
|
||||
/// </summary>
|
||||
public static string SaveFitupCheck(Model.PreWeldFitupCheckInput 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 = string.IsNullOrEmpty(item.FitupCheckId)
|
||||
? null
|
||||
: db.HJGL_PreWeldFitupCheck.FirstOrDefault(x => x.FitupCheckId == item.FitupCheckId);
|
||||
if (check == null)
|
||||
{
|
||||
check = new Model.HJGL_PreWeldFitupCheck
|
||||
{
|
||||
FitupCheckId = string.IsNullOrEmpty(item.FitupCheckId) ? Guid.NewGuid().ToString() : item.FitupCheckId,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
db.HJGL_PreWeldFitupCheck.InsertOnSubmit(check);
|
||||
}
|
||||
|
||||
check.ProjectId = string.IsNullOrEmpty(item.ProjectId) ? weldJoint.ProjectId : item.ProjectId;
|
||||
check.WeldJointId = item.WeldJointId;
|
||||
check.GrooveTypeId = item.GrooveTypeId;
|
||||
check.GrooveProcessType = item.GrooveProcessType;
|
||||
check.GrooveAngle = item.GrooveAngle;
|
||||
check.FitupGap = item.FitupGap;
|
||||
check.Misalignment = item.Misalignment;
|
||||
check.WeldReinforcement = item.WeldReinforcement;
|
||||
check.WeldHeight = item.WeldHeight;
|
||||
check.WeldWidth = item.WeldWidth;
|
||||
check.SurfaceDefect = item.SurfaceDefect;
|
||||
check.CheckPerson = item.CheckPerson;
|
||||
check.CheckTime = item.CheckTime ?? DateTime.Now;
|
||||
check.CreateUser = item.CreateUser ?? item.CheckPerson;
|
||||
check.CheckResult = item.CheckResult;
|
||||
check.UnqualifiedReason = item.UnqualifiedReason;
|
||||
check.RectifyRequirement = item.RectifyRequirement;
|
||||
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);
|
||||
return check.FitupCheckId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取防腐检查台账
|
||||
/// </summary>
|
||||
public static Tuple<List<Model.AntiCorrosionCheckRecordItem>, int> GetAntiCorrosionCheckList(string projectId, string materialCode, string paintCode, string intermediatePaint, string topcoat, string filmThickness, string checkResult, DateTime? startTime, DateTime? endTime, int pageIndex, int pageSize)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var query = from r in db.HJGL_AntiCorrosionCheckRecord
|
||||
join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin
|
||||
from m in materialJoin.DefaultIfEmpty()
|
||||
join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin
|
||||
from paint in paintJoin.DefaultIfEmpty()
|
||||
join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin
|
||||
from person in personJoin.DefaultIfEmpty()
|
||||
where string.IsNullOrEmpty(projectId) || r.ProjectId == projectId
|
||||
select new { r, m, paint, person };
|
||||
if (!string.IsNullOrEmpty(materialCode))
|
||||
{
|
||||
query = query.Where(x => x.r.MaterialCode.Contains(materialCode));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(paintCode))
|
||||
{
|
||||
query = query.Where(x => x.paint != null && x.paint.PaintCode.Contains(paintCode));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(intermediatePaint))
|
||||
{
|
||||
query = query.Where(x => x.paint != null && x.paint.IntermediatePaint.Contains(intermediatePaint));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(topcoat))
|
||||
{
|
||||
query = query.Where(x => x.paint != null && x.paint.Topcoat.Contains(topcoat));
|
||||
}
|
||||
decimal filmThicknessValue;
|
||||
if (!string.IsNullOrWhiteSpace(filmThickness) && decimal.TryParse(filmThickness, out filmThicknessValue))
|
||||
{
|
||||
query = query.Where(x => x.r.FilmThickness == filmThicknessValue);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(checkResult))
|
||||
{
|
||||
query = query.Where(x => x.r.CheckResult == checkResult);
|
||||
}
|
||||
if (startTime.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.r.CheckTime >= startTime.Value);
|
||||
}
|
||||
if (endTime.HasValue)
|
||||
{
|
||||
query = query.Where(x => x.r.CheckTime < endTime.Value.AddDays(1));
|
||||
}
|
||||
|
||||
int total = query.Count();
|
||||
var data = query.OrderByDescending(x => x.r.CheckTime)
|
||||
.Skip(pageIndex * pageSize)
|
||||
.Take(pageSize)
|
||||
.Select(x => new Model.AntiCorrosionCheckRecordItem
|
||||
{
|
||||
AntiCorrosionCheckId = x.r.AntiCorrosionCheckId,
|
||||
ProjectId = x.r.ProjectId,
|
||||
UnitWorkId = x.r.UnitWorkId,
|
||||
MaterialId = x.r.MaterialId,
|
||||
MaterialCode = x.r.MaterialCode,
|
||||
MaterialName = x.m == null ? string.Empty : x.m.MaterialName,
|
||||
MaterialSpec = x.m == null ? string.Empty : x.m.MaterialSpec,
|
||||
MaterialMade = x.m == null ? string.Empty : x.m.MaterialMade,
|
||||
MaterialDef = x.m == null ? string.Empty : x.m.MaterialDef,
|
||||
MaterialUnit = x.m == null ? string.Empty : x.m.MaterialUnit,
|
||||
HeatNo = x.m == null ? string.Empty : x.m.HeatNo,
|
||||
BatchNo = x.m == null ? string.Empty : x.m.BatchNo,
|
||||
Code = x.m == null ? string.Empty : x.m.Code,
|
||||
AnticorrosionLevel = x.r.AnticorrosionLevel,
|
||||
PaintId = x.r.PaintId,
|
||||
PaintCode = x.paint == null ? string.Empty : x.paint.PaintCode,
|
||||
Primer = x.paint == null ? string.Empty : x.paint.Primer,
|
||||
IntermediatePaint = x.paint == null ? string.Empty : x.paint.IntermediatePaint,
|
||||
Topcoat = x.paint == null ? string.Empty : x.paint.Topcoat,
|
||||
ColorCode = x.paint == null ? string.Empty : x.paint.ColorCode,
|
||||
FilmThickness = x.r.FilmThickness,
|
||||
SandBlasting = x.r.SandBlasting,
|
||||
RustSandBlasting = x.r.RustSandBlasting,
|
||||
CheckResult = x.r.CheckResult,
|
||||
CheckPerson = x.r.CheckPerson,
|
||||
CheckPersonName = x.person == null ? string.Empty : x.person.PersonName,
|
||||
CheckTime = x.r.CheckTime,
|
||||
UnqualifiedReason = x.r.UnqualifiedReason,
|
||||
RectifyRequirement = x.r.RectifyRequirement,
|
||||
Remark = x.r.Remark,
|
||||
CreateUser = x.r.CreateUser,
|
||||
CreateTime = x.r.CreateTime
|
||||
})
|
||||
.ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId);
|
||||
}
|
||||
|
||||
return Tuple.Create(data, total);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据防腐记录ID获取详情
|
||||
/// </summary>
|
||||
public static Model.AntiCorrosionCheckRecordItem GetAntiCorrosionCheckById(string antiCorrosionCheckId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var query = from r in db.HJGL_AntiCorrosionCheckRecord
|
||||
join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin
|
||||
from m in materialJoin.DefaultIfEmpty()
|
||||
join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin
|
||||
from paint in paintJoin.DefaultIfEmpty()
|
||||
join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin
|
||||
from person in personJoin.DefaultIfEmpty()
|
||||
where r.AntiCorrosionCheckId == antiCorrosionCheckId
|
||||
select new Model.AntiCorrosionCheckRecordItem
|
||||
{
|
||||
AntiCorrosionCheckId = r.AntiCorrosionCheckId,
|
||||
ProjectId = r.ProjectId,
|
||||
UnitWorkId = r.UnitWorkId,
|
||||
MaterialId = r.MaterialId,
|
||||
MaterialCode = r.MaterialCode,
|
||||
MaterialName = m == null ? string.Empty : m.MaterialName,
|
||||
MaterialSpec = m == null ? string.Empty : m.MaterialSpec,
|
||||
MaterialMade = m == null ? string.Empty : m.MaterialMade,
|
||||
MaterialDef = m == null ? string.Empty : m.MaterialDef,
|
||||
MaterialUnit = m == null ? string.Empty : m.MaterialUnit,
|
||||
HeatNo = m == null ? string.Empty : m.HeatNo,
|
||||
BatchNo = m == null ? string.Empty : m.BatchNo,
|
||||
Code = m == null ? string.Empty : m.Code,
|
||||
AnticorrosionLevel = r.AnticorrosionLevel,
|
||||
PaintId = r.PaintId,
|
||||
PaintCode = paint == null ? string.Empty : paint.PaintCode,
|
||||
Primer = paint == null ? string.Empty : paint.Primer,
|
||||
IntermediatePaint = paint == null ? string.Empty : paint.IntermediatePaint,
|
||||
Topcoat = paint == null ? string.Empty : paint.Topcoat,
|
||||
ColorCode = paint == null ? string.Empty : paint.ColorCode,
|
||||
FilmThickness = r.FilmThickness,
|
||||
SandBlasting = r.SandBlasting,
|
||||
RustSandBlasting = r.RustSandBlasting,
|
||||
CheckResult = r.CheckResult,
|
||||
CheckPerson = r.CheckPerson,
|
||||
CheckPersonName = person == null ? string.Empty : person.PersonName,
|
||||
CheckTime = r.CheckTime,
|
||||
UnqualifiedReason = r.UnqualifiedReason,
|
||||
RectifyRequirement = r.RectifyRequirement,
|
||||
Remark = r.Remark,
|
||||
CreateUser = r.CreateUser,
|
||||
CreateTime = r.CreateTime
|
||||
};
|
||||
var item = query.FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按材料编码获取防腐记录列表
|
||||
/// </summary>
|
||||
public static List<Model.AntiCorrosionCheckRecordItem> GetAntiCorrosionChecksByMaterialCode(string materialCode, string projectId)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var query = from r in db.HJGL_AntiCorrosionCheckRecord
|
||||
join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin
|
||||
from m in materialJoin.DefaultIfEmpty()
|
||||
join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin
|
||||
from paint in paintJoin.DefaultIfEmpty()
|
||||
join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin
|
||||
from person in personJoin.DefaultIfEmpty()
|
||||
where r.MaterialCode == materialCode && (string.IsNullOrEmpty(projectId) || r.ProjectId == projectId)
|
||||
orderby r.CheckTime descending
|
||||
select new Model.AntiCorrosionCheckRecordItem
|
||||
{
|
||||
AntiCorrosionCheckId = r.AntiCorrosionCheckId,
|
||||
ProjectId = r.ProjectId,
|
||||
UnitWorkId = r.UnitWorkId,
|
||||
MaterialId = r.MaterialId,
|
||||
MaterialCode = r.MaterialCode,
|
||||
MaterialName = m == null ? string.Empty : m.MaterialName,
|
||||
MaterialSpec = m == null ? string.Empty : m.MaterialSpec,
|
||||
MaterialMade = m == null ? string.Empty : m.MaterialMade,
|
||||
MaterialDef = m == null ? string.Empty : m.MaterialDef,
|
||||
MaterialUnit = m == null ? string.Empty : m.MaterialUnit,
|
||||
HeatNo = m == null ? string.Empty : m.HeatNo,
|
||||
BatchNo = m == null ? string.Empty : m.BatchNo,
|
||||
Code = m == null ? string.Empty : m.Code,
|
||||
AnticorrosionLevel = r.AnticorrosionLevel,
|
||||
PaintId = r.PaintId,
|
||||
PaintCode = paint == null ? string.Empty : paint.PaintCode,
|
||||
Primer = paint == null ? string.Empty : paint.Primer,
|
||||
IntermediatePaint = paint == null ? string.Empty : paint.IntermediatePaint,
|
||||
Topcoat = paint == null ? string.Empty : paint.Topcoat,
|
||||
ColorCode = paint == null ? string.Empty : paint.ColorCode,
|
||||
FilmThickness = r.FilmThickness,
|
||||
SandBlasting = r.SandBlasting,
|
||||
RustSandBlasting = r.RustSandBlasting,
|
||||
CheckResult = r.CheckResult,
|
||||
CheckPerson = r.CheckPerson,
|
||||
CheckPersonName = person == null ? string.Empty : person.PersonName,
|
||||
CheckTime = r.CheckTime,
|
||||
UnqualifiedReason = r.UnqualifiedReason,
|
||||
RectifyRequirement = r.RectifyRequirement,
|
||||
Remark = r.Remark,
|
||||
CreateUser = r.CreateUser,
|
||||
CreateTime = r.CreateTime
|
||||
};
|
||||
var data = query.ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按焊口获取防腐检查记录列表
|
||||
/// </summary>
|
||||
/// <param name="weldJointId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.AntiCorrosionCheckRecordItem> GetAntiCorrosionChecksByWeldJointId(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 r in db.HJGL_AntiCorrosionCheckRecord
|
||||
join m in db.HJGL_MaterialCodeLib on r.MaterialCode equals m.MaterialCode into materialJoin
|
||||
from m in materialJoin.DefaultIfEmpty()
|
||||
join paint in db.Tw_PaintCodeDict on r.PaintId equals paint.Id into paintJoin
|
||||
from paint in paintJoin.DefaultIfEmpty()
|
||||
join person in db.Person_Persons on r.CheckPerson equals person.PersonId into personJoin
|
||||
from person in personJoin.DefaultIfEmpty()
|
||||
join weldmat in db.HJGL_PipeLineMat on r.MaterialCode equals weldmat.MaterialCode into weldJoin
|
||||
from weldmat in weldJoin.DefaultIfEmpty()
|
||||
where weldmat.WeldJointId == weldJointId && (string.IsNullOrEmpty(getweldJointPaintId) || r.PaintId == getweldJointPaintId)
|
||||
orderby r.CheckTime descending
|
||||
select new Model.AntiCorrosionCheckRecordItem
|
||||
{
|
||||
AntiCorrosionCheckId = r.AntiCorrosionCheckId,
|
||||
ProjectId = r.ProjectId,
|
||||
UnitWorkId = r.UnitWorkId,
|
||||
MaterialId = r.MaterialId,
|
||||
MaterialCode = r.MaterialCode,
|
||||
MaterialName = m == null ? string.Empty : m.MaterialName,
|
||||
MaterialSpec = m == null ? string.Empty : m.MaterialSpec,
|
||||
MaterialMade = m == null ? string.Empty : m.MaterialMade,
|
||||
MaterialDef = m == null ? string.Empty : m.MaterialDef,
|
||||
MaterialUnit = m == null ? string.Empty : m.MaterialUnit,
|
||||
HeatNo = m == null ? string.Empty : m.HeatNo,
|
||||
BatchNo = m == null ? string.Empty : m.BatchNo,
|
||||
Code = m == null ? string.Empty : m.Code,
|
||||
AnticorrosionLevel = r.AnticorrosionLevel,
|
||||
PaintId = r.PaintId,
|
||||
PaintCode = paint == null ? string.Empty : paint.PaintCode,
|
||||
Primer = paint == null ? string.Empty : paint.Primer,
|
||||
IntermediatePaint = paint == null ? string.Empty : paint.IntermediatePaint,
|
||||
Topcoat = paint == null ? string.Empty : paint.Topcoat,
|
||||
ColorCode = paint == null ? string.Empty : paint.ColorCode,
|
||||
FilmThickness = r.FilmThickness,
|
||||
SandBlasting = r.SandBlasting,
|
||||
RustSandBlasting = r.RustSandBlasting,
|
||||
CheckResult = r.CheckResult,
|
||||
CheckPerson = r.CheckPerson,
|
||||
CheckPersonName = person == null ? string.Empty : person.PersonName,
|
||||
CheckTime = r.CheckTime,
|
||||
UnqualifiedReason = r.UnqualifiedReason,
|
||||
RectifyRequirement = r.RectifyRequirement,
|
||||
Remark = r.Remark,
|
||||
CreateUser = r.CreateUser,
|
||||
CreateTime = r.CreateTime
|
||||
};
|
||||
var data = query.ToList();
|
||||
foreach (var item in data)
|
||||
{
|
||||
item.AttachUrl1 = GetInspectionAttachUrl(db, Const.Tw_AntiCorrosionCheckRecordMenuId, item.AntiCorrosionCheckId);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存防腐检查,始终新增一条历史记录
|
||||
/// </summary>
|
||||
public static string SaveAntiCorrosionCheck(Model.AntiCorrosionCheckRecordInput item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException("item");
|
||||
}
|
||||
if (string.IsNullOrEmpty(item.MaterialCode))
|
||||
{
|
||||
throw new ArgumentException("材料编码不能为空。");
|
||||
}
|
||||
if (string.IsNullOrEmpty(item.PaintId))
|
||||
{
|
||||
throw new ArgumentException("防腐代码不能为空。");
|
||||
}
|
||||
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
if (!db.Tw_PaintCodeDict.Any(x => x.Id == item.PaintId && x.IsUsed))
|
||||
{
|
||||
throw new ArgumentException("防腐代码不存在或已停用。");
|
||||
}
|
||||
|
||||
var check = string.IsNullOrEmpty(item.AntiCorrosionCheckId)
|
||||
? null
|
||||
: db.HJGL_AntiCorrosionCheckRecord.FirstOrDefault(x => x.AntiCorrosionCheckId == item.AntiCorrosionCheckId);
|
||||
if (check == null)
|
||||
{
|
||||
check = new Model.HJGL_AntiCorrosionCheckRecord
|
||||
{
|
||||
AntiCorrosionCheckId = string.IsNullOrEmpty(item.AntiCorrosionCheckId) ? Guid.NewGuid().ToString() : item.AntiCorrosionCheckId,
|
||||
CreateTime = DateTime.Now
|
||||
};
|
||||
db.HJGL_AntiCorrosionCheckRecord.InsertOnSubmit(check);
|
||||
}
|
||||
|
||||
var materialId = item.MaterialId;
|
||||
|
||||
check.ProjectId = item.ProjectId;
|
||||
check.MaterialId = materialId;
|
||||
check.MaterialCode = item.MaterialCode;
|
||||
check.AnticorrosionLevel = item.AnticorrosionLevel;
|
||||
check.PaintId = item.PaintId;
|
||||
check.FilmThickness = item.FilmThickness;
|
||||
check.SandBlasting = item.SandBlasting;
|
||||
check.RustSandBlasting = item.RustSandBlasting;
|
||||
check.CheckResult = item.CheckResult;
|
||||
check.CheckPerson = item.CheckPerson;
|
||||
check.CheckTime = item.CheckTime ?? DateTime.Now;
|
||||
check.UnqualifiedReason = item.UnqualifiedReason;
|
||||
check.RectifyRequirement = item.RectifyRequirement;
|
||||
check.Remark = item.Remark;
|
||||
check.CreateUser = string.IsNullOrEmpty(item.CreateUser) ? item.CheckPerson : item.CreateUser;
|
||||
db.SubmitChanges();
|
||||
SaveInspectionAttachUrl(item.AttachUrl1, Const.Tw_AntiCorrosionCheckRecordMenuId, check.AntiCorrosionCheckId);
|
||||
return check.AntiCorrosionCheckId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存检查附件
|
||||
/// </summary>
|
||||
private static void SaveInspectionAttachUrl(string attachUrl, string menuId, string dataId)
|
||||
{
|
||||
if (attachUrl == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(attachUrl))
|
||||
{
|
||||
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(attachUrl, 10, null), attachUrl, menuId, dataId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonService.DeleteAttachFileById(menuId, dataId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据菜单和记录ID获取检查附件地址
|
||||
/// </summary>
|
||||
private static string GetInspectionAttachUrl(Model.SGGLDB db, string menuId, string dataId)
|
||||
{
|
||||
var attachUrl = db.AttachFile
|
||||
.Where(x => x.MenuId == menuId && x.ToKeyId == dataId)
|
||||
.Select(x => x.AttachUrl)
|
||||
.FirstOrDefault();
|
||||
return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user