632 lines
26 KiB
C#
632 lines
26 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
|
|
namespace BLL
|
|
{
|
|
public static class WeldJointService
|
|
{
|
|
public static List<Model.HJGL_WeldJoint> hJGL_WeldJoints
|
|
{
|
|
|
|
get;
|
|
set;
|
|
|
|
}
|
|
/// <summary>
|
|
/// 根据焊口Id获取焊口信息
|
|
/// </summary>
|
|
/// <param name="weldJointId"></param>
|
|
/// <returns></returns>
|
|
public static Model.HJGL_WeldJoint GetWeldJointByWeldJointId(string weldJointId)
|
|
{
|
|
return Funs.DB.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 判断焊口号是否已存在
|
|
/// </summary>
|
|
/// <param name="isoNo"></param>
|
|
/// <returns></returns>
|
|
public static bool IsExistWeldJointCode(string weldJointCode, string pipelineId, string weldJointId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint jot = null;
|
|
if (!string.IsNullOrEmpty(weldJointId))
|
|
{
|
|
jot = Funs.DB.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointCode == weldJointCode && x.PipelineId == pipelineId && x.WeldJointId != weldJointId);
|
|
}
|
|
else
|
|
{
|
|
jot = Funs.DB.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointCode == weldJointCode && x.PipelineId == pipelineId);
|
|
}
|
|
|
|
if (jot != null)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊接日报获取焊口数
|
|
/// </summary>
|
|
/// <param name="weldingDailyId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.HJGL_WeldJoint> GetWeldlinesByWeldingDailyId(string weldingDailyId)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineId, x.WeldJointCode select x).ToList();
|
|
return q;
|
|
}
|
|
public static List<Model.HJGL_WeldJoint> GetWeldJointsByPipelineId(string PipelineId)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == PipelineId select x).ToList();
|
|
return q;
|
|
}
|
|
|
|
public static Model.HJGL_WeldJoint GetWeldJointsByWeldJointCode(string PipelineId, string WeldJointCode)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_WeldJoint where x.PipelineId == PipelineId && x.WeldJointCode == WeldJointCode select x).FirstOrDefault();
|
|
|
|
return q;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 添加
|
|
/// </summary>
|
|
/// <param name="weldJoint"></param>
|
|
public static void AddWeldJoint(Model.HJGL_WeldJoint weldJoint)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint newWeldJoint = new Model.HJGL_WeldJoint
|
|
{
|
|
ProjectId = weldJoint.ProjectId,
|
|
PipelineId = weldJoint.PipelineId,
|
|
PipelineCode = weldJoint.PipelineCode,
|
|
WeldJointCode = weldJoint.WeldJointCode,
|
|
WeldTypeId = weldJoint.WeldTypeId,
|
|
Material1Id = weldJoint.Material1Id,
|
|
Material2Id = weldJoint.Material2Id,
|
|
Thickness = weldJoint.Thickness,
|
|
Dia = weldJoint.Dia,
|
|
DNDia = weldJoint.DNDia,
|
|
Size = weldJoint.Size,
|
|
DetectionTypeId = weldJoint.DetectionTypeId,
|
|
JointArea = weldJoint.JointArea,
|
|
WeldingMethodId = weldJoint.WeldingMethodId,
|
|
WeldingLocationId = weldJoint.WeldingLocationId,
|
|
JointAttribute = weldJoint.JointAttribute,
|
|
IsHotProess = weldJoint.IsHotProess,
|
|
WeldingWire = weldJoint.WeldingWire,
|
|
WeldingRod = weldJoint.WeldingRod,
|
|
DesignIsHotProess = weldJoint.DesignIsHotProess,
|
|
GrooveTypeId = weldJoint.GrooveTypeId,
|
|
Specification = weldJoint.Specification,
|
|
WPQId = weldJoint.WPQId,
|
|
HeartNo1 = weldJoint.HeartNo1,
|
|
HeartNo2 = weldJoint.HeartNo2,
|
|
BaseWeldJointId = weldJoint.BaseWeldJointId,
|
|
Components1Id = weldJoint.Components1Id,
|
|
Components2Id = weldJoint.Components2Id,
|
|
PreTemperature = weldJoint.PreTemperature,
|
|
Remark = weldJoint.Remark,
|
|
IsTwoJoint = weldJoint.IsTwoJoint,
|
|
SubmitMan = weldJoint.SubmitMan,
|
|
TwoJointType = weldJoint.TwoJointType,
|
|
CoverWelderTeamGroupId = weldJoint.CoverWelderTeamGroupId,
|
|
BackingWelderTeamGroupId = weldJoint.BackingWelderTeamGroupId
|
|
};
|
|
if (!string.IsNullOrEmpty(weldJoint.WeldJointId))
|
|
{
|
|
newWeldJoint.WeldJointId = weldJoint.WeldJointId;
|
|
}
|
|
else
|
|
{
|
|
newWeldJoint.WeldJointId = SQLHelper.GetNewID(typeof(Model.HJGL_WeldJoint));
|
|
}
|
|
db.HJGL_WeldJoint.InsertOnSubmit(newWeldJoint);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
public static void AddBulkWeldJoint(List<Model.HJGL_WeldJoint> weldJoints)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
db.HJGL_WeldJoint.InsertAllOnSubmit(weldJoints);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改
|
|
/// </summary>
|
|
/// <param name="weldJoint"></param>
|
|
public static void UpdateWeldJoint(Model.HJGL_WeldJoint weldJoint)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId);
|
|
if (newWeldJoint != null)
|
|
{
|
|
newWeldJoint.WeldJointCode = weldJoint.WeldJointCode;
|
|
newWeldJoint.ProjectId = weldJoint.ProjectId;
|
|
newWeldJoint.PipelineCode = weldJoint.PipelineCode;
|
|
newWeldJoint.WPQId = weldJoint.WPQId;
|
|
newWeldJoint.WeldTypeId = weldJoint.WeldTypeId;
|
|
newWeldJoint.Material1Id = weldJoint.Material1Id;
|
|
newWeldJoint.Material2Id = weldJoint.Material2Id;
|
|
newWeldJoint.Thickness = weldJoint.Thickness;
|
|
newWeldJoint.Dia = weldJoint.Dia;
|
|
newWeldJoint.DNDia = weldJoint.DNDia;
|
|
newWeldJoint.Size = weldJoint.Size;
|
|
newWeldJoint.DetectionTypeId = weldJoint.DetectionTypeId;
|
|
newWeldJoint.JointArea = weldJoint.JointArea;
|
|
newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId;
|
|
newWeldJoint.IsHotProess = weldJoint.IsHotProess;
|
|
newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId;
|
|
newWeldJoint.JointAttribute = weldJoint.JointAttribute;
|
|
newWeldJoint.DesignIsHotProess = weldJoint.DesignIsHotProess;
|
|
newWeldJoint.WeldingWire = weldJoint.WeldingWire;
|
|
newWeldJoint.WeldingRod = weldJoint.WeldingRod;
|
|
newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId;
|
|
newWeldJoint.HeartNo1 = weldJoint.HeartNo1;
|
|
newWeldJoint.HeartNo2 = weldJoint.HeartNo2;
|
|
newWeldJoint.Components1Id = weldJoint.Components1Id;
|
|
newWeldJoint.Components2Id = weldJoint.Components2Id;
|
|
newWeldJoint.BackingWelderId = weldJoint.BackingWelderId;
|
|
newWeldJoint.CoverWelderId = weldJoint.CoverWelderId;
|
|
newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId;
|
|
newWeldJoint.WeldingMode = weldJoint.WeldingMode;
|
|
newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode;
|
|
newWeldJoint.Specification = weldJoint.Specification;
|
|
newWeldJoint.PreTemperature = weldJoint.PreTemperature;
|
|
newWeldJoint.Remark = weldJoint.Remark;
|
|
newWeldJoint.AttachUrl = weldJoint.AttachUrl;
|
|
newWeldJoint.SubmitMan = weldJoint.SubmitMan;
|
|
newWeldJoint.TwoJointType = weldJoint.TwoJointType;
|
|
newWeldJoint.CoverWelderTeamGroupId = weldJoint.CoverWelderTeamGroupId;
|
|
newWeldJoint.BackingWelderTeamGroupId = weldJoint.BackingWelderTeamGroupId;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新施工焊口信息
|
|
/// </summary>
|
|
/// <param name="weldJoint"></param>
|
|
public static void UpdateConWeldJoint(Model.HJGL_WeldJoint weldJoint)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId);
|
|
if (newWeldJoint != null)
|
|
{
|
|
newWeldJoint.WPQId = weldJoint.WPQId;
|
|
newWeldJoint.MatchableWPQ = weldJoint.MatchableWPQ;
|
|
newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId;
|
|
newWeldJoint.IsHotProess = weldJoint.IsHotProess;
|
|
newWeldJoint.WeldingWire = weldJoint.WeldingWire;
|
|
newWeldJoint.WeldingRod = weldJoint.WeldingRod;
|
|
newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId;
|
|
newWeldJoint.PreTemperature = weldJoint.PreTemperature;
|
|
newWeldJoint.Remark = weldJoint.Remark;
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 回写焊口信息
|
|
/// </summary>
|
|
/// <param name="weldJoint"></param>
|
|
public static void WriteBackWeldJoint(Model.HJGL_WeldJoint weldJoint)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId);
|
|
if (newWeldJoint != null)
|
|
{
|
|
newWeldJoint.BackingWelderId = weldJoint.BackingWelderId;
|
|
newWeldJoint.CoverWelderId = weldJoint.CoverWelderId;
|
|
newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId;
|
|
newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode;
|
|
newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId;
|
|
newWeldJoint.JointAttribute = weldJoint.JointAttribute;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 二次焊口审核
|
|
/// </summary>
|
|
/// <param name="jointId"></param>
|
|
/// <param name="auditMan"></param>
|
|
/// <param name="auditDate"></param>
|
|
public static void UpdateJointAudit(string jointId, string auditMan, DateTime? auditDate)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == jointId);
|
|
if (newWeldJoint != null)
|
|
{
|
|
newWeldJoint.AuditMan = auditMan;
|
|
newWeldJoint.AuditDate = auditDate;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 二次焊口施工经理审核
|
|
/// </summary>
|
|
/// <param name="jointId"></param>
|
|
/// <param name="auditMan"></param>
|
|
/// <param name="auditDate"></param>
|
|
public static void UpdateJointAudit2(string jointId, string auditMan, DateTime? auditDate)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint newWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == jointId);
|
|
if (newWeldJoint != null)
|
|
{
|
|
newWeldJoint.AuditMan2 = auditMan;
|
|
newWeldJoint.AuditDate2 = auditDate;
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键删除焊口信息
|
|
/// </summary>
|
|
/// <param name="weldJointId"></param>
|
|
public static void DeleteWeldJointById(string weldJointId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.HJGL_WeldJoint weldline = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId);
|
|
if (weldline != null)
|
|
{
|
|
db.HJGL_WeldJoint.DeleteOnSubmit(weldline);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 根据管线删除焊口信息
|
|
/// </summary>
|
|
/// <param name="weldJointId"></param>
|
|
public static void DeleteWeldJointByPipelineId(string pipelineId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var weldline = db.HJGL_WeldJoint.Where(e => e.PipelineId == pipelineId);
|
|
if (weldline != null)
|
|
{
|
|
db.HJGL_WeldJoint.DeleteAllOnSubmit(weldline);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据unitworkid删除焊口
|
|
/// </summary>
|
|
/// <param name="unitworkId"></param>
|
|
public static void DeleteWeldJointByUnitWorkId(string unitworkId)
|
|
{
|
|
var oldPipeline = BLL.PipelineService.GetPipelinesByUnitWordId(unitworkId);
|
|
if (oldPipeline != null)
|
|
{
|
|
foreach (var pipeline in oldPipeline)
|
|
{
|
|
BLL.WeldJointService.DeleteWeldJointByPipelineId(pipeline.PipelineId); //删除原有管线对应焊口
|
|
}
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 更新焊口号 固定焊口号后 +G
|
|
/// </summary>
|
|
/// <param name="jotId">焊口id</param>
|
|
/// <param name="jointAttribute">焊口属性</param>
|
|
/// <param name="operateState">日报操作(增加、删除)</param>
|
|
public static void UpdateWeldJointAddG(string weldJointId, string jointAttribute, string operateState)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
if (operateState == Const.BtnDelete || jointAttribute != "安装口")
|
|
{
|
|
Model.HJGL_WeldJoint deleteWeldJoint = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId);
|
|
if (deleteWeldJoint.WeldJointCode.Last() == 'G')
|
|
{
|
|
deleteWeldJoint.WeldJointCode = deleteWeldJoint.WeldJointCode.Substring(0, deleteWeldJoint.WeldJointCode.Length - 1);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Model.HJGL_WeldJoint addJointInfo = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId);
|
|
if (addJointInfo.WeldJointCode.Last() != 'G')
|
|
{
|
|
addJointInfo.WeldJointCode += "G";
|
|
}
|
|
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据主键获取焊口信息视图
|
|
/// </summary>
|
|
/// <param name="weldJointId"></param>
|
|
/// <returns></returns>
|
|
public static Model.View_HJGL_WeldJoint GetViewWeldJointById(string weldJointId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
return db.View_HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId);
|
|
}
|
|
public static List<Model.HJGL_WeldJoint> GetWeldJointByUnitworkId(string UnitWorkId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var q = (from x in db.HJGL_WeldJoint
|
|
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId into tt
|
|
from g in tt.DefaultIfEmpty()
|
|
where g.UnitWorkId == UnitWorkId
|
|
select x).ToList();
|
|
|
|
return q;
|
|
}
|
|
public static List<Model.HJGL_WeldJoint> GetWeldJointByProjectid(string ProjectId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
|
|
var q = (from x in db.HJGL_WeldJoint
|
|
where x.ProjectId == ProjectId
|
|
select x).ToList();
|
|
return q;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊口Id获取插入焊口数
|
|
/// </summary>
|
|
/// <param name="weldingDailyId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.HJGL_WeldJoint> GetBaseWeldJointsByWeldJointId(string weldJointId)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_WeldJoint where x.BaseWeldJointId == weldJointId orderby x.WeldJointCode select x).ToList();
|
|
return q;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊接日报获取焊口数
|
|
/// </summary>
|
|
/// <param name="weldingDailyId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.HJGL_WeldJoint> GetWeldJointsByWeldingDailyId(string weldingDailyId)
|
|
{
|
|
var q = (from x in Funs.DB.HJGL_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineId, x.WeldJointCode select x).ToList();
|
|
return q;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据焊接日报获取焊口数
|
|
/// </summary>
|
|
/// <param name="dreportId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.View_HJGL_WeldJoint> GetViewWeldJointsByWeldingDailyId(string weldingDailyId)
|
|
{
|
|
var q = (from x in Funs.DB.View_HJGL_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineCode, x.WeldJointCode select x).ToList();
|
|
return q;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前焊工工作量是否超过60寸的焊接人员
|
|
/// </summary>
|
|
/// <param name="projectId">项目id</param>
|
|
/// <param name="unitId">单位id</param>
|
|
/// <param name="jot_Id">焊口ID</param>
|
|
/// <param name="jotDate">焊接日期</param>
|
|
/// <returns></returns>
|
|
public static bool GetWelderLimitDN(string projectId, string welderId, DateTime weldingDate)
|
|
{
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
{
|
|
var jots = from x in db.HJGL_WeldJoint
|
|
join y in db.HJGL_WeldingDaily on x.WeldingDailyId equals y.WeldingDailyId
|
|
where x.ProjectId == projectId && y.WeldingDate == weldingDate && (welderId == x.CoverWelderId || welderId == x.BackingWelderId)
|
|
select x;
|
|
decimal? count = jots.Sum(x => x.Size);
|
|
if (count >= 60)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据管线ID获取焊口信息
|
|
/// </summary>
|
|
/// <param name="pipelineId"></param>
|
|
/// <returns></returns>
|
|
public static List<Model.View_HJGL_WeldJoint> GetViewWeldJointsByPipelineId(string pipelineId)
|
|
{
|
|
var q = (from x in Funs.DB.View_HJGL_WeldJoint where x.PipelineId == pipelineId orderby x.WeldJointCode select x).ToList();
|
|
return q;
|
|
}
|
|
public static List<Model.View_HJGL_WeldJoint> GetViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model)
|
|
{
|
|
var baseQuery = from x in Funs.DB.View_HJGL_WeldJoint select x;
|
|
if (!string.IsNullOrEmpty(model.ProjectId))
|
|
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
|
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
|
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
|
if (!string.IsNullOrEmpty(model.PipelineId))
|
|
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
|
if (!string.IsNullOrEmpty(model.PipelineCode))
|
|
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode));
|
|
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
|
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode));
|
|
|
|
return baseQuery.ToList();
|
|
}
|
|
public static IEnumerable<Model.View_HJGL_WeldJoint> GetIEnumerableViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model)
|
|
{
|
|
var baseQuery = from x in Funs.DB.View_HJGL_WeldJoint select x;
|
|
if (!string.IsNullOrEmpty(model.ProjectId))
|
|
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
|
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
|
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
|
if (!string.IsNullOrEmpty(model.PipelineId))
|
|
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
|
if (!string.IsNullOrEmpty(model.PipelineCode))
|
|
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode));
|
|
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
|
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode));
|
|
|
|
return baseQuery.ToList() ;
|
|
}
|
|
public static (List<Model.View_HJGL_WeldJoint> Data, int Total)GetDataBymodel(Model.View_HJGL_WeldJoint model, int pageIndex = 0, int pageSize = 20)
|
|
{
|
|
// 阶段一:构建基础查询
|
|
var baseQuery = Funs.DB.View_HJGL_WeldJoint.AsQueryable();
|
|
|
|
// 阶段二:构建动态查询条件
|
|
if (!string.IsNullOrEmpty(model.ProjectId))
|
|
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
|
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
|
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
|
if (!string.IsNullOrEmpty(model.PipelineId))
|
|
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
|
if (!string.IsNullOrEmpty(model.PipelineCode))
|
|
baseQuery = baseQuery.Where(x => x.PipelineCode .Contains(model.PipelineCode));
|
|
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
|
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains( model.WeldJointCode));
|
|
|
|
// 阶段三:排序与分页控制(索引优化关键)
|
|
var orderedQuery = baseQuery.OrderBy(x => x.WeldJointCode);
|
|
|
|
// 阶段四:分页执行(数据库层面分页)
|
|
var pagedData = orderedQuery
|
|
.Skip((pageIndex ) * pageSize)
|
|
.Take(pageSize)
|
|
.ToList();
|
|
|
|
// 获取总记录数(延迟计数优化)
|
|
var totalCount = baseQuery.Count();
|
|
|
|
return (pagedData, totalCount);
|
|
}
|
|
public static List<Model.View_HJGL_WeldJoint> GetViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model, int pageIndex = 0, int pageSize = 20)
|
|
{
|
|
// 阶段一:构建基础查询
|
|
var baseQuery = Funs.DB.View_HJGL_WeldJoint.AsQueryable();
|
|
|
|
// 阶段二:构建动态查询条件
|
|
if (!string.IsNullOrEmpty(model.ProjectId))
|
|
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
|
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
|
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
|
if (!string.IsNullOrEmpty(model.PipelineId))
|
|
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
|
if (!string.IsNullOrEmpty(model.PipelineCode))
|
|
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode));
|
|
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
|
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode));
|
|
|
|
// 阶段三:排序与分页控制(索引优化关键)
|
|
var orderedQuery = baseQuery.OrderBy(x => x.WeldJointCode);
|
|
|
|
// 阶段四:分页执行(数据库层面分页)
|
|
var pagedData = orderedQuery
|
|
.Skip((pageIndex) * pageSize)
|
|
.Take(pageSize)
|
|
.ToList();
|
|
|
|
return pagedData;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据壁厚计算焊口达因
|
|
/// </summary>
|
|
/// <param name="weldJointId"></param>
|
|
/// <returns></returns>
|
|
public static double GetSizeByThickness(decimal? size, decimal thickness)
|
|
{
|
|
double n = 0;
|
|
if (thickness <= 8)
|
|
{
|
|
n = 1;
|
|
}
|
|
else if (thickness > 8 && thickness < 12)
|
|
{
|
|
n = 1.2;
|
|
}
|
|
else if (thickness >= 12 && thickness < 16)
|
|
{
|
|
n = 1.3;
|
|
}
|
|
else if (thickness >= 16 && thickness < 19)
|
|
{
|
|
n = 1.5;
|
|
}
|
|
else if (thickness >= 19 && thickness < 23)
|
|
{
|
|
n = 2;
|
|
}
|
|
else if (thickness >= 23 && thickness < 27)
|
|
{
|
|
n = 3;
|
|
}
|
|
else if (thickness >= 27 && thickness < 31)
|
|
{
|
|
n = 4;
|
|
}
|
|
else if (thickness >= 31 && thickness < 35)
|
|
{
|
|
n = 5;
|
|
}
|
|
else if (thickness >= 35 && thickness < 39)
|
|
{
|
|
n = 6;
|
|
}
|
|
else if (thickness >= 39 && thickness < 43)
|
|
{
|
|
n = 7;
|
|
}
|
|
else if (thickness >= 43 && thickness < 47)
|
|
{
|
|
n = 8;
|
|
}
|
|
else if (thickness >= 47 && thickness < 51)
|
|
{
|
|
n = 9;
|
|
}
|
|
else if (thickness >= 51 && thickness < 55)
|
|
{
|
|
n = 10;
|
|
}
|
|
else if (thickness >= 55 && thickness < 59)
|
|
{
|
|
n = 11;
|
|
}
|
|
else if (thickness >= 59 && thickness < 63)
|
|
{
|
|
n = 12;
|
|
}
|
|
return Convert.ToDouble(size) * n;
|
|
}
|
|
|
|
public static string GetWPQCodeByWeldJointId(object WeldJointId)
|
|
{
|
|
string result = "";
|
|
if (WeldJointId != null)
|
|
{
|
|
var model = GetViewWeldJointById(WeldJointId.ToString());
|
|
result = model?.WPQCode;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|