From 010cf55e6cde8eb1542f3c9f8649e51b9409b863 Mon Sep 17 00:00:00 2001 From: fei550 <1420031550@qq.com> Date: Tue, 1 Dec 2026 09:34:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(hjgl):=20=E5=AE=8C=E5=96=84=E7=84=8A?= =?UTF-8?q?=E6=8E=A5=E4=BB=BB=E5=8A=A1=E5=92=8C=E7=AE=A1=E7=BA=BF=E7=BB=B4?= =?UTF-8?q?=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 支持删除符合条件的任务明细并完善任务编辑,同时维护管线防腐等级。 --- .../BLL/HJGL/WeldingManage/WeldTaskService.cs | 23 ++-- .../HJGL/InfoQuery/JointQuery.aspx.cs | 1 + .../HJGL/WeldingManage/PipelineEdit.aspx | 9 +- .../HJGL/WeldingManage/PipelineEdit.aspx.cs | 11 +- .../PipelineEdit.aspx.designer.cs | 9 ++ .../HJGL/WeldingManage/WeldTask.aspx | 2 +- .../HJGL/WeldingManage/WeldTask.aspx.cs | 120 ++++++++++-------- 7 files changed, 106 insertions(+), 69 deletions(-) diff --git a/SGGL/BLL/HJGL/WeldingManage/WeldTaskService.cs b/SGGL/BLL/HJGL/WeldingManage/WeldTaskService.cs index a0594850..4d07cc78 100644 --- a/SGGL/BLL/HJGL/WeldingManage/WeldTaskService.cs +++ b/SGGL/BLL/HJGL/WeldingManage/WeldTaskService.cs @@ -150,7 +150,9 @@ namespace BLL public static List GetWeldingTaskList(string ProjectId, string UnitWorkId, string unitId, DateTime taskDate, string canWelder, string serialNumber) { + // 任务视图保留已失去焊口关联的明细,任务列表和打印只取仍有焊口的明细。 var q = from x in Funs.DB.View_HJGL_WeldingTask + join joint in Funs.DB.HJGL_WeldJoint on x.WeldJointId equals joint.WeldJointId where x.ProjectId == ProjectId && x.UnitWorkId == UnitWorkId && x.TaskDate.Value.Date == taskDate.Date select x; @@ -513,18 +515,19 @@ namespace BLL //} /// - /// 根据Id删除一个焊接任务单明细信息 + /// 仅删除当前项目中关联焊口未生成焊接日报的任务明细。 /// - /// - public static void DeleteWeldingTask(string WeldTaskId) + public static bool DeleteWeldingTask(string projectId, string weldTaskId) { - Model.SGGLDB db = Funs.DB; - Model.HJGL_WeldTask delWeldTask = db.HJGL_WeldTask.FirstOrDefault(e => e.WeldTaskId == WeldTaskId); - if (delWeldTask != null) - { - db.HJGL_WeldTask.DeleteOnSubmit(delWeldTask); - db.SubmitChanges(); - } + // 删除时锁定关联焊口,避免校验后日报状态发生变化。 + return Funs.DB.ExecuteQuery(@" +DELETE task +FROM dbo.HJGL_WeldTask AS task +INNER JOIN dbo.HJGL_WeldJoint AS joint WITH (UPDLOCK, HOLDLOCK) + ON joint.WeldJointId = task.WeldJointId +WHERE task.ProjectId = {0} AND task.WeldTaskId = {1} + AND (joint.WeldingDailyId IS NULL OR DATALENGTH(joint.WeldingDailyId) = 0); +SELECT @@ROWCOUNT;", projectId, weldTaskId).Single() == 1; } } } diff --git a/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs b/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs index cd2a82ba..605f27cd 100644 --- a/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/InfoQuery/JointQuery.aspx.cs @@ -761,6 +761,7 @@ namespace FineUIPro.Web.HJGL.InfoQuery System.Web.HttpContext.Current.Response.AddHeader("Content-Length", info.Length.ToString()); System.Web.HttpContext.Current.Response.TransmitFile(path, 0, info.Length); System.Web.HttpContext.Current.Response.Flush(); + System.Web.HttpContext.Current.Response.SuppressContent = true; File.Delete(path); System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest(); } diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx index 3c568d8b..7a3962a2 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx @@ -121,7 +121,14 @@ - + + + + + + + diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.cs index 7a1eb485..4e5673ce 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.cs @@ -1,5 +1,6 @@ using BLL; using System; +using System.Linq; namespace FineUIPro.Web.HJGL.WeldingManage { @@ -79,6 +80,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage if (!IsPostBack) { this.PipelineId = Request.Params["PipelineId"]; + string paintId = null; Base_MediumService.InitMediumDropDownList(this.drpMedium, this.CurrUser.LoginProjectId, true); @@ -104,6 +106,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage Model.View_HJGL_Pipeline pipeline = BLL.PipelineService.GetViewPipelineByPipelineId(this.PipelineId); + paintId = pipeline.PaintId; BLL.UnitService.InitUnitDropDownListByUnitIds(this.drpUnit, UnitWorkService.getUnitWorkByUnitWorkId(pipeline.UnitWorkId).UnitId, true);//单位 this.ProjectId = pipeline.ProjectId; this.UnitId = pipeline.UnitId; @@ -195,6 +198,11 @@ namespace FineUIPro.Web.HJGL.WeldingManage } } + + drpPaintId.DataSource = PaintCodeDictService.GetList(null).Where(paint => paint.IsUsed || paint.Id == paintId).ToList(); + drpPaintId.DataBind(); + Funs.FineUIPleaseSelect(drpPaintId, UiText.Message("请选择")); + drpPaintId.SelectedValue = paintId ?? Const._Null; } } #endregion @@ -332,6 +340,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage { pipeline.MaterialId = this.drpMaterial.SelectedValue; } + pipeline.PaintId = drpPaintId.SelectedValue == Const._Null ? null : drpPaintId.SelectedValue; pipeline.Remark = this.txtRemark.Text.Trim(); if (!string.IsNullOrEmpty(this.PipelineId)) { @@ -357,4 +366,4 @@ namespace FineUIPro.Web.HJGL.WeldingManage } -} \ No newline at end of file +} diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.designer.cs index 8cd36f6a..dd3c560b 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/PipelineEdit.aspx.designer.cs @@ -257,6 +257,15 @@ namespace FineUIPro.Web.HJGL.WeldingManage /// protected global::FineUIPro.DropDownList drpMaterial; + /// + /// drpPaintId 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpPaintId; + /// /// txtRemark 控件。 /// diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx index ac2b6140..176e2913 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx @@ -287,7 +287,7 @@ diff --git a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs index a672a710..17947ade 100644 --- a/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/WeldingManage/WeldTask.aspx.cs @@ -3,6 +3,7 @@ using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; +using System.Globalization; using System.IO; using System.Linq; using System.Web.UI.WebControls; @@ -133,6 +134,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage foreach (var q in unitWork1) { var a = (from x in Funs.DB.HJGL_WeldTask + join joint in Funs.DB.HJGL_WeldJoint on x.WeldJointId equals joint.WeldJointId where x.UnitWorkId == q.UnitWorkId && x.TaskDate < Convert.ToDateTime(this.txtTaskDateMonth.Text.Trim() + "-01").AddMonths(1) && x.TaskDate >= Convert.ToDateTime(this.txtTaskDateMonth.Text.Trim() + "-01") @@ -170,6 +172,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage if (!hasWeldJointCode && !hasPipelineCode) { var a = (from x in Funs.DB.HJGL_WeldTask + join joint in Funs.DB.HJGL_WeldJoint on x.WeldJointId equals joint.WeldJointId where x.UnitWorkId == q.UnitWorkId && x.TaskDate < Convert.ToDateTime(this.txtTaskDateMonth.Text.Trim() + "-01").AddMonths(1) && x.TaskDate >= Convert.ToDateTime(this.txtTaskDateMonth.Text.Trim() + "-01") @@ -245,6 +248,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage if (!hasWeldJointCode && !hasPipelineCode) { var p = (from x in Funs.DB.HJGL_WeldTask + join joint in Funs.DB.HJGL_WeldJoint on x.WeldJointId equals joint.WeldJointId where x.UnitWorkId == node.NodeID && x.TaskDate < Convert.ToDateTime(this.txtTaskDateMonth.Text.Trim() + "-01").AddMonths(1) && x.TaskDate >= Convert.ToDateTime(this.txtTaskDateMonth.Text.Trim() + "-01") @@ -308,9 +312,10 @@ namespace FineUIPro.Web.HJGL.WeldingManage private void BindGrid(List weldingTask) { UpdateTotalSizeLabel(weldingTask); - if (!string.IsNullOrEmpty(this.txtPipelineCode.Text.Trim())) + var pipelineCode = this.txtPipelineCode.Text.Trim(); + if (pipelineCode.Length > 0) { - weldingTask = weldingTask.Where(e => e.PipelineCode.Contains(this.txtPipelineCode.Text.Trim())).ToList(); + weldingTask = weldingTask.Where(e => e.PipelineCode != null && e.PipelineCode.Contains(pipelineCode)).ToList(); } weldingTask = OrderWeldingTaskRows(weldingTask); DataTable tb = this.LINQToDataTable(weldingTask); @@ -326,7 +331,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage for (int i = 0; i < this.Grid1.Rows.Count; i++) { Model.HJGL_WeldTask task = BLL.WeldTaskService.GetWeldTaskById(this.Grid1.Rows[i].RowID); - if (task.IsSaved == true) + if (task == null || task.IsSaved == true) { this.Grid1.Rows[i].RowCssClass = "f-grid-cell-uneditable"; foreach (GridColumn column in Grid1.AllColumns) @@ -1006,21 +1011,13 @@ namespace FineUIPro.Web.HJGL.WeldingManage NewItem.WeldingWireCode = values.Value("WeldingWireCode").ToString(); } - if (!string.IsNullOrEmpty(values.Value("Size")) && !string.IsNullOrEmpty(values.Value("Size").ToString())) + NewItem.Size = ReadGridDecimal(values, "Size"); + NewItem.Dia = ReadGridDecimal(values, "Dia"); + NewItem.Thickness = ReadGridDecimal(values, "Thickness"); + int sortIndex; + if (int.TryParse(values.Value("PipeLineSortIndex"), NumberStyles.Integer, CultureInfo.InvariantCulture, out sortIndex)) { - NewItem.Size = values.Value("Size"); - } - if (!string.IsNullOrEmpty(values.Value("Dia")) && !string.IsNullOrEmpty(values.Value("Dia").ToString())) - { - NewItem.Dia = values.Value("Dia"); - } - if (!string.IsNullOrEmpty(values.Value("PipeLineSortIndex")) && !string.IsNullOrEmpty(values.Value("PipeLineSortIndex").ToString())) - { - NewItem.PipeLineSortIndex = values.Value("PipeLineSortIndex"); - } - if (!string.IsNullOrEmpty(values.Value("Thickness").ToString())) - { - NewItem.Thickness = values.Value("Thickness"); + NewItem.PipeLineSortIndex = sortIndex; } if (!string.IsNullOrEmpty(values.Value("WeldingMethodCode").ToString())) { @@ -1032,6 +1029,13 @@ namespace FineUIPro.Web.HJGL.WeldingManage } return getNewWeldTaskItem; } + + private static decimal? ReadGridDecimal(JObject values, string field) + { + decimal number; + return decimal.TryParse(values.Value(field), NumberStyles.Float, CultureInfo.InvariantCulture, out number) + ? number : (decimal?)null; + } #endregion protected void btnMenuAdd_Click(object sender, EventArgs e) @@ -1133,49 +1137,53 @@ namespace FineUIPro.Web.HJGL.WeldingManage #region 删除 protected void btnMenuDelete_Click(object sender, EventArgs e) { - if (CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_WeldTaskMenuId, Const.BtnDelete)) - { - if (Grid1.SelectedRowIndexArray.Length > 0) - { - List getNewWeldTaskItem = this.CollectGridJointInfo(); - foreach (int rowIndex in Grid1.SelectedRowIndexArray) - { - string rowID = Grid1.DataKeys[rowIndex][0].ToString(); - var item = getNewWeldTaskItem.FirstOrDefault(x => x.WeldTaskId == rowID); - var joint = Funs.DB.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == item.WeldJointId); - if (string.IsNullOrEmpty(joint.WeldingDailyId)) //焊口尚未焊接,任务单信息可以删除 - { - if (item != null) - { - getNewWeldTaskItem.Remove(item); - // 删除明细信息 - var task = Funs.DB.HJGL_WeldTask.FirstOrDefault(x => x.WeldTaskId == rowID); - if (task != null) - { - BLL.WeldTaskService.DeleteWeldingTask(task.WeldTaskId); - //PointBatchService.DeleteBatchByWeldJointId(task.WeldJointId); - } - } - ShowNotify("删除成功!", MessageBoxIcon.Success); - } - else - { - ShowNotify("该焊口焊接日报已生成,无法删除任务单信息!", MessageBoxIcon.Warning); - } - } - BindGrid(getNewWeldTaskItem); - if (getNewWeldTaskItem.Count == 0) //明细记录删除完,任务单即不存在 - { - this.InitTreeMenu();//加载树 - } - - } - } - else + if (!CommonService.GetAllButtonPowerList(CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_WeldTaskMenuId, Const.BtnDelete)) { ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning); return; } + + var selectedIds = (Grid1.SelectedRowIDArray ?? Array.Empty()).Distinct().ToArray(); + if (selectedIds.Length == 0) + { + ShowNotify("请选择要删除的记录", MessageBoxIcon.Warning); + return; + } + + var currentTasks = GetCurrentTaskList(); + if (currentTasks == null) + { + ShowNotify("请选择任务单", MessageBoxIcon.Warning); + return; + } + + var currentIds = new HashSet(currentTasks.Select(task => task.WeldTaskId)); + currentIds.IntersectWith(Grid1.DataKeys.Select(keys => (string)keys[0])); + int deletedCount = 0; + foreach (string taskId in selectedIds) + { + if (currentIds.Contains(taskId) && BLL.WeldTaskService.DeleteWeldingTask(CurrUser.LoginProjectId, taskId)) + { + deletedCount++; + } + } + + var remainingTasks = GetCurrentTaskList(); + BindGrid(remainingTasks); + if (remainingTasks.Count == 0) + { + InitTreeMenu(); + } + + if (deletedCount == selectedIds.Length) + { + ShowNotify("删除成功!", MessageBoxIcon.Success); + } + else + { + ShowNotify(string.Format("已删除 {0} 条,未删除 {1} 条。请核对记录是否仍在当前列表、关联焊口是否存在及是否已生成焊接日报。", + deletedCount, selectedIds.Length - deletedCount), MessageBoxIcon.Warning); + } } #endregion