ZHJA_HJGL/HJGL_ZH/BLL/HJGL/TestPackageManage/HJGL_TestPackageManageEditS...

263 lines
13 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using System.Web.UI.WebControls;
namespace BLL
{
public class HJGL_TestPackageManageEditService
{
/// <summary>
/// 根据试压Id获取用于试压信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
public static Model.HJGL_TP_TestPackage GetTP_TestPackageByID(string PTP_ID)
{
Model.SGGLDB db = Funs.DB;
var view = db.HJGL_TP_TestPackage.FirstOrDefault(e => e.PTP_ID == PTP_ID);
return view;
}
/// <summary>
/// 根据试压包号获取试压信息
/// </summary>
/// <param name="testPackageNo"></param>
/// <returns></returns>
public static Model.HJGL_TP_TestPackage GetTestPackageByTestPackageNo(string testPackageNo)
{
return Funs.DB.HJGL_TP_TestPackage.FirstOrDefault(e => e.PTP_TestPackageNo == testPackageNo);
}
/// <summary>
/// 根据试压Id获取用于管线明细信息
/// </summary>
/// <param name="jot_id"></param>
/// <returns></returns>
//public static List<Model.HJGL_PW_IsoInfo> GetIsoInfosByPTP_ID(string PTP_ID)
//{
// Model.SGGLDB db = Funs.DB;
// var view = from x in db.HJGL_PW_IsoInfo
// join y in db.HJGL_TP_IsoList on x.ISO_ID equals y.ISO_ID
// where y.PTP_ID == PTP_ID
// select x;
// return view.ToList();
//}
/// <summary>
/// 增加试压信息
/// </summary>
/// <param name="testPackage">试压实体</param>
public static void AddTP_TestPackage(Model.HJGL_TP_TestPackage testPackage)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_TP_TestPackage newTestPackage = new Model.HJGL_TP_TestPackage();
newTestPackage.PTP_ID = testPackage.PTP_ID;
newTestPackage.PTP_TestPackageNo = testPackage.PTP_TestPackageNo;
newTestPackage.PTP_TestPackageName = testPackage.PTP_TestPackageName;
newTestPackage.PTP_TestService = testPackage.PTP_TestService;
newTestPackage.PTP_TestAmbientTemp = testPackage.PTP_TestAmbientTemp;
newTestPackage.PTP_TestMediumTemp = testPackage.PTP_TestMediumTemp;
newTestPackage.PTP_OperationMedium = testPackage.PTP_OperationMedium;
newTestPackage.PTP_PurgingMedium = testPackage.PTP_PurgingMedium;
newTestPackage.PTP_CleaningMedium = testPackage.PTP_CleaningMedium;
newTestPackage.ProjectId = testPackage.ProjectId;
newTestPackage.InstallationId = testPackage.InstallationId;
newTestPackage.PressureTest = testPackage.PressureTest;
newTestPackage.IsolationRemoval = testPackage.IsolationRemoval;
newTestPackage.OpenValve = testPackage.OpenValve;
newTestPackage.WaterSpecification = testPackage.WaterSpecification;
newTestPackage.InstallationSpecification = testPackage.InstallationSpecification;
newTestPackage.WorkRecord = testPackage.WorkRecord;
newTestPackage.NDTConform = testPackage.NDTConform;
newTestPackage.HotConform = testPackage.HotConform;
newTestPackage.InstallationCorrectness = testPackage.InstallationCorrectness;
newTestPackage.IsolationOpening = testPackage.IsolationOpening;
newTestPackage.Cover = testPackage.Cover;
newTestPackage.ConstructionPlanAsk = testPackage.ConstructionPlanAsk;
newTestPackage.MeetRequirements = testPackage.MeetRequirements;
newTestPackage.StainlessTestWater = testPackage.StainlessTestWater;
newTestPackage.ComponentReinspection = testPackage.ComponentReinspection;
newTestPackage.MarkClearly = testPackage.MarkClearly;
db.HJGL_TP_TestPackage.InsertOnSubmit(newTestPackage);
db.SubmitChanges();
}
/// <summary>
/// 修改试压信息
/// </summary>
/// <param name="weldReport">试压实体</param>
public static void UpdateTP_TestPackage(Model.HJGL_TP_TestPackage testPackage)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_TP_TestPackage newTestPackage = db.HJGL_TP_TestPackage.First(e => e.PTP_ID == testPackage.PTP_ID);
newTestPackage.PTP_TestPackageNo = testPackage.PTP_TestPackageNo;
newTestPackage.PTP_TestPackageName = testPackage.PTP_TestPackageName;
newTestPackage.PTP_TestService = testPackage.PTP_TestService;
newTestPackage.PTP_TestAmbientTemp = testPackage.PTP_TestAmbientTemp;
newTestPackage.PTP_TestMediumTemp = testPackage.PTP_TestMediumTemp;
newTestPackage.PTP_OperationMedium = testPackage.PTP_OperationMedium;
newTestPackage.PTP_PurgingMedium = testPackage.PTP_PurgingMedium;
newTestPackage.PTP_CleaningMedium = testPackage.PTP_CleaningMedium;
newTestPackage.ProjectId = testPackage.ProjectId;
newTestPackage.InstallationId = testPackage.InstallationId;
newTestPackage.PressureTest = testPackage.PressureTest;
newTestPackage.IsolationRemoval = testPackage.IsolationRemoval;
newTestPackage.OpenValve = testPackage.OpenValve;
newTestPackage.WaterSpecification = testPackage.WaterSpecification;
newTestPackage.InstallationSpecification = testPackage.InstallationSpecification;
newTestPackage.WorkRecord = testPackage.WorkRecord;
newTestPackage.NDTConform = testPackage.NDTConform;
newTestPackage.HotConform = testPackage.HotConform;
newTestPackage.InstallationCorrectness = testPackage.InstallationCorrectness;
newTestPackage.IsolationOpening = testPackage.IsolationOpening;
newTestPackage.Cover = testPackage.Cover;
newTestPackage.ConstructionPlanAsk = testPackage.ConstructionPlanAsk;
newTestPackage.MeetRequirements = testPackage.MeetRequirements;
newTestPackage.StainlessTestWater = testPackage.StainlessTestWater;
newTestPackage.ComponentReinspection = testPackage.ComponentReinspection;
newTestPackage.MarkClearly = testPackage.MarkClearly;
db.SubmitChanges();
}
/// <summary>
/// 根据主键删除试压信息
/// </summary>
/// <param name="testPackageID">试压主键</param>
public static void DeleteTP_TestPackageByTP_TestPackageID(string testPackageID)
{
Model.SGGLDB db = Funs.DB;
Model.HJGL_TP_TestPackage testPackage = db.HJGL_TP_TestPackage.First(e => e.PTP_ID == testPackageID);
db.HJGL_TP_TestPackage.DeleteOnSubmit(testPackage);
db.SubmitChanges();
}
/// <summary>
/// 试压包编号是否存在
/// </summary>
/// <param name="pointNo"></param>
/// <param name="pointId"></param>
/// <returns></returns>
public static bool IsExistTestPackageCode(string TestPackageNo, string PTP_ID, string projectId)
{
var q = Funs.DB.HJGL_TP_TestPackage.FirstOrDefault(x => x.PTP_TestPackageNo == TestPackageNo && x.ProjectId == projectId && x.PTP_ID != PTP_ID);
if (q != null)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 试压包是否全部(需要热处理或硬度处理的已经全部处理)
/// </summary>
/// <param name="PTP_ID"></param>
/// <returns></returns>
public static string IsExistNoHotHardItem(string PTP_ID)
{
string isohot = string.Empty;
//var isoList = from x in Funs.DB.HJGL_TP_IsoList where x.PTP_ID == PTP_ID select x;
//if (isoList.Count() > 0)
//{
// foreach (var isoId in isoList)
// {
// var jots = from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == isoId.ISO_ID && x.IS_Proess == "1" select x;
// if (jots.Count() > 0)
// {
// string jotMessage = string.Empty;
// foreach (var jotItem in jots)
// {
// var hotProssItem = Funs.DB.HJGL_HotProessItem.FirstOrDefault(x => x.JOT_ID == jotItem.JOT_ID);
// if (hotProssItem == null)
// {
// jotMessage += "焊口:" + jotItem.JOT_JointNo + "未作热处理;";
// }
// else
// {
// var hotHardItem = Funs.DB.HJGL_HotHardItem.FirstOrDefault(x => x.JOT_ID == jotItem.JOT_ID);
// if (hotHardItem == null)
// {
// jotMessage += "焊口:" + jotItem.JOT_JointNo + "未作硬度检测;";
// }
// }
// }
// if (!string.IsNullOrEmpty(jotMessage))
// {
// var isoinfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoId.ISO_ID);
// if (isoinfo != null)
// {
// isohot += "管线:" + isoinfo.ISO_IsoNo + "中" + jotMessage;
// }
// }
// }
// }
//}
return isohot;
}
/// <summary>
/// 检验试压包检测率(管线中设置的每个检测方法的检测比例是否达标)
/// </summary>
/// <param name="PTP_ID"></param>
/// <returns></returns>
public static string InspectionIsoRate(string PTP_ID)
{
string isoRate = string.Empty;
//var isoList = from x in Funs.DB.HJGL_TP_IsoList where x.PTP_ID == PTP_ID select x;
//if (isoList.Count() > 0)
//{
// foreach (var isoInfoItem in isoList)
// {
// var isoinfo = BLL.HJGL_PW_IsoInfoService.GetIsoInfoByIsoInfoId(isoInfoItem.ISO_ID);
// if (isoinfo != null)
// {
// int jotCouts = (from x in Funs.DB.HJGL_PW_JointInfo where x.ISO_ID == isoinfo.ISO_ID select x).Count(); //焊口总数
// if (jotCouts > 0)
// {
// if (!string.IsNullOrEmpty(isoinfo.NDT_ID)) ///探伤方法
// {
// decimal? raleValue = null;
// var rates = BLL.HJGL_DetectionService.GetNDTRateByNDTRID(isoinfo.NDTR_ID); //探伤比例
// if (rates != null)
// {
// raleValue = Funs.GetNewDecimalOrZero(rates.NDTR_Rate);
// }
// if (raleValue.HasValue)
// {
// var checkJotCout = (from x in Funs.DB.HJGL_CH_CheckItem
// join y in Funs.DB.HJGL_CH_TrustItem on x.CH_TrustItemID equals y.CH_TrustItemID
// join z in Funs.DB.HJGL_CH_Trust on y.CH_TrustID equals z.CH_TrustID
// where z.CH_NDTMethod == isoinfo.NDT_ID
// select x.JOT_ID).Distinct().Count();
// decimal? realRaleValue = Convert.ToDecimal(checkJotCout / jotCouts) * 100;
// if (realRaleValue < raleValue)
// {
// string name = string.Empty;
// var type = BLL.HJGL_TestingService.GetTestingByTestingId(isoinfo.NDT_ID);
// if (type != null)
// {
// name = type.NDT_Code;
// }
// isoRate += "管线:" + isoinfo.ISO_IsoNo + ";探伤类型:" + type.NDT_Code + ",实际检测比例小于应检测比例值。";
// }
// }
// }
// }
// }
// }
//}
return isoRate;
}
}
}