using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using System.Web.UI.WebControls; namespace BLL { public static class Pipeline_WeldJointService { /// /// 根据焊口Id获取焊口信息 /// /// /// public static Model.Pipeline_WeldJoint GetWeldJointByWeldJointId(string weldJointId) { return Funs.DB.Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); } /// /// 判断焊口号是否已存在 /// /// /// public static bool IsExistWeldJointCode(string weldJointCode, string pipelineId, string weldJointId) { Model.HJGLDB db = Funs.DB; var q = Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.WeldJointCode == weldJointCode && x.PipelineId == pipelineId && x.WeldJointId != weldJointId); if (q != null) { return true; } else { return false; } } /// /// 根据焊接日报获取焊口数 /// /// /// public static List GetWeldlinesByWeldingDailyId(string weldingDailyId) { var q = (from x in Funs.DB.Pipeline_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineId, x.WeldJointCode select x).ToList(); return q; } /// /// 添加 /// /// public static void AddWeldJoint(Model.Pipeline_WeldJoint weldJoint) { Model.HJGLDB db = Funs.DB; Model.Pipeline_WeldJoint newWeldJoint = new Model.Pipeline_WeldJoint { WeldJointId = SQLHelper.GetNewID(typeof(Model.Pipeline_WeldJoint)), ProjectId = weldJoint.ProjectId, PipelineId = weldJoint.PipelineId, WeldJointCode = weldJoint.WeldJointCode, WeldTypeId = weldJoint.WeldTypeId, Material1Id = weldJoint.Material1Id, Material2Id = weldJoint.Material2Id, Thickness = weldJoint.Thickness, Dia = weldJoint.Dia, Size = weldJoint.Size, JointAttribute = weldJoint.JointAttribute, JointArea = weldJoint.JointArea, WeldingMethodId = weldJoint.WeldingMethodId, IsHotProess = weldJoint.IsHotProess, WeldingLocationId = weldJoint.WeldingLocationId, WeldMatId = weldJoint.WeldMatId, WeldSilkId = weldJoint.WeldSilkId, GrooveTypeId = weldJoint.GrooveTypeId, PipeSegment = weldJoint.PipeSegment, PipeAssembly1Id = weldJoint.PipeAssembly1Id, PipeAssembly2Id = weldJoint.PipeAssembly2Id, PipeAssemblyCount = weldJoint.PipeAssemblyCount, HeartNo1 = weldJoint.HeartNo1, HeartNo2 = weldJoint.HeartNo2, LastTemp = weldJoint.LastTemp, CellTemp = weldJoint.CellTemp, PrepareTemp = weldJoint.PrepareTemp, Electricity = weldJoint.Electricity, Voltage = weldJoint.Voltage, TestPackageNo = weldJoint.TestPackageNo, WeldingDailyCode = weldJoint.WeldingDailyCode, BackingWelderId = weldJoint.BackingWelderId, CoverWelderId = weldJoint.CoverWelderId, WeldingDailyId = weldJoint.WeldingDailyId, PipingClassId = weldJoint.PipingClassId, Specification = weldJoint.Specification, DoneDin = weldJoint.DoneDin, SystemNumber = weldJoint.SystemNumber, Remark = weldJoint.Remark, IsGoldJoint = weldJoint.IsGoldJoint, WPQId = weldJoint.WPQId, DetectionType = weldJoint.DetectionType, PageNum = weldJoint.PageNum, ANSISCH = weldJoint.ANSISCH }; db.Pipeline_WeldJoint.InsertOnSubmit(newWeldJoint); db.SubmitChanges(); } /// /// 修改 /// /// public static void UpdateWeldJoint(Model.Pipeline_WeldJoint weldJoint) { Model.HJGLDB db = Funs.DB; Model.Pipeline_WeldJoint newWeldJoint = db.Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId); if (newWeldJoint != null) { newWeldJoint.WeldJointCode = weldJoint.WeldJointCode; newWeldJoint.WeldTypeId = weldJoint.WeldTypeId; newWeldJoint.Material1Id = weldJoint.Material1Id; newWeldJoint.Material2Id = weldJoint.Material2Id; newWeldJoint.Thickness = weldJoint.Thickness; newWeldJoint.Dia = weldJoint.Dia; newWeldJoint.Size = weldJoint.Size; newWeldJoint.JointAttribute = weldJoint.JointAttribute; newWeldJoint.JointArea = weldJoint.JointArea; newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId; newWeldJoint.IsHotProess = weldJoint.IsHotProess; newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId; newWeldJoint.WeldMatId = weldJoint.WeldMatId; newWeldJoint.WeldSilkId = weldJoint.WeldSilkId; newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId; newWeldJoint.PipeSegment = weldJoint.PipeSegment; newWeldJoint.PipeAssembly1Id = weldJoint.PipeAssembly1Id; newWeldJoint.PipeAssembly2Id = weldJoint.PipeAssembly2Id; newWeldJoint.PipeAssemblyCount = weldJoint.PipeAssemblyCount; newWeldJoint.HeartNo1 = weldJoint.HeartNo1; newWeldJoint.HeartNo2 = weldJoint.HeartNo2; newWeldJoint.LastTemp = weldJoint.LastTemp; newWeldJoint.CellTemp = weldJoint.CellTemp; newWeldJoint.PrepareTemp = weldJoint.PrepareTemp; newWeldJoint.Electricity = weldJoint.Electricity; newWeldJoint.Voltage = weldJoint.Voltage; newWeldJoint.IsPMI= weldJoint.IsPMI; newWeldJoint.TestPackageNo = weldJoint.TestPackageNo; newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode; newWeldJoint.BackingWelderId = weldJoint.BackingWelderId; newWeldJoint.CoverWelderId = weldJoint.CoverWelderId; newWeldJoint.WeldingDate = weldJoint.WeldingDate; newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId; newWeldJoint.PipingClassId = weldJoint.PipingClassId; newWeldJoint.Specification = weldJoint.Specification; newWeldJoint.DoneDin = weldJoint.DoneDin; newWeldJoint.SystemNumber = weldJoint.SystemNumber; newWeldJoint.Remark = weldJoint.Remark; newWeldJoint.IsCancel = weldJoint.IsCancel; newWeldJoint.IsGoldJoint = weldJoint.IsGoldJoint; newWeldJoint.WPQId = weldJoint.WPQId; newWeldJoint.DetectionType = weldJoint.DetectionType; newWeldJoint.PageNum = weldJoint.PageNum; newWeldJoint.ANSISCH = weldJoint.ANSISCH; db.SubmitChanges(); } } /// /// 修改部分内容 /// /// public static void UpdateDepartWeldJoint(Model.Pipeline_WeldJoint weldJoint) { Model.HJGLDB db = Funs.DB; Model.Pipeline_WeldJoint newWeldJoint = db.Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId); if (newWeldJoint != null) { newWeldJoint.WeldJointCode = weldJoint.WeldJointCode; newWeldJoint.WeldTypeId = weldJoint.WeldTypeId; newWeldJoint.Material1Id = weldJoint.Material1Id; newWeldJoint.Material2Id = weldJoint.Material2Id; if (weldJoint.Thickness != null) { newWeldJoint.Thickness = weldJoint.Thickness; } newWeldJoint.Dia = weldJoint.Dia; newWeldJoint.Size = weldJoint.Size; newWeldJoint.JointAttribute = weldJoint.JointAttribute; if (!string.IsNullOrEmpty(weldJoint.JointArea)) { newWeldJoint.JointArea = weldJoint.JointArea; } newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId; if (weldJoint.IsHotProess != null) { newWeldJoint.IsHotProess = weldJoint.IsHotProess; } if (!string.IsNullOrEmpty(weldJoint.WeldingLocationId)) { newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId; } if (!string.IsNullOrEmpty(weldJoint.WeldMatId)) { newWeldJoint.WeldMatId = weldJoint.WeldMatId; } if (!string.IsNullOrEmpty(weldJoint.WeldSilkId)) { newWeldJoint.WeldSilkId = weldJoint.WeldSilkId; } newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId; if (!string.IsNullOrEmpty(weldJoint.PipeSegment)) { newWeldJoint.PipeSegment = weldJoint.PipeSegment; } if (!string.IsNullOrEmpty(weldJoint.PipeAssembly1Id)) { newWeldJoint.PipeAssembly1Id = weldJoint.PipeAssembly1Id; } if (!string.IsNullOrEmpty(weldJoint.PipeAssembly2Id)) { newWeldJoint.PipeAssembly2Id = weldJoint.PipeAssembly2Id; } if (weldJoint.PipeAssemblyCount != null) { newWeldJoint.PipeAssemblyCount = weldJoint.PipeAssemblyCount; } if (!string.IsNullOrEmpty(weldJoint.HeartNo1)) { newWeldJoint.HeartNo1 = weldJoint.HeartNo1; } if (!string.IsNullOrEmpty(weldJoint.HeartNo2)) { newWeldJoint.HeartNo2 = weldJoint.HeartNo2; } if (!string.IsNullOrEmpty(weldJoint.LastTemp)) { newWeldJoint.LastTemp = weldJoint.LastTemp; } if (!string.IsNullOrEmpty(weldJoint.CellTemp)) { newWeldJoint.CellTemp = weldJoint.CellTemp; } if (!string.IsNullOrEmpty(weldJoint.PrepareTemp)) { newWeldJoint.PrepareTemp = weldJoint.PrepareTemp; } if (!string.IsNullOrEmpty(weldJoint.Electricity)) { newWeldJoint.Electricity = weldJoint.Electricity; } if (!string.IsNullOrEmpty(weldJoint.Voltage)) { newWeldJoint.Voltage = weldJoint.Voltage; } if (!string.IsNullOrEmpty(weldJoint.TestPackageNo)) { newWeldJoint.TestPackageNo = weldJoint.TestPackageNo; } //newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode; //newWeldJoint.BackingWelderId = weldJoint.BackingWelderId; //newWeldJoint.CoverWelderId = weldJoint.CoverWelderId; //newWeldJoint.WeldingDate = weldJoint.WeldingDate; //newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId; newWeldJoint.PipingClassId = weldJoint.PipingClassId; newWeldJoint.Specification = weldJoint.Specification; newWeldJoint.DoneDin = weldJoint.DoneDin; if (!string.IsNullOrEmpty(weldJoint.SystemNumber)) { newWeldJoint.SystemNumber = weldJoint.SystemNumber; } if (!string.IsNullOrEmpty(weldJoint.Remark)) { newWeldJoint.Remark = weldJoint.Remark; } //newWeldJoint.IsCancel = weldJoint.IsCancel; newWeldJoint.IsGoldJoint = weldJoint.IsGoldJoint; newWeldJoint.WPQId = weldJoint.WPQId; newWeldJoint.DetectionType = weldJoint.DetectionType; if (!string.IsNullOrEmpty(weldJoint.PageNum)) { newWeldJoint.PageNum = weldJoint.PageNum; } if (!string.IsNullOrEmpty(weldJoint.ANSISCH)) { newWeldJoint.ANSISCH = weldJoint.ANSISCH; } db.SubmitChanges(); } } /// /// 修改部分内容TCC11,暂时 /// /// public static void UpdateDepartWeldJointToTCC11(Model.Pipeline_WeldJoint weldJoint) { Model.HJGLDB db = Funs.DB; Model.Pipeline_WeldJoint newWeldJoint = db.Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJoint.WeldJointId); if (newWeldJoint != null) { newWeldJoint.WeldJointCode = weldJoint.WeldJointCode; //newWeldJoint.WeldTypeId = weldJoint.WeldTypeId; //newWeldJoint.Material1Id = weldJoint.Material1Id; //newWeldJoint.Material2Id = weldJoint.Material2Id; if (weldJoint.Thickness != null) { newWeldJoint.Thickness = weldJoint.Thickness; } if (weldJoint.Dia != null) { newWeldJoint.Dia = weldJoint.Dia; } if (weldJoint.Size != null) { newWeldJoint.Size = weldJoint.Size; } if (!string.IsNullOrEmpty(weldJoint.JointAttribute)) { newWeldJoint.JointAttribute = weldJoint.JointAttribute; } if (!string.IsNullOrEmpty(weldJoint.JointArea)) { newWeldJoint.JointArea = weldJoint.JointArea; } //newWeldJoint.WeldingMethodId = weldJoint.WeldingMethodId; if (weldJoint.IsHotProess != null) { newWeldJoint.IsHotProess = weldJoint.IsHotProess; } if (!string.IsNullOrEmpty(weldJoint.WeldingLocationId)) { newWeldJoint.WeldingLocationId = weldJoint.WeldingLocationId; } if (!string.IsNullOrEmpty(weldJoint.WeldMatId)) { newWeldJoint.WeldMatId = weldJoint.WeldMatId; } if (!string.IsNullOrEmpty(weldJoint.WeldSilkId)) { newWeldJoint.WeldSilkId = weldJoint.WeldSilkId; } //newWeldJoint.GrooveTypeId = weldJoint.GrooveTypeId; if (!string.IsNullOrEmpty(weldJoint.PipeSegment)) { newWeldJoint.PipeSegment = weldJoint.PipeSegment; } if (!string.IsNullOrEmpty(weldJoint.PipeAssembly1Id)) { newWeldJoint.PipeAssembly1Id = weldJoint.PipeAssembly1Id; } if (!string.IsNullOrEmpty(weldJoint.PipeAssembly2Id)) { newWeldJoint.PipeAssembly2Id = weldJoint.PipeAssembly2Id; } if (weldJoint.PipeAssemblyCount != null) { newWeldJoint.PipeAssemblyCount = weldJoint.PipeAssemblyCount; } if (!string.IsNullOrEmpty(weldJoint.HeartNo1)) { newWeldJoint.HeartNo1 = weldJoint.HeartNo1; } if (!string.IsNullOrEmpty(weldJoint.HeartNo2)) { newWeldJoint.HeartNo2 = weldJoint.HeartNo2; } if (!string.IsNullOrEmpty(weldJoint.LastTemp)) { newWeldJoint.LastTemp = weldJoint.LastTemp; } if (!string.IsNullOrEmpty(weldJoint.CellTemp)) { newWeldJoint.CellTemp = weldJoint.CellTemp; } if (!string.IsNullOrEmpty(weldJoint.PrepareTemp)) { newWeldJoint.PrepareTemp = weldJoint.PrepareTemp; } if (!string.IsNullOrEmpty(weldJoint.Electricity)) { newWeldJoint.Electricity = weldJoint.Electricity; } if (!string.IsNullOrEmpty(weldJoint.Voltage)) { newWeldJoint.Voltage = weldJoint.Voltage; } if (!string.IsNullOrEmpty(weldJoint.TestPackageNo)) { newWeldJoint.TestPackageNo = weldJoint.TestPackageNo; } //newWeldJoint.WeldingDailyCode = weldJoint.WeldingDailyCode; //newWeldJoint.BackingWelderId = weldJoint.BackingWelderId; //newWeldJoint.CoverWelderId = weldJoint.CoverWelderId; //newWeldJoint.WeldingDate = weldJoint.WeldingDate; //newWeldJoint.WeldingDailyId = weldJoint.WeldingDailyId; //newWeldJoint.PipingClassId = weldJoint.PipingClassId; if (!string.IsNullOrEmpty(weldJoint.Specification)) { newWeldJoint.Specification = weldJoint.Specification; } //newWeldJoint.DoneDin = weldJoint.DoneDin; if (!string.IsNullOrEmpty(weldJoint.SystemNumber)) { newWeldJoint.SystemNumber = weldJoint.SystemNumber; } if (!string.IsNullOrEmpty(weldJoint.Remark)) { newWeldJoint.Remark = weldJoint.Remark; } //newWeldJoint.IsCancel = weldJoint.IsCancel; if (weldJoint.IsGoldJoint != null) { newWeldJoint.IsGoldJoint = weldJoint.IsGoldJoint; } if (!string.IsNullOrEmpty(weldJoint.WPQId)) { newWeldJoint.WPQId = weldJoint.WPQId; } if (!string.IsNullOrEmpty(weldJoint.DetectionType)) { newWeldJoint.DetectionType = weldJoint.DetectionType; } if (!string.IsNullOrEmpty(weldJoint.PageNum)) { newWeldJoint.PageNum = weldJoint.PageNum; } if (!string.IsNullOrEmpty(weldJoint.ANSISCH)) { newWeldJoint.ANSISCH = weldJoint.ANSISCH; } db.SubmitChanges(); } } /// /// 根据主键删除焊口信息 /// /// public static void DeleteWeldJointById(string weldJointId) { Model.HJGLDB db = Funs.DB; Model.Pipeline_WeldJoint weldline = db.Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); if (weldline != null) { db.Pipeline_WeldJoint.DeleteOnSubmit(weldline); db.SubmitChanges(); } } /// /// 更新焊口号 固定焊口号后 +G /// /// 焊口id /// 焊口属性 /// 日报操作(增加、删除) public static void UpdateWeldJointAddG(string weldJointId, string jointAttribute, string operateState) { Model.HJGLDB db = Funs.DB; if (operateState == Const.BtnDelete || jointAttribute != "固定") { Model.Pipeline_WeldJoint deleteWeldJoint = db.Pipeline_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.Pipeline_WeldJoint addJointInfo = db.Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); if (addJointInfo.WeldJointCode.Last() != 'G') { addJointInfo.WeldJointCode += "G"; } db.SubmitChanges(); } } /// /// 根据主键获取焊口信息视图 /// /// /// public static Model.View_Pipeline_WeldJoint GetViewWeldJointById(string weldJointId) { Model.HJGLDB db = Funs.DB; return db.View_Pipeline_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId); } /// /// 根据焊接日报获取焊口数 /// /// /// public static List GetWeldJointsByWeldingDailyId(string weldingDailyId) { var q = (from x in Funs.DB.Pipeline_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineId, x.WeldJointCode select x).ToList(); return q; } /// /// 根据焊接日报获取焊口数 /// /// /// public static List GetViewWeldJointsByWeldingDailyId(string weldingDailyId) { var q = (from x in Funs.DB.View_Pipeline_WeldJoint where x.WeldingDailyId == weldingDailyId orderby x.PipelineCode, x.WeldJointCode select x).ToList(); return q; } /// /// 获取当前焊工工作量是否超过60寸的焊接人员 /// /// 项目id /// 单位id /// 焊口ID /// 焊接日期 /// public static bool GetWelderLimitDN(string projectId, string welderId, DateTime weldingDate) { var jots = from x in Funs.DB.Pipeline_WeldJoint join y in Funs.DB.Pipeline_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; } } /// /// 根据管线ID获取焊口信息 /// /// /// public static List GetViewWeldJointsByPipelineId(string pipelineId) { var q = (from x in Funs.DB.View_Pipeline_WeldJoint where x.PipelineId == pipelineId orderby x.WeldJointCode select x).ToList(); return q; } } }