diff --git a/SGGL/BLL/HJGL/PointTrust/PointBatchService.cs b/SGGL/BLL/HJGL/PointTrust/PointBatchService.cs index 6b396b5e..c1cb3789 100644 --- a/SGGL/BLL/HJGL/PointTrust/PointBatchService.cs +++ b/SGGL/BLL/HJGL/PointTrust/PointBatchService.cs @@ -1,5 +1,13 @@ -using System; +using Microsoft.SqlServer.Dts.Runtime; +using NPOI.SS.Formula.Functions; +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SqlClient; using System.Linq; +using System.Windows.Media.Animation; +using System.Windows; +using Model; namespace BLL { @@ -84,6 +92,236 @@ namespace BLL db.HJGL_Batch_PointBatch.DeleteOnSubmit(batch); db.SubmitChanges(); } + /// + /// 根据焊口id删除批信息 + /// + /// + public static void DeleteBatchByWeldJointId(string weldJointId) + { + var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(weldJointId); + + if (newWeldJoint != null ) + { + var isTrust = from x in Funs.DB.HJGL_Batch_BatchTrustItem + where x.WeldJointId == weldJointId + select x; ; + if (!isTrust.Any()) + { + var pointBatchItems = from x in Funs.DB.HJGL_Batch_PointBatchItem where x.WeldJointId == weldJointId select x; + string pointBatchId = pointBatchItems.FirstOrDefault()?.PointBatchId; + + // 删除焊口所在批明细信息 + BLL.PointBatchDetailService.DeleteBatchDetail(weldJointId); + + // 删除批信息 + var batch = from x in Funs.DB.HJGL_Batch_PointBatchItem where x.PointBatchId == pointBatchId select x; + if (!string .IsNullOrEmpty(pointBatchId) && !batch.Any()) + { + DeleteBatch(pointBatchId); + } + //BLL.Batch_NDEItemService.DeleteAllNDEInfoToWeldJoint(item.WeldJointId); + + } + else + { + // errlog += "焊口【" + newWeldJoint.WeldJointCode + "】已进委托单了,不能删除。"; + } + } + } + /// + /// 根据焊口id组批 + /// + public static string AddBatchByWeldJointId(string weldJointId, DateTime? weldingDate, string batchCondition) + { + string errlog = string.Empty; + string[] condition = batchCondition.Split('|'); + var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(weldJointId); + var pipeline = BLL.PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId); + var project = BLL.ProjectService.GetProjectByProjectId(pipeline.ProjectId); + var unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(pipeline.UnitWorkId); + var unit = BLL.UnitService.GetUnitByUnitId(pipeline.UnitId); + var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(newWeldJoint.DetectionTypeId); + var ndtr = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(pipeline.DetectionRateId); + + if (newWeldJoint != null) + { + bool isPass = true; + foreach (string c in condition) + { + if (c == "1") + { + if (string.IsNullOrEmpty(pipeline.UnitWorkId)) + { + isPass = false; + break; + + } + } + if (c == "2") + { + if (string.IsNullOrEmpty(pipeline.UnitId)) + { + isPass = false; + break; + + } + } + if (c == "3") + { + if (string.IsNullOrEmpty(newWeldJoint.DetectionTypeId)) + { + isPass = false; + break; + } + } + if (c == "4") + { + if (string.IsNullOrEmpty(pipeline.DetectionRateId)) + { + isPass = false; + break; + } + } + if (c == "5") + { + if (string.IsNullOrEmpty(pipeline.PipingClassId)) + { + isPass = false; + break; + } + } + // 6是管线,7是焊工都不可能为空,这里就不判断了 + } + if (isPass) + { + string strSql = @"SELECT PointBatchId FROM dbo.HJGL_Batch_PointBatch + WHERE (EndDate IS NULL OR EndDate ='') + AND ProjectId = @ProjectId + AND UnitWorkId = @UnitWorkId AND UnitId =@UnitId + AND DetectionTypeId =@DetectionTypeId + AND DetectionRateId =@DetectionRateId"; + List listStr = new List + { + new SqlParameter("@ProjectId", project.ProjectId), + new SqlParameter("@UnitWorkId", pipeline.UnitWorkId), + new SqlParameter("@UnitId", pipeline.UnitId), + new SqlParameter("@DetectionTypeId", newWeldJoint.DetectionTypeId), + new SqlParameter("@DetectionRateId", pipeline.DetectionRateId) + }; + + // 5,6,7项为可选项 + if (condition.Contains("5")) + { + strSql += " AND PipingClassId =@PipingClassId"; + listStr.Add(new SqlParameter("@PipingClassId", pipeline.PipingClassId)); + } + if (condition.Contains("6")) + { + strSql += " AND PipelineId =@PipelineId"; + listStr.Add(new SqlParameter("@PipelineId", newWeldJoint.PipelineId)); + } + if (condition.Contains("7")) + { + strSql += " AND WelderId =@WelderId"; + listStr.Add(new SqlParameter("@WelderId", newWeldJoint.CoverWelderId)); + } + + SqlParameter[] parameter = listStr.ToArray(); + DataTable batchInfo = SQLHelper.GetDataTableRunText(strSql, parameter); + + string batchId = string.Empty; + if (batchInfo.Rows.Count == 0) + { + Model.HJGL_Batch_PointBatch batch = new Model.HJGL_Batch_PointBatch(); + batch.PointBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_PointBatch)); + batchId = batch.PointBatchId; + string perfix = project.ProjectCode + "-" + unitWork.UnitWorkCode + "-GD-DK-" + ndt.DetectionTypeCode + "-" + ndtr.DetectionRateValue.ToString() + "%-"; + batch.PointBatchCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCode4ByProjectId", "dbo.HJGL_Batch_PointBatch", "PointBatchCode", project.ProjectId, perfix); + + batch.ProjectId = project.ProjectId; + batch.UnitWorkId = pipeline.UnitWorkId; + batch.BatchCondition = batchCondition; + batch.UnitId = pipeline.UnitId; + batch.DetectionTypeId = newWeldJoint.DetectionTypeId; + batch.DetectionRateId = pipeline.DetectionRateId; + if (condition.Contains("5")) + { + batch.PipingClassId = pipeline.PipingClassId; + } + if (condition.Contains("6")) + { + batch.PipelineId = newWeldJoint.PipelineId; + if (pipeline.PipeArea == PipelineService.PipeArea_FIELD) + { + perfix += "XC-"; + batch.PointBatchCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCode4ByProjectId", "dbo.HJGL_Batch_PointBatch", "PointBatchCode", project.ProjectId, perfix); + + } + else if (pipeline.PipeArea == PipelineService.PipeArea_SHOP) + { + perfix += "GC-"; + batch.PointBatchCode = BLL.SQLHelper.RunProcNewIdByProjectId("SpGetNewCode4ByProjectId", "dbo.HJGL_Batch_PointBatch", "PointBatchCode", project.ProjectId, perfix); + + } + } + if (condition.Contains("7")) + { + batch.WelderId = newWeldJoint.CoverWelderId; + } + batch.StartDate = DateTime.Now; + BLL.PointBatchService.AddPointBatch(batch); + } + else + { + batchId = batchInfo.Rows[0][0].ToString(); + } + + var b = BLL.PointBatchDetailService.GetBatchDetailByJotId(weldJointId); + if (b == null) + { + try + { + Model.HJGL_Batch_PointBatchItem batchDetail = new Model.HJGL_Batch_PointBatchItem(); + string pointBatchItemId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_PointBatchItem)); + batchDetail.PointBatchItemId = pointBatchItemId; + batchDetail.PointBatchId = batchId; + batchDetail.WeldJointId = weldJointId; + batchDetail.WeldingDate = weldingDate; + batchDetail.CreatDate = DateTime.Now; + BLL.Funs.DB.HJGL_Batch_PointBatchItem.InsertOnSubmit(batchDetail); + BLL.Funs.DB.SubmitChanges(); + + // 焊工首道口RT必点 + var joints = from x in Funs.DB.HJGL_Batch_PointBatchItem + join y in Funs.DB.HJGL_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.HJGL_WeldJoint on x.WeldJointId equals j.WeldJointId + where z.DetectionTypeCode == "RT" + && j.CoverWelderId == newWeldJoint.CoverWelderId + select x; + if (joints.Count() <= 1) + { + BLL.PointBatchDetailService.UpdatePointBatchDetail(pointBatchItemId, "1", System.DateTime.Now); + BLL.PointBatchDetailService.UpdateWelderFirst(pointBatchItemId, true); + } + } + catch + { + + } + } + } + else + { + errlog += "焊口【" + newWeldJoint.WeldJointCode + "】组批条件不能为空。"; + } + + } + + return errlog; + } + + } } diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReportEdit.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReportEdit.aspx.cs index 715faddb..558a3655 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReportEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldReportEdit.aspx.cs @@ -526,7 +526,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage { var t = BLL.WeldTaskService.GetWeldTaskById(row); - errlog += InsertWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId, t.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, true); + errlog += InsertWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId, t.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, false); } } else @@ -536,12 +536,12 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage if (Grid1.SelectedRowIDArray.Contains(Grid1.Rows[i].RowID)) { var t = BLL.WeldTaskService.GetWeldTaskById(Grid1.Rows[i].RowID); - errlog += InsertWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId, t.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, true); + errlog += InsertWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId, t.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, false); } else { var t = BLL.WeldTaskService.GetWeldTaskById(Grid1.Rows[i].RowID); - errlog += DeleteWeldingDailyItem(t.WeldJointId, t.CoverWelderId, t.BackingWelderId, t.JointAttribute, newWeldingDaily.WeldingDate, batchCondition, true); + errlog += DeleteWeldingDailyItem(t.WeldJointId); } } } @@ -827,22 +827,21 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage { if (!string.IsNullOrEmpty(coverWelderId) && !string.IsNullOrEmpty(backingWelderId)) { + newWeldJoint.WeldingDailyId = this.WeldingDailyId; + newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(); + newWeldJoint.CoverWelderId = coverWelderId; + newWeldJoint.BackingWelderId = backingWelderId; + //if (item.WeldingLocationId != Const._Null) + //{ + // newWeldJoint.WeldingLocationId = item.WeldingLocationId; + //} + newWeldJoint.JointAttribute = jointAttribute; + BLL.WeldJointService.UpdateWeldJoint(newWeldJoint); + + // 更新焊口号 修改固定焊口号后 +G + BLL.WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd); if (isSave) { - newWeldJoint.WeldingDailyId = this.WeldingDailyId; - newWeldJoint.WeldingDailyCode = this.txtWeldingDailyCode.Text.Trim(); - newWeldJoint.CoverWelderId = coverWelderId; - newWeldJoint.BackingWelderId = backingWelderId; - //if (item.WeldingLocationId != Const._Null) - //{ - // newWeldJoint.WeldingLocationId = item.WeldingLocationId; - //} - newWeldJoint.JointAttribute = jointAttribute; - BLL.WeldJointService.UpdateWeldJoint(newWeldJoint); - - // 更新焊口号 修改固定焊口号后 +G - BLL.WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd); - // 进批 //BLL.Batch_PointBatchItemService.InsertPointBatch(this.ProjectId, this.drpUnit.SelectedValue, this.drpUnitWork.SelectedValue, item.CoverWelderId, item.WeldJointId, weldingDate); bool isPass = true; @@ -1035,7 +1034,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage /// /// /// - private string DeleteWeldingDailyItem(string weldJointId, string coverWelderId, string backingWelderId, string jointAttribute, DateTime? weldingDate, string batchCondition, bool isSave) + private string DeleteWeldingDailyItem(string weldJointId) { string errlog = string.Empty; var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(weldJointId); @@ -1063,7 +1062,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage var pointBatchItems = from x in Funs.DB.HJGL_Batch_PointBatchItem where x.WeldJointId == weldJointId select x; string pointBatchId = pointBatchItems.FirstOrDefault().PointBatchId; - // 删除焊口所在批明细信息 + /*// 删除焊口所在批明细信息 BLL.PointBatchDetailService.DeleteBatchDetail(weldJointId); // 删除批信息 @@ -1071,10 +1070,8 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage if (pointBatchId != null && batch.Count() == 0) { BLL.PointBatchService.DeleteBatch(pointBatchId); - } - //BLL.Batch_NDEItemService.DeleteAllNDEInfoToWeldJoint(item.WeldJointId); + }*/ } - //BLL.Sys_LogService.AddLog(BLL.Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_WeldReportMenuId, Const.BtnDelete, weldingDailyId); } else { diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs index b45da0d1..025e2f42 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs @@ -422,6 +422,15 @@ namespace FineUIPro.Web.HJGL.WeldingManage jot.JointAttribute = item.JointAttribute; } BLL.WeldJointService.UpdateWeldJoint(jot); + // 获取组批条件 + var batchC = BLL.Project_SysSetService.GetSysSetBySetId("5", CurrUser.LoginProjectId); + if (batchC != null) + { + string batchCondition = batchC.SetValue; + BLL.PointBatchService.AddBatchByWeldJointId(item.WeldJointId,null, batchCondition); + + } + } } } @@ -910,6 +919,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage if (task != null) { BLL.WeldTaskService.DeleteWeldingTask(task.WeldTaskId); + PointBatchService.DeleteBatchByWeldJointId(task.WeldJointId); } } ShowNotify("删除成功!", MessageBoxIcon.Success);