using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace BLL { /// /// 点口明细表 /// public static class Batch_PointBatchItemService { /// /// 根据主键获取相关明细信息 /// /// /// public static Model.Batch_PointBatchItem GetPointBatchItemByPointBatchItemId(string pointBatchItemId) { return Funs.DB.Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchItemId == pointBatchItemId); } /// /// 根据主键获取相关明细信息 /// /// /// public static List GetPointBatchItemByPointBatchId(string pointBatchId) { return (from x in Funs.DB.Batch_PointBatchItem where x.PointBatchId == pointBatchId select x).ToList(); } /// /// 根据主键获取批里已点口的明细 /// /// /// public static List GetPointByPointBatchId(string pointBatchId) { return (from x in Funs.DB.Batch_PointBatchItem where x.PointBatchId == pointBatchId && (x.PointState != null && x.PointState != "") select x).ToList(); } /// /// 根据主键获取相关明细视图信息 /// /// /// public static List GetViewPointBatchItemByPointBatchId(string pointBatchId) { return (from x in Funs.DB.View_Batch_PointBatchItem where x.PointBatchId == pointBatchId orderby x.PipelineCode, x.WeldJointCode select x).ToList(); } /// /// 增加 /// /// public static void AddPointBatchItem(Model.Batch_PointBatchItem pointBatchItem) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = new Model.Batch_PointBatchItem { PointBatchItemId = pointBatchItem.PointBatchItemId, PointBatchId = pointBatchItem.PointBatchId, WeldJointId = pointBatchItem.WeldJointId, WeldingDate = pointBatchItem.WeldingDate, PointState = pointBatchItem.PointState, PointDate = pointBatchItem.PointDate, RepairDate = pointBatchItem.RepairDate, CutDate = pointBatchItem.CutDate, CreatDate = pointBatchItem.CreatDate, Remark = pointBatchItem.Remark, OldPointState = pointBatchItem.OldPointState, OldPointDate = pointBatchItem.OldPointDate, IsCheckRepair = pointBatchItem.IsCheckRepair, IsBuildTrust = pointBatchItem.IsBuildTrust, AcceptLevel = pointBatchItem.AcceptLevel, RepairRecordId = pointBatchItem.RepairRecordId, BatchOrder = pointBatchItem.BatchOrder, IsCompletedPoint=pointBatchItem.IsCompletedPoint }; db.Batch_PointBatchItem.InsertOnSubmit(newPointBatchItem); db.SubmitChanges(); } /// /// 根据主键删除相关明细信息 /// /// public static void DeletePointBatchItemByPointBatchId(string pointBatchId) { var pointBatchItem = (from x in Funs.DB.Batch_PointBatchItem where x.PointBatchId == pointBatchId select x).ToList(); if (pointBatchItem!=null) { Funs.DB.Batch_PointBatchItem.DeleteAllOnSubmit(pointBatchItem); Funs.DB.SubmitChanges(); } } /// /// 根据主键删除相关明细信息 /// /// public static void DeletePointBatchItemById(string pointBatchItemId) { Model.HJGLDB db = Funs.DB; var pointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(x=> x.PointBatchItemId == pointBatchItemId); if (pointBatchItem != null) { db.Batch_PointBatchItem.DeleteOnSubmit(pointBatchItem); db.SubmitChanges(); } } #region 更新批明细表信息-点口 /// /// /// /// /// /// /// public static void UpdatePointBatchItem(string pointBatchItemId, string pointState, DateTime? pointDate, DateTime? cutDate) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId); if (newPointBatchItem != null) { newPointBatchItem.PointState = pointState; newPointBatchItem.PointDate = pointDate; newPointBatchItem.CutDate = cutDate; newPointBatchItem.IsCompletedPoint = true; db.SubmitChanges(); var pointBatch = db.Batch_PointBatch.FirstOrDefault(e => e.PointBatchId == newPointBatchItem.PointBatchId); if (pointBatch != null) { pointBatch.IsTrust = false; db.SubmitChanges(); } } } #endregion #region 点口审核 /// /// 点口审核 /// /// /// public static void PointAudit(string pointBatchItemId, bool isAudit) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId); if (newPointBatchItem != null) { newPointBatchItem.IsAudit = isAudit; db.SubmitChanges(); } } #endregion #region 首件制 /// /// 焊工首件制 /// /// /// public static void UpdateWelderFirst(string pointBatchItemId, bool? welderFirst) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId); newPointBatchItem.IsWelderFirst = welderFirst; db.SubmitChanges(); } /// /// 管线首件 /// /// /// public static void UpdatePipelineFirst(string pointBatchItemId, bool? pipelineFirst) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId); newPointBatchItem.IsPipelineFirst = pipelineFirst; db.SubmitChanges(); } #endregion /// /// 该口是否完成点口 /// /// /// public static void UpdateIsCompletedPoint(string pointBatchItemId, bool? isCompleted) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId); newPointBatchItem.IsCompletedPoint = isCompleted; db.SubmitChanges(); } public static void UpdatePointBatchOrder(string pointBatchItemId, int batchOrder) { Model.HJGLDB db = Funs.DB; Model.Batch_PointBatchItem newPointBatchItem = db.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId); newPointBatchItem.BatchOrder = batchOrder; db.SubmitChanges(); } #region 生成焊口批 方法 /// /// /// /// /// /// /// /// /// public static void InsertPointBatch(string projectId, string unitId, string installationId, string backingWelderId, string coverWelderId, string weldJointId, DateTime? weldingDate) { var project = BLL.Base_ProjectService.GetProjectByProjectId(projectId); var jot = Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId); //焊口表 // 判断此焊口是否已存在批中 var pointBatchItemIsExists = from x in Funs.DB.Batch_PointBatchItem where x.WeldJointId == weldJointId select x; if (jot != null && !string.IsNullOrEmpty(backingWelderId) && !string.IsNullOrEmpty(coverWelderId) && pointBatchItemIsExists.Count() == 0) { //Model.Base_DetectionType ndt = null; var isoInfo = Funs.DB.Pipeline_Pipeline.FirstOrDefault(x => x.PipelineId == jot.PipelineId); //管线表 var weldType = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId); if (isoInfo != null && isoInfo.DetectionRateId != null && !string.IsNullOrEmpty(jot.DetectionType)) { // 进批 var rate = Funs.DB.Base_DetectionRate.FirstOrDefault(x => x.DetectionRateId == isoInfo.DetectionRateId); string[] ndtTypeList = jot.DetectionType.Split('|'); foreach (string ndt in ndtTypeList) { var ndttype = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(ndt); var pointBatch = from x in Funs.DB.Batch_PointBatch where x.ProjectId == projectId && x.UnitId == unitId && x.InstallationId == installationId && x.DetectionRateId == isoInfo.DetectionRateId && x.DetectionTypeId == ndt && x.PipelineId == isoInfo.PipelineId && (!x.EndDate.HasValue) select x; string pointBatchId = string.Empty; if (pointBatch.Count() == 0) //批次空时 { Model.Batch_PointBatch newPointBatch = new Model.Batch_PointBatch(); pointBatchId = SQLHelper.GetNewID(typeof(Model.Batch_PointBatch)); string pointBatchCode = Batch_PointBatchService.GetNewPointBatchCode(projectId, isoInfo.PipelineCode, ndttype.DetectionTypeCode, rate.DetectionRateCode); newPointBatch.PointBatchId = pointBatchId; newPointBatch.PointBatchCode = pointBatchCode; newPointBatch.ProjectId = projectId; newPointBatch.UnitId = unitId; newPointBatch.PipelineId = jot.PipelineId; newPointBatch.InstallationId = installationId; newPointBatch.DetectionTypeId = ndt; newPointBatch.DetectionRateId = isoInfo.DetectionRateId; newPointBatch.StartDate = System.DateTime.Now; newPointBatch.IsTrust = true; Batch_PointBatchService.AddPointBatch(newPointBatch); // 生成主表 } else { pointBatchId = pointBatch.FirstOrDefault().PointBatchId; } Model.Batch_PointBatchItem newPointBatchItem = new Model.Batch_PointBatchItem(); string pointBatchItemId = SQLHelper.GetNewID(typeof(Model.Batch_PointBatchItem)); newPointBatchItem.PointBatchItemId = pointBatchItemId; newPointBatchItem.PointBatchId = pointBatchId; newPointBatchItem.WeldJointId = weldJointId; newPointBatchItem.WeldingDate = weldingDate; newPointBatchItem.IsCheckRepair = false; if (rate.DetectionRateValue != 0) { if (rate.DetectionRateValue == 5 || rate.DetectionRateValue == 10) { newPointBatchItem.AcceptLevel = "Ⅲ"; } else { newPointBatchItem.AcceptLevel = "Ⅱ"; } } newPointBatchItem.IsCompletedPoint = false; BLL.Batch_PointBatchItemService.AddPointBatchItem(newPointBatchItem); // 插入明细表 // 点口 if (rate.DetectionRateValue != 0) { if (ndttype.SysType == "射线检测") { // 整个装置的首三道口必点 var threeJot = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Batch_PointBatch on x.PointBatchId equals y.PointBatchId join z in Funs.DB.Base_DetectionType on y.DetectionTypeId equals z.DetectionTypeId join j in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals j.WeldJointId where y.ProjectId == projectId && y.InstallationId==installationId && z.SysType == "射线检测" && (j.CoverWelderId == coverWelderId || j.BackingWelderId==backingWelderId) && x.PointDate.HasValue select x; if (Funs.UsingUnit == "TCC11") { if (threeJot.Count() <= 1) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); UpdateWelderFirst(pointBatchItemId, true); } } else { if (threeJot.Count() <= 2) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); UpdateWelderFirst(pointBatchItemId, true); } } //// 焊工在这个批首道口RT要覆盖 不要了 //var joints = from x in Funs.DB.Batch_PointBatchItem // join y in Funs.DB.Batch_PointBatch on x.PointBatchId equals y.PointBatchId // join z in Funs.DB.Base_DetectionType on y.DetectionTypeId equals z.DetectionTypeId // join j in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals j.WeldJointId // where y.PipelineId == jot.PipelineId && z.SysType == "射线检测" // && j.CoverWelderId == welderId && x.PointDate.HasValue // select x; //if (joints.Count() == 0) //{ // UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); // UpdatePipelineFirst(pointBatchItemId, true); //} // 管径大于等于500必点 if (jot.Dia >= 500) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } if (jot.IsGoldJoint == true) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } } // 一个段位的数量 int dnum = Convert.ToInt32((double)100 / (double)rate.DetectionRateValue); // 批里未完成点口的焊口 var totalJot = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId where x.PointBatchId == pointBatchId && x.IsCompletedPoint == false && (y.CoverWelderId==coverWelderId || y.BackingWelderId==backingWelderId) && y.WeldingDate.HasValue && (y.IsCancel == false || y.IsCancel == null) select x; int totalnum = totalJot.Count(); // 时间>15处理放globle //DateTime lastWeldingDate = totalJot.Select(x => x.WeldingDate.Value).Min(); //if((DateTime.Now.Date- lastWeldingDate).Days>=15) // 该段达到检测比例的数量 if (dnum == totalnum) { var GJot = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId where x.PointBatchId == pointBatchId && x.IsCompletedPoint == false && (y.IsCancel == false || y.IsCancel == null) && y.JointAttribute== "固定F" select x; // 先查找固定口数量,如有固定口,则优先点 if (GJot.Count() > 0) { int Gnum = GJot.Count(); int rnum = Funs.GetRandomNum(1, Gnum); int j = 1; foreach (var g in GJot) { if (rnum == j) { UpdatePointBatchItem(g.PointBatchItemId, "1", System.DateTime.Now, null); } j++; } } else { int rnum = Funs.GetRandomNum(1, totalnum); int j = 1; foreach (var g in totalJot) { if (rnum == j) { UpdatePointBatchItem(g.PointBatchItemId, "1", System.DateTime.Now, null); } j++; } } int batchOrder= GetMaxBatchOrder(pointBatchId); // 点口后,更新该段批里的所有口为完成点口,并更新分段的顺序 foreach (var g in totalJot) { UpdateIsCompletedPoint(g.PointBatchItemId, true); UpdatePointBatchOrder(g.PointBatchItemId, batchOrder); } } } } } } } #endregion #region 生成焊口批-1 方法 /// /// /// /// /// /// /// /// /// public static void InsertPointBatch1(string projectId, string unitId, string installationId, string welderId, string weldJointId, DateTime? weldingDate) { var project = BLL.Base_ProjectService.GetProjectByProjectId(projectId); var jot = Funs.DB.Pipeline_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId); //焊口表 // 判断此焊口是否已存在批中 var pointBatchItemIsExists = from x in Funs.DB.Batch_PointBatchItem where x.WeldJointId == weldJointId select x; if (jot != null && !string.IsNullOrEmpty(welderId) && pointBatchItemIsExists.Count() == 0) { //当前只考虑RT,PT Model.Base_DetectionType ndt = null; var isoInfo = Funs.DB.Pipeline_Pipeline.FirstOrDefault(x => x.PipelineId == jot.PipelineId); //管线表 var weldType = BLL.Base_WeldTypeService.GetWeldTypeByWeldTypeId(jot.WeldTypeId); // 1表示对接焊缝 进行RT探伤,2,3表示承插焊缝或支管连接焊缝进行PT探伤 if (weldType.Flag == "1") { ndt = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.SysType == "射线检测"); } else { ndt = Funs.DB.Base_DetectionType.FirstOrDefault(x => x.SysType == "渗透检测"); } if (isoInfo != null && isoInfo.DetectionRateId != null && ndt != null) { // 进批 var rate = Funs.DB.Base_DetectionRate.FirstOrDefault(x => x.DetectionRateId == isoInfo.DetectionRateId); var pointBatch = from x in Funs.DB.Batch_PointBatch where x.ProjectId == projectId && x.UnitId == unitId && x.InstallationId == installationId && x.DetectionRateId == isoInfo.DetectionRateId && x.DetectionTypeId == ndt.DetectionTypeId && x.PipelineId == isoInfo.PipelineId && (!x.EndDate.HasValue) select x; string pointBatchId = string.Empty; if (pointBatch.Count() == 0) //批次空时 { Model.Batch_PointBatch newPointBatch = new Model.Batch_PointBatch(); pointBatchId = SQLHelper.GetNewID(typeof(Model.Batch_PointBatch)); string pointBatchCode = Batch_PointBatchService.GetNewPointBatchCode(projectId, isoInfo.PipelineCode, ndt.DetectionTypeCode, rate.DetectionRateCode); newPointBatch.PointBatchId = pointBatchId; newPointBatch.PointBatchCode = pointBatchCode; newPointBatch.ProjectId = projectId; newPointBatch.UnitId = unitId; newPointBatch.PipelineId = jot.PipelineId; newPointBatch.InstallationId = installationId; newPointBatch.DetectionTypeId = ndt.DetectionTypeId; newPointBatch.DetectionRateId = isoInfo.DetectionRateId; newPointBatch.StartDate = System.DateTime.Now; newPointBatch.IsTrust = true; Batch_PointBatchService.AddPointBatch(newPointBatch); // 生成主表 } else { pointBatchId = pointBatch.FirstOrDefault().PointBatchId; } Model.Batch_PointBatchItem newPointBatchItem = new Model.Batch_PointBatchItem(); string pointBatchItemId = SQLHelper.GetNewID(typeof(Model.Batch_PointBatchItem)); newPointBatchItem.PointBatchItemId = pointBatchItemId; newPointBatchItem.PointBatchId = pointBatchId; newPointBatchItem.WeldJointId = weldJointId; newPointBatchItem.WeldingDate = weldingDate; newPointBatchItem.IsCheckRepair = false; if (rate.DetectionRateValue != 0) { if (rate.DetectionRateValue == 5 || rate.DetectionRateValue == 10) { newPointBatchItem.AcceptLevel = "Ⅲ"; } else { newPointBatchItem.AcceptLevel = "Ⅱ"; } } BLL.Batch_PointBatchItemService.AddPointBatchItem(newPointBatchItem); // 插入明细表 // 点口 if (rate.DetectionRateValue != 0) { if (weldType.Flag == "1") { // 整个装置的首两道口必点 var twoJot = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Batch_PointBatch on x.PointBatchId equals y.PointBatchId join z in Funs.DB.Base_DetectionType on y.DetectionTypeId equals z.DetectionTypeId join j in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals j.WeldJointId where y.ProjectId == projectId && z.SysType == "射线检测" && j.CoverWelderId == welderId && x.PointDate.HasValue select x; if (twoJot.Count() <= 1) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); UpdateWelderFirst(pointBatchItemId, true); } // 焊工在这个批首道口RT要覆盖 var joints = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Batch_PointBatch on x.PointBatchId equals y.PointBatchId join z in Funs.DB.Base_DetectionType on y.DetectionTypeId equals z.DetectionTypeId join j in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals j.WeldJointId where y.PipelineId == jot.PipelineId && z.SysType == "射线检测" && j.CoverWelderId == welderId && x.PointDate.HasValue select x; if (joints.Count() == 0) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); UpdatePipelineFirst(pointBatchItemId, true); } // 管径大于等于500必点 if (jot.Dia >= 500) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } if (jot.IsGoldJoint == true) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } // 固定口点口 宁波万华 if (project.ProjectArea == "2") { // 固定口100%点口 var jointsGD = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId where x.PointBatchItemId == pointBatchItemId && y.JointAttribute == "固定F" select x; if (jointsGD.Count() > 0) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } // 匹配随机数点口 // RT点口 // 当前焊口焊接的序号 int num = (from x in Funs.DB.Pipeline_WeldJoint join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId where x.PipelineId == jot.PipelineId && y.Flag == "1" && x.JointAttribute == "活动S" && (x.WeldingDailyId != null && x.WeldingDailyId != "") select x).Count(); if (!string.IsNullOrEmpty(isoInfo.RandomNum)) // 管线已生成随机点口数 { // 如随机点口的序号包含这个序号则自动点口 string[] random = isoInfo.RandomNum.Split(','); if (random.Contains(num.ToString())) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } } } // 按大于管线检测比例的40%产生的随机数点口 else { int num = (from x in Funs.DB.Pipeline_WeldJoint join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId where x.PipelineId == jot.PipelineId && y.Flag == "1" && (x.IsCancel == false || x.IsCancel == null) && (x.WeldingDailyId != null && x.WeldingDailyId != "") select x).Count(); // 计算在什么段位 int dnum = Convert.ToInt32(Math.Ceiling((double)(num) / ((double)100 / (double)rate.DetectionRateValue))); // 因为第一个段焊工覆盖,所以不用匹配随机数 if (dnum > 1) { // 获取该段位的随机数 string random = isoInfo.RandomNum.Split(',')[dnum - 1]; // 焊接位置的数 string dd = (num - (dnum - 1) * 100 / rate.DetectionRateValue).ToString(); // 匹配上点口 if (random == dd) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } } int totalNum = (from x in Funs.DB.Pipeline_WeldJoint join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId where x.PipelineId == jot.PipelineId && y.Flag == "1" && (x.IsCancel == false || x.IsCancel == null) select x).Count(); // 说明这条线已焊完,如固定口比例不足,则在固定口中随机补充缺的部分 if (num == totalNum) { // 固定口需要点口数 int needPointNum = Convert.ToInt32(Math.Ceiling(((double)(totalNum) * (double)(rate.DetectionRateValue) * 0.4) / 100.0)); // 固定口已点口数 int GdPointNum = (from x in Funs.DB.Pipeline_WeldJoint join y in Funs.DB.Batch_PointBatchItem on x.WeldJointId equals y.WeldJointId join z in Funs.DB.Batch_PointBatch on y.PointBatchId equals z.PointBatchId join n in Funs.DB.Base_DetectionType on z.DetectionTypeId equals n.DetectionTypeId where x.PipelineId == jot.PipelineId && x.WeldingDailyId != null && (x.IsCancel == false || x.IsCancel == null) && y.PointState == "1" && n.SysType == "射线检测" && x.JointAttribute == "固定F" select y.PointBatchItemId).Count(); if (GdPointNum < needPointNum) { int d = needPointNum - GdPointNum; // 没有点口的固定口 var GdNoPoint = from x in Funs.DB.Batch_PointBatchItem join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId join z in Funs.DB.Base_WeldType on y.WeldTypeId equals z.WeldTypeId where y.PipelineId == jot.PipelineId && y.WeldingDailyId != null && (y.IsCancel == false || y.IsCancel == null) && x.PointState == null && z.Flag == "1" && y.JointAttribute == "固定F" select x; int gdMaxValue = GdNoPoint.Count(); if (gdMaxValue > 0) { string random = string.Empty; int[] r = Funs.GetRandomNum(d, 1, gdMaxValue); var q = from x in r orderby x select x; foreach (int i in q) { if (i <= gdMaxValue) { random = random + i.ToString() + ","; } } int j = 1; foreach (var g in GdNoPoint) { if (random.Contains(j.ToString())) { UpdatePointBatchItem(g.PointBatchItemId, "1", System.DateTime.Now, null); } j++; } } } #region// 如这条线焊工未覆盖,则需覆盖,放前面覆盖了 //var welderList = (from x in Funs.DB.Pipeline_WeldJoint // join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId // where x.PipelineId == jot.PipelineId && y.Flag == "1" // select x.CoverWelderId).Distinct(); //foreach (var welder in welderList) //{ // // 该焊工是否在这条线有点口 // var welderPoint = from x in Funs.DB.Batch_PointBatchItem // join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId // join z in Funs.DB.Base_WeldType on y.WeldTypeId equals z.WeldTypeId // where y.PipelineId == jot.PipelineId && y.CoverWelderId == welder // && x.PointState == "1" && z.Flag == "1" // select x; // // 说明这个焊工在这个批里未覆盖 // if (welderPoint.Count() == 0) // { // var q = from x in Funs.DB.Batch_PointBatchItem // join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId // join z in Funs.DB.Base_WeldType on y.WeldTypeId equals z.WeldTypeId // orderby x.WeldingDate descending // where y.PipelineId == jot.PipelineId && y.CoverWelderId == welder // && z.Flag == "1" // select x; // // 将这个焊工最近焊的覆盖(点口) // UpdatePointBatchItem(q.First().PointBatchItemId, "1", System.DateTime.Now, null); // } //} #endregion } #region 暂不用 // 当前固定焊口焊接的序号 //if (jot.JointAttribute == "固定F") //{ // int num = (from x in Funs.DB.Pipeline_WeldJoint // join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId // where x.PipelineId == jot.PipelineId && x.JointAttribute == "固定F" // && y.Flag == "1" // && (x.WeldingDailyId != null && x.WeldingDailyId != "") // select x).Count(); // if (!string.IsNullOrEmpty(isoInfo.GDRandomNum)) // 管线已生成随机点口数 // { // // 如随机点口的序号包含这个序号则自动点口 // string[] random = isoInfo.GDRandomNum.Split(','); // if (random.Contains(num.ToString())) // { // UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); // } // } //} //else //{ // // 当前焊口焊接的序号 // int num = (from x in Funs.DB.Pipeline_WeldJoint // join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId // where x.PipelineId == jot.PipelineId && y.Flag == "1" && x.JointAttribute == "活动S" // && (x.WeldingDailyId != null && x.WeldingDailyId != "") // select x).Count(); // if (!string.IsNullOrEmpty(isoInfo.RandomNum)) // 管线已生成随机点口数 // { // // 如随机点口的序号包含这个序号则自动点口 // string[] random = isoInfo.RandomNum.Split(','); // if (random.Contains(num.ToString())) // { // UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); // } // } //} #endregion } } // PT点口 else { // BRO焊缝必点 if (weldType.WeldTypeCode == "BRO") { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } // 检测比例100%的管线必点 if (rate.DetectionRateValue == 100) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } // 当前焊口焊接的序号 int num = (from x in Funs.DB.Pipeline_WeldJoint join y in Funs.DB.Base_WeldType on x.WeldTypeId equals y.WeldTypeId where x.PipelineId == jot.PipelineId && (y.Flag == "2" || y.Flag == "3") && (x.WeldingDailyId != null && x.WeldingDailyId != "") select x).Count(); if (!string.IsNullOrEmpty(isoInfo.PTRandomNum)) // 管线已生成随机点口数 { // 如随机点口的序号包含这个序号则自动点口 string[] random = isoInfo.PTRandomNum.Split(','); // 检测比例大于10%的管线,按正常做PT if (rate.DetectionRateValue > 10 && rate.DetectionRateValue < 100) { if (random.Contains(num.ToString())) { UpdatePointBatchItem(pointBatchItemId, "1", System.DateTime.Now, null); } } } } } } } } #endregion #region 是否显示返修\切除页面通过批id /// /// 是否显示返修\切除页面 /// /// public static bool GetIsShowPointRepairByPointBatchId(string pointBatchId) { ////判断该焊口是否点口\扩透 是显示链接 var pointBatchItem = Funs.DB.Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchId == pointBatchId && !x.CutDate.HasValue && x.PointDate.HasValue && x.IsCheckRepair.HasValue && x.IsCheckRepair.Value); if (pointBatchItem != null) { return true; } else { return false; } } #endregion // 返回进批的顺序 public static int GetMaxBatchOrder(string pointBatchId) { int orderNum = 1; Model.HJGLDB db = Funs.DB; var batchItem = db.Batch_PointBatchItem.Where(x => x.PointBatchId == pointBatchId && x.IsCompletedPoint==true); if (batchItem.Count() > 0) { orderNum = (batchItem.Max(x => x.BatchOrder) != null ? batchItem.Max(x => x.BatchOrder).Value : 0) + 1; } return orderNum; } /// /// 更新委托次数 /// /// 委托批明细ID /// public static void UpdateTrustNum(string trustBatchItemId, int num) { Model.HJGLDB db = Funs.DB; var trustBatchItem = db.Batch_BatchTrustItem.FirstOrDefault(x => x.TrustBatchItemId == trustBatchItemId); if (trustBatchItem != null) { trustBatchItem.TrustNum = trustBatchItem.TrustNum ?? 0 + num; if (trustBatchItem.TrustNum < 0) { trustBatchItem.TrustNum = 0; } } db.SubmitChanges(); } } }