diff --git a/SGGL/BLL/API/HJGL/APINDETrustService.cs b/SGGL/BLL/API/HJGL/APINDETrustService.cs index 1f02b976..bb616813 100644 --- a/SGGL/BLL/API/HJGL/APINDETrustService.cs +++ b/SGGL/BLL/API/HJGL/APINDETrustService.cs @@ -434,7 +434,7 @@ namespace BLL Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust { TrustBatchId = trustBatchId, - TrustBatchCode = batch.PointBatchCode.Replace("-DK-", "-WT-"), + TrustBatchCode = BLL.Batch_BatchTrustService.BuildTrustBatchCode(batch.PointBatchCode, DateTime.Now), TrustDate = DateTime.Now, ProjectId = batch.ProjectId, PointBatchId = pointBatchId, @@ -534,7 +534,7 @@ namespace BLL var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(trust.DetectionRateId); string perfix = string.Empty; - perfix = unit.UnitCode + "-" + ndt.DetectionTypeCode + "-" + rate.DetectionRateValue.ToString() + "%-"; + perfix = BLL.Batch_BatchTrustService.BuildTrustBatchCodePrefix(unit.UnitCode, ndt.DetectionTypeCode, rate.DetectionRateValue.ToString(), DateTime.Now); string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust)); // 生成委托条件对比 diff --git a/SGGL/BLL/HJGL/PointTrust/Batch_BatchTrustService.cs b/SGGL/BLL/HJGL/PointTrust/Batch_BatchTrustService.cs index d38ed28e..877c9ebd 100644 --- a/SGGL/BLL/HJGL/PointTrust/Batch_BatchTrustService.cs +++ b/SGGL/BLL/HJGL/PointTrust/Batch_BatchTrustService.cs @@ -7,6 +7,47 @@ namespace BLL /// public static class Batch_BatchTrustService { + /// + /// 根据点口批编号生成委托单号,在流水号前追加日期段。 + /// + public static string BuildTrustBatchCode(string pointBatchCode, System.DateTime trustDate) + { + string trustBatchCode = (pointBatchCode ?? string.Empty).Replace("-DK-", "-WT-"); + return InsertDateBeforeSerial(trustBatchCode, trustDate); + } + + /// + /// 生成委托单号前缀,在流水号前追加日期段。 + /// + public static string BuildTrustBatchCodePrefix(string unitCode, string detectionTypeCode, string detectionRateValue, System.DateTime trustDate) + { + return unitCode + "-" + detectionTypeCode + "-" + detectionRateValue + "%-" + trustDate.ToString("yyyyMMdd") + "-"; + } + + private static string InsertDateBeforeSerial(string code, System.DateTime date) + { + if (string.IsNullOrEmpty(code)) + { + return code; + } + + string dateText = date.ToString("yyyyMMdd"); + int lastIndex = code.LastIndexOf('-'); + if (lastIndex < 0) + { + return code + "-" + dateText; + } + + string prefix = code.Substring(0, lastIndex); + string serial = code.Substring(lastIndex + 1); + if (prefix.EndsWith("-" + dateText, System.StringComparison.Ordinal)) + { + return code; + } + + return prefix + "-" + dateText + "-" + serial; + } + /// /// 根据主键获取无损委托 /// diff --git a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx index 4672e66c..e40ae9cd 100644 --- a/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx +++ b/SGGL/FineUIPro.Web/HJGL/NDT/NDTBatch.aspx @@ -130,6 +130,8 @@ AllowPaging="true" IsDatabasePaging="true" PageSize="10" OnPageIndexChange="Grid1_PageIndexChange" EnableTextSelection="True"> + "; + newNode.Text = "" + code + ""; } } else @@ -425,44 +416,65 @@ namespace FineUIPro.Web.HJGL.NDT { this.SetTextTemp(); this.PageInfoLoad(); ///页面输入提交信息 - var check = Funs.DB.View_Batch_NDE.FirstOrDefault(x => x.TrustBatchId == this.TrustBatchId); - if (check != null) + List ndeItems = this.GetDisplayNDEItems(); + this.BindGrid(ndeItems); + } + } + + /// + /// 获取检测单录入展示明细,保持与编辑界面一致。 + /// + /// + private List GetDisplayNDEItems() + { + List ndeItems = new List(); + var batchTrustItems = BLL.Batch_BatchTrustItemService.GetViewBatchTrustItem(this.TrustBatchId); + var check = Funs.DB.View_Batch_NDE.FirstOrDefault(x => x.TrustBatchId == this.TrustBatchId); + if (check != null) + { + ndeItems = BLL.Batch_NDEItemService.GetViewNDEItem(check.NDEID); + } + + List trustBatchItemIds = ndeItems.Select(x => x.TrustBatchItemId).ToList(); + foreach (var batchTrustItem in batchTrustItems) + { + if (!trustBatchItemIds.Contains(batchTrustItem.TrustBatchItemId)) { - string strSql = @"SELECT * FROM dbo.View_Batch_NDEItem d WHERE NDEID=@NDEID "; - List listStr = new List - { - - }; - listStr.Add(new SqlParameter("@NDEID", check.NDEID)); - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); - - // 2.获取当前分页数据 - //var table = this.GetPagedDataTable(Grid1, tb1); - Grid1.RecordCount = tb.Rows.Count; - tb = GetFilteredTable(Grid1.FilteredData, tb); - var table = this.GetPagedDataTable(Grid1, tb); - Grid1.DataSource = table; - Grid1.DataBind(); + Model.View_Batch_NDEItem item = new Model.View_Batch_NDEItem(); + item.NDEItemID = BLL.SQLHelper.GetNewID(typeof(Model.HJGL_Batch_NDEItem)); + item.PipelineCode = batchTrustItem.PipelineCode; + item.WeldJointCode = batchTrustItem.WeldJointCode; + item.UnitWorkCode = batchTrustItem.UnitWorkCode; + item.WelderCode = batchTrustItem.WelderCode; + item.NDEReportNo = batchTrustItem.TrustBatchCode; + item.TrustBatchItemId = batchTrustItem.TrustBatchItemId; + ndeItems.Add(item); } - else + } + + return ndeItems; + } + + /// + /// 绑定检测单录入展示明细。 + /// + /// + private void BindGrid(List ndeItems) + { + DataTable tb = this.LINQToDataTable(ndeItems); + Grid1.RecordCount = tb.Rows.Count; + tb = GetFilteredTable(Grid1.FilteredData, tb); + var table = this.GetPagedDataTable(Grid1, tb); + Grid1.DataSource = table; + Grid1.DataBind(); + + CheckBoxField ckbIsSelected = (CheckBoxField)Grid1.FindColumn("ckbIsSelected"); + for (int i = 0; i < this.Grid1.Rows.Count; i++) + { + string ndeItemId = Grid1.DataKeys[i][1] == null ? string.Empty : Grid1.DataKeys[i][1].ToString(); + if (BLL.Batch_NDEItemService.GetNDEItemById(ndeItemId) != null) { - string strSql = @"SELECT * FROM dbo.View_Batch_BatchTrustItem d WHERE TrustBatchId=@TrustBatchId "; - List listStr = new List - { - - }; - listStr.Add(new SqlParameter("@TrustBatchId", this.TrustBatchId)); - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); - - // 2.获取当前分页数据 - //var table = this.GetPagedDataTable(Grid1, tb1); - Grid1.RecordCount = tb.Rows.Count; - tb = GetFilteredTable(Grid1.FilteredData, tb); - var table = this.GetPagedDataTable(Grid1, tb); - Grid1.DataSource = table; - Grid1.DataBind(); + ckbIsSelected.SetCheckedState(i, true); } } } @@ -972,12 +984,22 @@ namespace FineUIPro.Web.HJGL.NDT /// protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { - string id = Grid1.DataKeys[e.RowIndex][0].ToString(); + string id = Grid1.DataKeys[e.RowIndex][1] == null ? string.Empty : Grid1.DataKeys[e.RowIndex][1].ToString(); if (e.CommandName == "CancelAudit") { if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_NDTBatchMenuId, Const.BtnCancelAuditing)) { + if (string.IsNullOrEmpty(id)) + { + ShowNotify("请选择已录入的检测项!", MessageBoxIcon.Warning); + return; + } Model.HJGL_Batch_NDEItem item = BLL.Batch_NDEItemService.GetNDEItemById(id); + if (item == null) + { + ShowNotify("请选择已录入的检测项!", MessageBoxIcon.Warning); + return; + } if (item.SubmitDate == null) { @@ -1047,4 +1069,4 @@ namespace FineUIPro.Web.HJGL.NDT } } } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/PointTrust/PointAudit.aspx.cs b/SGGL/FineUIPro.Web/HJGL/PointTrust/PointAudit.aspx.cs index 5eafffa9..be248680 100644 --- a/SGGL/FineUIPro.Web/HJGL/PointTrust/PointAudit.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/PointTrust/PointAudit.aspx.cs @@ -169,7 +169,7 @@ namespace FineUIPro.Web.HJGL.PointTrust var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId); string perfix = string.Empty; - perfix = unit.UnitCode + "-" + ndt.DetectionTypeCode + "-" + rate.DetectionRateValue.ToString() + "%-"; + perfix = BLL.Batch_BatchTrustService.BuildTrustBatchCodePrefix(unit.UnitCode, ndt.DetectionTypeCode, rate.DetectionRateValue.ToString(), DateTime.Now); newBatchTrust.TrustBatchCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HJGL_Batch_BatchTrust", "TrustBatchCode", project.ProjectId, perfix); string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust)); @@ -239,4 +239,4 @@ namespace FineUIPro.Web.HJGL.PointTrust #endregion } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/PointTrust/PointTrust.aspx.cs b/SGGL/FineUIPro.Web/HJGL/PointTrust/PointTrust.aspx.cs index 0d01ceb1..298003a0 100644 --- a/SGGL/FineUIPro.Web/HJGL/PointTrust/PointTrust.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/PointTrust/PointTrust.aspx.cs @@ -55,7 +55,7 @@ namespace FineUIPro.Web.HJGL.PointTrust var unitWork = BLL.UnitWorkService.GetUnitWorkByUnitWorkId(batch.UnitWorkId); var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(batch.DetectionTypeId); var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId); - this.txtTrustBatchCode.Text = batch.PointBatchCode.Replace("-DK-", "-WT-"); + this.txtTrustBatchCode.Text = BLL.Batch_BatchTrustService.BuildTrustBatchCode(batch.PointBatchCode, DateTime.Now); if (unit != null) { this.txtUnit.Text = unit.UnitName; @@ -240,4 +240,4 @@ namespace FineUIPro.Web.HJGL.PointTrust } #endregion } -} \ No newline at end of file +}