ZHJA_HJGL/HJGL_ZH/BLL/HJGL/WeldingManage/HJGL_PW_JointInfoService.cs

1329 lines
52 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace BLL
{
/// <summary>
/// 焊口信息初始化
/// </summary>
public static class HJGL_PW_JointInfoService
{
/// <summary>
/// 根据焊口Id获取焊口信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_PW_JointInfo GetJointInfoByJotID(string jot_id)
{
return Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_id);
}
/// <summary>
/// 添加
/// </summary>
/// <param name="jointInfo"></param>
public static void AddJointInfo(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = new Model.HJGL_PW_JointInfo();
//newJointInfo.JOT_ID = SQLHelper.GetNewID(typeof(Model.HJGL_PW_JointInfo));
newJointInfo.JOT_ID = jointInfo.JOT_ID;
newJointInfo.ProjectId = jointInfo.ProjectId;
newJointInfo.JOT_JointNo = jointInfo.JOT_JointNo;
newJointInfo.DReportID = jointInfo.DReportID;
newJointInfo.ISO_ID = jointInfo.ISO_ID;
newJointInfo.STE_ID = jointInfo.STE_ID;
newJointInfo.STE_ID2 = jointInfo.STE_ID2;
newJointInfo.JOT_CellWelder = jointInfo.JOT_CellWelder;
newJointInfo.JOT_FloorWelder = jointInfo.JOT_FloorWelder;
newJointInfo.WLO_Code = jointInfo.WLO_Code;
newJointInfo.JOT_DoneDin = jointInfo.JOT_DoneDin;
newJointInfo.IS_Compute = jointInfo.IS_Compute;
newJointInfo.JOT_Component1 = jointInfo.JOT_Component1;
newJointInfo.JOT_Component2 = jointInfo.JOT_Component2;
newJointInfo.JOT_WeldMat = jointInfo.JOT_WeldMat;
newJointInfo.JOT_JointStatus = "100";//jointInfo.JOT_JointStatus;
newJointInfo.JOT_Dia = jointInfo.JOT_Dia;
newJointInfo.JOT_Size = jointInfo.JOT_Size;
newJointInfo.JOT_Sch = jointInfo.JOT_Sch;
newJointInfo.JOT_FactSch = jointInfo.JOT_FactSch;
newJointInfo.JOT_JointFlag = jointInfo.JOT_JointFlag;
newJointInfo.JOT_TrustFlag = jointInfo.JOT_TrustFlag;
newJointInfo.JOT_JointDesc = jointInfo.JOT_JointDesc;
newJointInfo.JOT_WeldSilk = jointInfo.JOT_WeldSilk;
newJointInfo.JOTY_ID = jointInfo.JOTY_ID;
newJointInfo.JOT_CheckFlag = jointInfo.JOT_CheckFlag;
newJointInfo.JOT_RepairFlag = jointInfo.JOT_RepairFlag;
newJointInfo.WME_ID = jointInfo.WME_ID;
newJointInfo.JST_ID = jointInfo.JST_ID;
newJointInfo.IS_Proess = jointInfo.IS_Proess;
newJointInfo.ProessTypes = jointInfo.ProessTypes;
newJointInfo.JOT_PrepareTemp = jointInfo.JOT_PrepareTemp;
newJointInfo.JOT_CellTemp = jointInfo.JOT_CellTemp;
newJointInfo.JOT_LastTemp = jointInfo.JOT_LastTemp;
newJointInfo.JOT_JointAttribute = jointInfo.JOT_JointAttribute;
newJointInfo.JOT_Remark = jointInfo.JOT_Remark;
newJointInfo.JOT_Location = jointInfo.JOT_Location;
newJointInfo.InstallationId = jointInfo.InstallationId;
newJointInfo.NDTR_ID = jointInfo.NDTR_ID;
newJointInfo.IsSpecial = jointInfo.IsSpecial;
newJointInfo.JOT_QualifiedLevel = jointInfo.JOT_QualifiedLevel;
newJointInfo.WeldL = jointInfo.WeldL;
newJointInfo.JOT_Electricity = jointInfo.JOT_Electricity;
newJointInfo.JOT_Voltage = jointInfo.JOT_Voltage;
newJointInfo.PressureTestPackageNo = jointInfo.PressureTestPackageNo;
db.HJGL_PW_JointInfo.InsertOnSubmit(newJointInfo);
db.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="jointInfo"></param>
public static void UpdateJointInfo(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jointInfo.JOT_ID);
if (newJointInfo != null)
{
newJointInfo.JOT_JointNo = jointInfo.JOT_JointNo;
newJointInfo.DReportID = jointInfo.DReportID;
newJointInfo.ISO_ID = jointInfo.ISO_ID;
newJointInfo.STE_ID = jointInfo.STE_ID;
newJointInfo.STE_ID2 = jointInfo.STE_ID2;
newJointInfo.JOT_CellWelder = jointInfo.JOT_CellWelder;
newJointInfo.JOT_FloorWelder = jointInfo.JOT_FloorWelder;
newJointInfo.WLO_Code = jointInfo.WLO_Code;
newJointInfo.JOT_DoneDin = jointInfo.JOT_DoneDin;
newJointInfo.IS_Compute = jointInfo.IS_Compute;
newJointInfo.JOT_Component1 = jointInfo.JOT_Component1;
newJointInfo.JOT_Component2 = jointInfo.JOT_Component2;
newJointInfo.JOT_WeldMat = jointInfo.JOT_WeldMat;
newJointInfo.JOT_Dia = jointInfo.JOT_Dia;
newJointInfo.JOT_Size = jointInfo.JOT_Size;
newJointInfo.JOT_Sch = jointInfo.JOT_Sch;
newJointInfo.JOT_FactSch = jointInfo.JOT_FactSch;
newJointInfo.JOT_JointFlag = jointInfo.JOT_JointFlag;
newJointInfo.JOT_TrustFlag = jointInfo.JOT_TrustFlag;
newJointInfo.JOT_JointDesc = jointInfo.JOT_JointDesc;
newJointInfo.JOT_WeldSilk = jointInfo.JOT_WeldSilk;
newJointInfo.JOTY_ID = jointInfo.JOTY_ID;
newJointInfo.JOT_CheckFlag = jointInfo.JOT_CheckFlag;
newJointInfo.JOT_RepairFlag = jointInfo.JOT_RepairFlag;
newJointInfo.WME_ID = jointInfo.WME_ID;
newJointInfo.JST_ID = jointInfo.JST_ID;
newJointInfo.IS_Proess = jointInfo.IS_Proess;
newJointInfo.ProessTypes = jointInfo.ProessTypes;
newJointInfo.JOT_PrepareTemp = jointInfo.JOT_PrepareTemp;
newJointInfo.JOT_CellTemp = jointInfo.JOT_CellTemp;
newJointInfo.JOT_LastTemp = jointInfo.JOT_LastTemp;
newJointInfo.JOT_JointAttribute = jointInfo.JOT_JointAttribute;
newJointInfo.JOT_Remark = jointInfo.JOT_Remark;
newJointInfo.JOT_Location = jointInfo.JOT_Location;
newJointInfo.InstallationId = jointInfo.InstallationId;
newJointInfo.NDTR_ID = jointInfo.NDTR_ID;
newJointInfo.IsSpecial = jointInfo.IsSpecial;
newJointInfo.JOT_QualifiedLevel = jointInfo.JOT_QualifiedLevel;
newJointInfo.WeldL = jointInfo.WeldL;
newJointInfo.PressureTestPackageNo = jointInfo.PressureTestPackageNo;
db.SubmitChanges();
}
}
/// <summary>
/// 修改更新导入焊口
/// </summary>
/// <param name="jointInfo"></param>
public static void UpdateExportJoint(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jointInfo.JOT_ID);
if (newJointInfo != null)
{
newJointInfo.STE_ID = jointInfo.STE_ID;
newJointInfo.STE_ID2 = jointInfo.STE_ID2;
newJointInfo.JOTY_ID = jointInfo.JOTY_ID;
newJointInfo.WLO_Code = jointInfo.WLO_Code;
newJointInfo.JOT_JointAttribute = jointInfo.JOT_JointAttribute;
newJointInfo.JOT_Size = jointInfo.JOT_Size;
newJointInfo.JOT_JointDesc = jointInfo.JOT_JointDesc;
newJointInfo.JOT_Sch = jointInfo.JOT_Sch;
newJointInfo.WME_ID = jointInfo.WME_ID;
newJointInfo.JOT_WeldMat = jointInfo.JOT_WeldMat;
newJointInfo.JOT_WeldSilk = jointInfo.JOT_WeldSilk;
newJointInfo.JST_ID = jointInfo.JST_ID;
newJointInfo.JOT_Component1 = jointInfo.JOT_Component1;
newJointInfo.JOT_Component2 = jointInfo.JOT_Component2;
newJointInfo.JOT_PrepareTemp = jointInfo.JOT_PrepareTemp;
newJointInfo.IS_Proess = jointInfo.IS_Proess;
newJointInfo.JOT_Location = jointInfo.JOT_Location;
newJointInfo.JOT_Dia = jointInfo.JOT_Dia;
newJointInfo.InstallationId = jointInfo.InstallationId;
newJointInfo.NDTR_ID = jointInfo.NDTR_ID;
newJointInfo.IsSpecial = jointInfo.IsSpecial;
db.SubmitChanges();
}
}
/// <summary>
/// 批量添加焊口信息
/// </summary>
/// <param name="jointInfo"></param>
public static void AddJointInfoFatch(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = new Model.HJGL_PW_JointInfo();
string NewKeyID = SQLHelper.GetNewID(typeof(Model.HJGL_PW_JointInfo));
newJointInfo.JOT_ID = NewKeyID;
newJointInfo.ProjectId = jointInfo.ProjectId;
newJointInfo.ISO_ID = jointInfo.ISO_ID;
newJointInfo.JOT_JointNo = jointInfo.JOT_JointNo;
newJointInfo.WLO_Code = jointInfo.WLO_Code;
newJointInfo.STE_ID = jointInfo.STE_ID;
newJointInfo.STE_ID2 = jointInfo.STE_ID2;
newJointInfo.JOT_JointDesc = jointInfo.JOT_JointDesc;
newJointInfo.JOTY_ID = jointInfo.JOTY_ID;
newJointInfo.JOT_Size = jointInfo.JOT_Size;
newJointInfo.JOT_Dia = jointInfo.JOT_Dia;
newJointInfo.JOT_JointAttribute = jointInfo.JOT_JointAttribute;
newJointInfo.JOT_Sch = jointInfo.JOT_Sch;
newJointInfo.JOT_TrustFlag = jointInfo.JOT_TrustFlag;
newJointInfo.JOT_CheckFlag = jointInfo.JOT_CheckFlag;
newJointInfo.JOT_JointStatus = jointInfo.JOT_JointStatus;
newJointInfo.JOT_WeldMat = jointInfo.JOT_WeldMat;
newJointInfo.JOT_WeldSilk = jointInfo.JOT_WeldSilk;
newJointInfo.WME_ID = jointInfo.WME_ID;
newJointInfo.InstallationId = jointInfo.InstallationId;
newJointInfo.NDTR_ID = jointInfo.NDTR_ID;
newJointInfo.IsSpecial = jointInfo.IsSpecial;
db.HJGL_PW_JointInfo.InsertOnSubmit(newJointInfo);
db.SubmitChanges();
}
/// <summary>
/// 删除
/// </summary>
/// <param name="jot_id"></param>
public static void DeleteJointInfo(string jot_id)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo jointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_id);
db.HJGL_PW_JointInfo.DeleteOnSubmit(jointInfo);
db.SubmitChanges();
}
/// <summary>
/// 修改
/// </summary>
/// <param name="jointInfo"></param>
public static void UpdateJointInfoByDReport(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jointInfo.JOT_ID);
if (newJointInfo != null)
{
newJointInfo.JOT_JointNo = jointInfo.JOT_JointNo;
newJointInfo.DReportID = jointInfo.DReportID;
newJointInfo.JOT_CellWelder = jointInfo.JOT_CellWelder;
newJointInfo.JOT_FloorWelder = jointInfo.JOT_FloorWelder;
newJointInfo.WLO_Code = jointInfo.WLO_Code;
newJointInfo.JOT_DoneDin = jointInfo.JOT_DoneDin;
newJointInfo.JOT_JointAttribute = jointInfo.JOT_JointAttribute;
newJointInfo.JOT_JointStatus = jointInfo.JOT_JointStatus;
newJointInfo.JOT_Location = jointInfo.JOT_Location;
newJointInfo.JOT_Dia = jointInfo.JOT_Dia;
newJointInfo.JOT_Sch = jointInfo.JOT_Sch;
newJointInfo.WME_ID = jointInfo.WME_ID;
newJointInfo.JOT_WeldMat = jointInfo.JOT_WeldMat;
newJointInfo.JOT_WeldSilk = jointInfo.JOT_WeldSilk;
newJointInfo.JOT_Size = jointInfo.JOT_Size;
newJointInfo.JOT_JointDesc = jointInfo.JOT_JointDesc;
db.SubmitChanges();
}
}
/// <summary>
/// 修改焊接热处理备注信息
/// </summary>
/// <param name="jointInfo"></param>
public static void UpdateHotProessRemark(Model.HJGL_PW_JointInfo jointInfo)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jointInfo.JOT_ID);
if (newJointInfo != null)
{
newJointInfo.HotProessRemark = jointInfo.HotProessRemark;
db.SubmitChanges();
}
}
/// <summary>
/// 委托单信息回写
/// </summary>
/// <param name="trustCode"></param>
/// <param name="trustDate"></param>
/// <param name="trustStates"></param>
public static void JointTrustWriteBack(string jotId, string ndtType,string pointType,string trustCode, DateTime? trustDate, string trustStates)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (newJointInfo != null)
{
var ndt = BLL.HJGL_TestingService.GetTestingByTestingId(ndtType);
newJointInfo.PointType = pointType;
if (ndt.SysType == "射线检测")
{
newJointInfo.RT_TrustCode = trustCode;
newJointInfo.RT_TrustDate = trustDate;
newJointInfo.RT_States = trustStates;
}
if (ndt.SysType == "渗透检测")
{
newJointInfo.PT_TrustCode = trustCode;
newJointInfo.PT_TrustDate = trustDate;
newJointInfo.PT_States = trustStates;
}
if (ndt.SysType == "磁粉检测")
{
newJointInfo.MT_TrustCode = trustCode;
newJointInfo.MT_TrustDate = trustDate;
newJointInfo.MT_States = trustStates;
}
if (ndt.SysType == "超声波检测")
{
if (ndt.NDT_Code == "UT")
{
newJointInfo.UT_TrustCode = trustCode;
newJointInfo.UT_TrustDate = trustDate;
newJointInfo.UT_States = trustStates;
}
else
{
newJointInfo.PAUT_TrustCode = trustCode;
newJointInfo.PAUT_TrustDate = trustDate;
newJointInfo.PAUT_States = trustStates;
}
}
db.SubmitChanges();
}
}
/// <summary>
/// 拍片数据回写
/// </summary>
/// <param name="jotId"></param>
/// <param name="num"></param>
public static void JointFileNumWriteBack(string jotId, int filenum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (newJointInfo != null)
{
newJointInfo.RT_FilmNum = filenum;
db.SubmitChanges();
}
}
/// <summary>
/// 回写R母材数量
/// </summary>
/// <param name="jotId"></param>
/// <param name="rnum"></param>
public static void JointRMaterialWriteBack(string jotId, int rnum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (newJointInfo != null)
{
if (newJointInfo.R_Material == null)
{
newJointInfo.R_Material = rnum;
}
else
{
newJointInfo.R_Material = newJointInfo.R_Material + rnum;
}
db.SubmitChanges();
}
}
/// <summary>
/// 检测状态回写
/// </summary>
/// <param name="jotId"></param>
/// <param name="ndtType"></param>
/// <param name="states"></param>
public static void JointCheckStateWriteBack(string jotId, string ndtType, string states)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (newJointInfo != null)
{
var ndt = BLL.HJGL_TestingService.GetTestingByTestingId(ndtType);
string checkState = string.Empty;
if (states == "1")
{
checkState = "待检测";
}
if (states == "2")
{
checkState = "检测合格";
}
if (states == "3")
{
checkState = "待重检";
}
if (states == "4")
{
checkState = "待返修";
}
if (ndt.SysType == "射线检测")
{
newJointInfo.RT_States = checkState;
if (states == "1")
{
newJointInfo.RTFeedbackDate = null;
newJointInfo.RT1_RepairFilmNum = null;
newJointInfo.RT1_RepairFilm = null;
newJointInfo.RT2_RepairFilmNum = null;
newJointInfo.RT2_RepairFilm = null;
newJointInfo.RT3_RepairFilmNum = null;
newJointInfo.RT3_RepairFilm = null;
}
}
if (ndt.SysType == "渗透检测")
{
newJointInfo.PT_States = checkState;
if (states == "1")
{
newJointInfo.PTIsRepair1 = null;
newJointInfo.PTIsRepair2 = null;
newJointInfo.PTIsRepair2 = null;
}
}
if (ndt.SysType == "磁粉检测")
{
newJointInfo.MT_States = checkState;
if (states == "1")
{
newJointInfo.MTIsRepair1 = null;
newJointInfo.MTIsRepair2 = null;
newJointInfo.MTIsRepair2 = null;
}
}
if (ndt.SysType == "超声波检测")
{
if (ndt.NDT_Name == "相控阵超声检测")
{
newJointInfo.PAUT_States = checkState;
if (states == "1")
{
newJointInfo.PAUTIsRepair1 = null;
newJointInfo.PAUTIsRepair2 = null;
newJointInfo.PAUTIsRepair2 = null;
}
}
else
{
newJointInfo.UT_States = checkState;
if (states == "1")
{
newJointInfo.UTIsRepair1 = null;
newJointInfo.UTIsRepair2 = null;
newJointInfo.UTIsRepair2 = null;
}
}
}
db.SubmitChanges();
}
}
public static void JointRTFeedbackDateWriteBack(string jotId, string ndtType, DateTime? backDate)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (newJointInfo != null)
{
var ndt = BLL.HJGL_TestingService.GetTestingByTestingId(ndtType);
if (ndt.SysType == "射线检测")
{
newJointInfo.RTFeedbackDate = backDate;
}
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口扩透状态
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPointType(string jot_Id, string pointType)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PointType = pointType;
db.SubmitChanges();
}
}
/// <summary>
/// 更新焊口号 固定焊口号后 +G
/// </summary>
/// <param name="jotId">焊口id</param>
/// <param name="jointAttribute">焊口属性</param>
/// <param name="operateState">日报操作(增加、删除)</param>
public static void UpdateJointNoAddG(string jotId, string jointAttribute, string operateState)
{
Model.SGGLDB db = Funs.DB;
if (operateState == Const.Delete || jointAttribute != "固定")
{
Model.HJGL_PW_JointInfo deleteJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (deleteJointInfo.JOT_JointNo.Last() == 'G')
{
deleteJointInfo.JOT_JointNo = deleteJointInfo.JOT_JointNo.Substring(0, deleteJointInfo.JOT_JointNo.Length - 1);
db.SubmitChanges();
}
}
else
{
Model.HJGL_PW_JointInfo addJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jotId);
if (addJointInfo.JOT_JointNo.Last() != 'G')
{
addJointInfo.JOT_JointNo += "G";
}
db.SubmitChanges();
}
}
/// <summary>
/// 回写热处理委托时间
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackHotProessTrustDate(string jot_Id, DateTime? date)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.HotProessTrustDate = date;
db.SubmitChanges();
}
}
/// <summary>
/// 回写热处理合格及反馈时间
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackHotProessResultOKAndDate(string jot_Id, bool? isOK)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.HotProessResultOK = isOK;
if (isOK == true)
{
newJointInfo.HotResultDate = DateTime.Now;
}
else
{
newJointInfo.HotResultDate = null;
}
db.SubmitChanges();
}
}
/// <summary>
/// 回写硬度委托时间
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackHardTrustDate(string jot_Id, DateTime? date)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.HardTrustDate = date;
db.SubmitChanges();
}
}
/// <summary>
/// 回写硬度合格及反馈时间
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackHardTestResultOKAndDate(string jot_Id, bool? isOK)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.HardTestResultOK = isOK;
if (isOK == null)
{
newJointInfo.HardResultDate = null;
}
else
{
newJointInfo.HardResultDate = DateTime.Now;
}
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口一次返修片子及数量
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackRT1RepairFilmAndNum(string jot_Id, string filmNum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
if (newJointInfo.RT1_RepairFilmNum == null)
{
newJointInfo.RT1_RepairFilmNum = 1;
}
else
{
newJointInfo.RT1_RepairFilmNum = newJointInfo.RT1_RepairFilmNum + 1;
}
if (string.IsNullOrEmpty(newJointInfo.RT1_RepairFilm))
{
newJointInfo.RT1_RepairFilm = filmNum;
}
else
{
newJointInfo.RT1_RepairFilm = newJointInfo.RT1_RepairFilm + "," + filmNum;
}
newJointInfo.HardResultDate = DateTime.Now;
db.SubmitChanges();
}
}
/// <summary>
/// 删除返修通知单回写焊口一次返修片子及数量
/// </summary>
/// <param name="jointInfo"></param>
public static void DeleteWriteBackRT1RepairFilmAndNum(string jot_Id, string filmNum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
if (newJointInfo.RT1_RepairFilmNum == 1)
{
newJointInfo.RT1_RepairFilmNum = null;
}
else
{
newJointInfo.RT1_RepairFilmNum = newJointInfo.RT1_RepairFilmNum - 1;
}
string[] strs = newJointInfo.RT1_RepairFilm.Split(',');
if (strs.Length == 1)
{
newJointInfo.RT1_RepairFilm = null;
}
else
{
string str = string.Empty;
foreach (var item in strs)
{
if (item != filmNum)
{
str += item + ",";
}
}
if (!string.IsNullOrEmpty(str))
{
str = str.Substring(0, str.LastIndexOf(","));
}
newJointInfo.RT1_RepairFilm = str;
}
newJointInfo.HardResultDate = DateTime.Now;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口二次返修片子及数量
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackRT2RepairFilmAndNum(string jot_Id, string filmNum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
if (newJointInfo.RT2_RepairFilmNum == null)
{
newJointInfo.RT2_RepairFilmNum = 1;
}
else
{
newJointInfo.RT2_RepairFilmNum = newJointInfo.RT2_RepairFilmNum + 1;
}
if (string.IsNullOrEmpty(newJointInfo.RT2_RepairFilm))
{
newJointInfo.RT2_RepairFilm = filmNum;
}
else
{
newJointInfo.RT2_RepairFilm = newJointInfo.RT2_RepairFilm + "," + filmNum;
}
newJointInfo.HardResultDate = DateTime.Now;
db.SubmitChanges();
}
}
/// <summary>
/// 删除返修通知单回写焊口二次返修片子及数量
/// </summary>
/// <param name="jointInfo"></param>
public static void DeleteWriteBackRT2RepairFilmAndNum(string jot_Id, string filmNum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
if (newJointInfo.RT2_RepairFilmNum == 1)
{
newJointInfo.RT2_RepairFilmNum = null;
}
else
{
newJointInfo.RT2_RepairFilmNum = newJointInfo.RT2_RepairFilmNum - 1;
}
string[] strs = newJointInfo.RT2_RepairFilm.Split(',');
if (strs.Length == 1)
{
newJointInfo.RT2_RepairFilm = null;
}
else
{
string str = string.Empty;
foreach (var item in strs)
{
if (item != filmNum)
{
str += item + ",";
}
}
if (!string.IsNullOrEmpty(str))
{
str = str.Substring(0, str.LastIndexOf(","));
}
newJointInfo.RT2_RepairFilm = str;
}
newJointInfo.HardResultDate = DateTime.Now;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口三次返修片子及数量
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackRT3RepairFilmAndNum(string jot_Id, string filmNum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
if (newJointInfo.RT3_RepairFilmNum == null)
{
newJointInfo.RT3_RepairFilmNum = 1;
}
else
{
newJointInfo.RT3_RepairFilmNum = newJointInfo.RT3_RepairFilmNum + 1;
}
if (string.IsNullOrEmpty(newJointInfo.RT3_RepairFilm))
{
newJointInfo.RT3_RepairFilm = filmNum;
}
else
{
newJointInfo.RT3_RepairFilm = newJointInfo.RT3_RepairFilm + "," + filmNum;
}
newJointInfo.HardResultDate = DateTime.Now;
db.SubmitChanges();
}
}
/// <summary>
/// 删除返修通知单回写焊口三次返修片子及数量
/// </summary>
/// <param name="jointInfo"></param>
public static void DeleteWriteBackRT3RepairFilmAndNum(string jot_Id, string filmNum)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
if (newJointInfo.RT3_RepairFilmNum == 1)
{
newJointInfo.RT3_RepairFilmNum = null;
}
else
{
newJointInfo.RT3_RepairFilmNum = newJointInfo.RT3_RepairFilmNum - 1;
}
string[] strs = newJointInfo.RT3_RepairFilm.Split(',');
if (strs.Length == 1)
{
newJointInfo.RT3_RepairFilm = null;
}
else
{
string str = string.Empty;
foreach (var item in strs)
{
if (item != filmNum)
{
str += item + ",";
}
}
if (!string.IsNullOrEmpty(str))
{
str = str.Substring(0, str.LastIndexOf(","));
}
newJointInfo.RT3_RepairFilm = str;
}
newJointInfo.HardResultDate = DateTime.Now;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口PT是否一次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPTIsRepair1(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PTIsRepair1 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口PT是否二次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPTIsRepair2(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PTIsRepair2 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口PT是否三次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPTIsRepair3(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PTIsRepair3 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口MT是否一次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackMTIsRepair1(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.MTIsRepair1 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口MT是否二次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackMTIsRepair2(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.MTIsRepair2 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口MT是否三次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackMTIsRepair3(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.MTIsRepair3 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口UT是否一次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackUTIsRepair1(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.UTIsRepair1 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口UT是否二次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackUTIsRepair2(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.UTIsRepair2 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口UT是否三次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackUTIsRepair3(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.UTIsRepair3 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口PAUT是否一次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPAUTIsRepair1(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PAUTIsRepair1 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口PAUT是否二次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPAUTIsRepair2(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PAUTIsRepair2 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 回写焊口PAUT是否三次返修
/// </summary>
/// <param name="jointInfo"></param>
public static void WriteBackPAUTIsRepair3(string jot_Id, bool? b)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_PW_JointInfo newJointInfo = db.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_ID == jot_Id);
if (newJointInfo != null)
{
newJointInfo.PAUTIsRepair3 = b;
db.SubmitChanges();
}
}
/// <summary>
/// 根据焊接日报ID获取焊接日期
/// </summary>
/// <param name="dReportID"></param>
/// <returns></returns>
public static DateTime GetReportDateByDReportID(string dReportID)
{
return (from y in Funs.DB.HJGL_BO_WeldReportMain where y.DReportID == dReportID select y.JOT_WeldDate).FirstOrDefault();
}
/// <summary>
/// 根据日报告号获取焊口信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static List<Model.HJGL_PW_JointInfo> GetJointInfosByDReportID(string DReportID)
{
return (from x in Funs.DB.HJGL_PW_JointInfo where x.DReportID == DReportID select x).ToList();
}
/// <summary>
/// 根据管线Id获取已焊接的焊口信息
/// </summary>
/// <param name="iso_id"></param>
/// <returns></returns>
public static string GetDeReportByJotID(string iso_id)
{
return (from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == iso_id && x.DReportID != null select x.DReportID).FirstOrDefault();
}
/// <summary>
/// 根据焊口号、管线号及区域号获取焊口信息
/// </summary>
/// <param name="jointNo">焊口号</param>
/// <param name="isoNo"></param>
/// <param name="bAW_ID"></param>
/// <returns></returns>
public static Model.HJGL_PW_JointInfo GetJointInfoByJointNoAndIsoNoAndBAW_ID(string projectId, string bAW_ID, string isoNo, string jointNo)
{
return (from x in Funs.DB.HJGL_PW_JointInfo join y in Funs.DB.HJGL_PW_IsoInfo on x.ISO_ID equals y.ISO_ID where x.ProjectId == projectId && y.BAW_ID == bAW_ID && y.ISO_IsoNo == isoNo && x.JOT_JointNo == jointNo select x).FirstOrDefault();
}
/// <summary>
/// 根据焊口信息查找焊口信息
/// </summary>
/// <param name="jot_no"></param>
/// <returns></returns>
public static string GetJointInfoByJOTNO(string iso_id, string jot_no)
{
return (from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == iso_id && x.JOT_JointNo == jot_no select x.JOT_JointNo).FirstOrDefault();
}
/// <summary>
/// 根据焊接日报获取焊口数
/// </summary>
/// <param name="dreportId"></param>
/// <returns></returns>
public static List<Model.HJGL_PW_JointInfo> GetJointInfoByDReportId(string dreportId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.DReportID == dreportId select x).ToList();
return q;
}
/// <summary>
/// 管线是否已有焊接记录
/// </summary>
/// <param name="iso_id"></param>
/// <returns></returns>
public static bool IsExistDReport(string iso_id)
{
var q = from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == iso_id && x.DReportID == null select x;
if (q.Count() > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 根据材质1获取焊口数
/// </summary>
/// <param name="dreportId"></param>
/// <returns></returns>
public static int GetJointInfoBySTEID(string steId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.STE_ID == steId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据材质2获取焊口数
/// </summary>
/// <param name="dreportId"></param>
/// <returns></returns>
public static int GetJointInfoBySTEID2(string steId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.STE_ID2 == steId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据盖面焊工获取焊口数
/// </summary>
/// <param name="cellWelder"></param>
/// <returns></returns>
public static int GetJointInfoByCellWelder(string cellWelder)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOT_CellWelder == cellWelder select x).ToList();
return q.Count();
}
/// <summary>
/// 根据打底焊工获取焊口数
/// </summary>
/// <param name="floorWelder"></param>
/// <returns></returns>
public static int GetJointInfoByFloorWelder(string floorWelder)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOT_FloorWelder == floorWelder select x).ToList();
return q.Count();
}
/// <summary>
/// 根据安装组件1获取焊口数
/// </summary>
/// <param name="comId"></param>
/// <returns></returns>
public static int GetJointInfoByCom1(string comId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOT_Component1 == comId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据安装组件2获取焊口数
/// </summary>
/// <param name="comId"></param>
/// <returns></returns>
public static int GetJointInfoByCom2(string comId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOT_Component2 == comId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据焊条获取焊口数
/// </summary>
/// <param name="weldmat"></param>
/// <returns></returns>
public static int GetJointInfoByWeldMat(string weldmat)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOT_WeldMat == weldmat select x).ToList();
return q.Count();
}
/// <summary>
/// 根据焊丝获取焊口数
/// </summary>
/// <param name="weldsilk"></param>
/// <returns></returns>
public static int GetJointInfoByWeldSilk(string weldsilk)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOT_WeldSilk == weldsilk select x).ToList();
return q.Count();
}
/// <summary>
/// 根据焊缝类型获取焊口数
/// </summary>
/// <param name="jotyId"></param>
/// <returns></returns>
public static int GetJointInfoByJOTYID(string jotyId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JOTY_ID == jotyId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据焊接方法获取焊口数
/// </summary>
/// <param name="wmeId"></param>
/// <returns></returns>
public static int GetJointInfoByWMEID(string wmeId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.WME_ID == wmeId select x).ToList();
return q.Count();
}
/// <summary>
/// 根据焊接方法获取焊口数
/// </summary>
/// <param name="jstId"></param>
/// <returns></returns>
public static int GetJointInfoByJSTID(string jstId)
{
var q = (from x in Funs.DB.HJGL_PW_JointInfo where x.JST_ID == jstId select x).ToList();
return q.Count();
}
/// <summary>
/// 判断焊口号是否已存在
/// </summary>
/// <param name="isoNo"></param>
/// <returns></returns>
public static bool IsExistJointInfoCode(string projectId ,string jotNo, string ISO_ID, string JOT_ID)
{
if (JOT_ID == null) // JOT_ID!=null SQL语句不支持
{
JOT_ID = "";
}
var q = Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(x =>x.ProjectId==projectId && x.JOT_JointNo == jotNo && x.ISO_ID == ISO_ID && x.JOT_ID != JOT_ID);
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <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 jotDate)
{
var jots = from x in Funs.DB.HJGL_PW_JointInfo
join y in Funs.DB.HJGL_BO_WeldReportMain on x.DReportID equals y.DReportID
where x.ProjectId == projectId && y.JOT_WeldDate == jotDate && (welderId == x.JOT_FloorWelder || welderId == x.JOT_CellWelder)
select x;
decimal? count = jots.Sum(x => x.JOT_DoneDin);
if (count >= 60)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 获取当前焊工寸径量
/// </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 decimal? GetWelderDN(string projectId, string welderId, DateTime jotDate)
{
var jots = from x in Funs.DB.HJGL_PW_JointInfo
join y in Funs.DB.HJGL_BO_WeldReportMain on x.DReportID equals y.DReportID
where x.ProjectId == projectId && y.JOT_WeldDate == jotDate && (welderId == x.JOT_FloorWelder || welderId == x.JOT_CellWelder)
select x;
decimal? count = jots.Sum(x => x.JOT_DoneDin);
return count;
}
/// <summary>
/// 获取热处理类型
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
public static List<Model.HandleStep> GetProessTypes()
{
List<Model.HandleStep> proessTypes = new List<Model.HandleStep>();
Model.HandleStep proessType1 = new Model.HandleStep();
proessType1.Id = "1";
proessType1.Name = "预热";
proessTypes.Add(proessType1);
Model.HandleStep proessType2 = new Model.HandleStep();
proessType2.Id = "2";
proessType2.Name = "消氢";
proessTypes.Add(proessType2);
Model.HandleStep proessType3 = new Model.HandleStep();
proessType3.Id = "3";
proessType3.Name = "后热";
proessTypes.Add(proessType3);
Model.HandleStep proessType4 = new Model.HandleStep();
proessType4.Id = "4";
proessType4.Name = "消应力热处理";
proessTypes.Add(proessType4);
Model.HandleStep proessType5 = new Model.HandleStep();
proessType5.Id = "5";
proessType5.Name = "稳定化处理";
proessTypes.Add(proessType5);
return proessTypes;
}
/// <summary>
/// 获取热处理类型方法
/// </summary>
/// <param name="isoNo"></param>
/// <returns></returns>
public static string ConvertProessTypes(string proessTypes)
{
string name = string.Empty;
string[] list = proessTypes.Split('|');
foreach (var item in list)
{
if (!string.IsNullOrEmpty(item))
{
name += GetProessTypes().First(x => x.Id == item).Name + ",";
}
}
if (!string.IsNullOrEmpty(name))
{
name = name.Substring(0, name.LastIndexOf(","));
}
return name;
}
/// <summary>
/// 根据焊口号、管线ID、项目Id获取焊口信息
/// </summary>
/// <param name="jointNo"></param>
/// <param name="isoId"></param>
/// <param name="projectId"></param>
/// <returns></returns>
public static Model.HJGL_PW_JointInfo GetJointInfoByJointNoAndIsoId(string jointNo, string isoId, string projectId)
{
return Funs.DB.HJGL_PW_JointInfo.FirstOrDefault(e => e.JOT_JointNo == jointNo && e.ISO_ID == isoId && e.ProjectId == projectId);
}
}
}