using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace BLL { /// /// 检测明细 /// public class CheckItemManageService { /// /// 根据焊口ID获取委托明细信息 /// /// /// public static Model.View_CH_CheckItem GetTrustItemByCheckItem(string checkItemID) { return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.CHT_CheckItemID == checkItemID); } /// /// 根据焊口ID获取委托明细信息 /// /// /// public static Model.View_CH_CheckItem GetViewCheckItemByJOTID(string jotId) { return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId); } public static Model.View_CH_CheckItem GetNoCheckViewCheckItemByJOTID(string jotId) { return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId&&e.CHT_CheckID ==null); } public static Model.View_CH_CheckItem GetNoCheckViewCheckItemByJOTID(string jotId,string CH_TrustID) { return Funs.DB.View_CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId && e.CH_TrustID == CH_TrustID); } /// /// 根据焊口ID获取检测明细信息 /// /// /// public static List GetTrustItemByCheck(string checkId) { return Funs.DB.CH_CheckItem.Where(e => e.CHT_CheckID == checkId).ToList(); } /// /// 根据焊口ID和检测id获取检测明细信息 /// /// /// public static Model.CH_CheckItem GetTrustItemByCheckAndJotId(string checkId, string jotId) { return Funs.DB.CH_CheckItem.FirstOrDefault(e => e.CHT_CheckID == checkId && e.JOT_ID == jotId); } /// /// 添加 /// /// public static void AddCheckItem(Model.CH_CheckItem checkItem) { Model.CH_CheckItem newCheckItem = new Model.CH_CheckItem(); string newKeyID = SQLHelper.GetNewID(typeof(Model.CH_CheckItem)); newCheckItem.CHT_CheckItemID = newKeyID; newCheckItem.CHT_CheckID = checkItem.CHT_CheckID; newCheckItem.JOT_ID = checkItem.JOT_ID; newCheckItem.CH_TrustItemID = checkItem.CH_TrustItemID; newCheckItem.CHT_CheckMethod = checkItem.CHT_CheckMethod; newCheckItem.CHT_RequestDate = checkItem.CHT_RequestDate; newCheckItem.CHT_RepairLocation = checkItem.CHT_RepairLocation; newCheckItem.CHT_TotalFilm = checkItem.CHT_TotalFilm; newCheckItem.CHT_PassFilm = checkItem.CHT_PassFilm; newCheckItem.CHT_CheckResult = checkItem.CHT_CheckResult; newCheckItem.CHT_CheckNo = checkItem.CHT_CheckNo; newCheckItem.CHT_FilmDate = checkItem.CHT_FilmDate; newCheckItem.CHT_ReportDate = checkItem.CHT_ReportDate; newCheckItem.CHT_Remark = checkItem.CHT_Remark; newCheckItem.CHT_FloorWelder1 = checkItem.CHT_FloorWelder1; newCheckItem.CHT_FloorWelder2 = checkItem.CHT_FloorWelder2; newCheckItem.FilmSpecifications = checkItem.FilmSpecifications; newCheckItem.DefectLength = checkItem.DefectLength; newCheckItem.DefectDepth = checkItem.DefectDepth; newCheckItem.DefectHeight = checkItem.DefectHeight; newCheckItem.ExtendingRice = checkItem.ExtendingRice; newCheckItem.Defects_Definition = checkItem.Defects_Definition; Funs.DB.CH_CheckItem.InsertOnSubmit(newCheckItem); Funs.DB.SubmitChanges(); } /// /// 根据检测单号获取相关的所有明细 /// /// /// public static List GetCheckItemByCheck(string cht_checkId) { return (from x in Funs.DB.CH_CheckItem where x.CHT_CheckID == cht_checkId select x).ToList(); } /// /// 修改检测明细审核日期 /// /// 主表ID /// 1表示更新为当前时间,2表示为取消审核日期 public static void UpdateCheckItemAudioTime(string cht_CheckID, string flag) { var q = GetCheckItemByCheck(cht_CheckID); foreach (var item in q) { Model.CH_CheckItem newCheck = item; if (flag == "1") { newCheck.CHT_AuditTime = DateTime.Now; } else { newCheck.CHT_AuditTime = null; } Funs.DB.SubmitChanges(); } } /// /// 根据主表Id删除所有明细信息 /// /// public static void DeleteCheckItemByCheckId(string checkId) { var checkItem = from x in Funs.DB.CH_CheckItem where x.CHT_CheckID == checkId select x; if (checkItem != null) { Funs.DB.CH_CheckItem.DeleteAllOnSubmit(checkItem); Funs.DB.SubmitChanges(); } } /// /// 更改焊口检测情况 /// /// /// public static void UpdateJointCheckFlag(string jot_id, string type) { var jointinfo = Funs.DB.PW_JointInfo.FirstOrDefault(x => x.JOT_ID == jot_id); if (jointinfo != null) { if (type == "1") { if (string.IsNullOrEmpty(jointinfo.JOT_CheckFlag) || jointinfo.JOT_CheckFlag == "00") { jointinfo.JOT_CheckFlag = "01"; } else if (jointinfo.JOT_CheckFlag == "01")//一次检测,未审核 { jointinfo.JOT_CheckFlag = "02"; } else if (jointinfo.JOT_CheckFlag == "02")//一次检测,已审核 { jointinfo.JOT_CheckFlag = "11"; } else if (jointinfo.JOT_CheckFlag == "11")//二次检测,未审核 { jointinfo.JOT_CheckFlag = "12"; } else if (jointinfo.JOT_CheckFlag == "12")//二次检测,已审核 { jointinfo.JOT_CheckFlag = "21"; } else if (jointinfo.JOT_CheckFlag == "21")//三次检测,未审核 { jointinfo.JOT_CheckFlag = "22";//三次检测,已审核 } } else { if (jointinfo.JOT_CheckFlag == "22") { jointinfo.JOT_CheckFlag = "21"; } else if (jointinfo.JOT_CheckFlag == "21") { jointinfo.JOT_CheckFlag = "12"; } else if (jointinfo.JOT_CheckFlag == "12") { jointinfo.JOT_CheckFlag = "11"; } else if (jointinfo.JOT_CheckFlag == "11") { jointinfo.JOT_CheckFlag = "02"; } else if (jointinfo.JOT_CheckFlag == "02") { jointinfo.JOT_CheckFlag = "01"; } else { jointinfo.JOT_CheckFlag = "00"; } } } Funs.DB.SubmitChanges(); } /// /// 根据焊口信息获取检测记录 /// /// /// public static Model.CH_CheckItem GetCheckItemByJotId(string jotId) { return Funs.DB.CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId); } public static Model.CH_CheckItem GetCheckItemByJotId(string jotId,string checkId) { return Funs.DB.CH_CheckItem.FirstOrDefault(e => e.JOT_ID == jotId && e.CHT_CheckID== checkId); } /// /// 根据检测id获取明细视图 /// /// /// public static List GetViewCheckItemByCheckId(string checkId) { return (from x in Funs.DB.View_CH_CheckItem where x.CHT_CheckID == checkId select x).ToList(); } } }