From 05a92b528ded916a8dea5031df65ee1973780338 Mon Sep 17 00:00:00 2001 From: wendy <408182087@qq.com> Date: Thu, 23 Oct 2025 16:35:37 +0800 Subject: [PATCH] =?UTF-8?q?20251023=20=E6=8E=92=E4=BA=A7=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../版本日志/SGGLDB_V2025-10-23-001-bwj.sql | 123 ++++++ .../ProductionSchedulingPlanService.cs | 32 +- .../PreDesign/ProductionSchedulingPlan.aspx | 53 ++- .../ProductionSchedulingPlan.aspx.cs | 369 ++++++++++++++++-- .../ProductionSchedulingPlan.aspx.designer.cs | 100 +++-- 5 files changed, 594 insertions(+), 83 deletions(-) create mode 100644 DataBase/版本日志/SGGLDB_V2025-10-23-001-bwj.sql diff --git a/DataBase/版本日志/SGGLDB_V2025-10-23-001-bwj.sql b/DataBase/版本日志/SGGLDB_V2025-10-23-001-bwj.sql new file mode 100644 index 00000000..35dcfa2d --- /dev/null +++ b/DataBase/版本日志/SGGLDB_V2025-10-23-001-bwj.sql @@ -0,0 +1,123 @@ +ALTER PROCEDURE [dbo].[Sp_HJGL_ProductionPlanStatistics] + @projectId nvarchar(50)=null +AS +BEGIN + SET NOCOUNT ON; -- + + -- ʹCTEԤȹ˺;ۺ + WITH PipelineFiltered AS ( + SELECT UnitWorkId, FlowingSection, PipelineId + FROM HJGL_Pipeline + WHERE PipeArea='1' + AND FlowingSection IS NOT NULL + AND FlowingSection != '' + AND (@projectId IS NULL OR UnitWorkId IN ( + SELECT UnitWorkId FROM WBS_UnitWork WHERE ProjectId = @projectId + )) + ), + + -- Ԥܴ + TotalDiaCTE AS ( + SELECT p.UnitWorkId, p.FlowingSection, SUM(wj.Size) as TotalDia + FROM HJGL_WeldJoint wj + INNER JOIN PipelineFiltered p ON p.PipelineId = wj.PipelineId + WHERE wj.JointAttribute='Ԥƿ' + GROUP BY p.UnitWorkId, p.FlowingSection + ), + + -- ɹ + CurrentDayCompletedCTE AS ( + SELECT p.UnitWorkId, p.FlowingSection, SUM(wj.Size) as CurrentDayCompletedDia + FROM HJGL_WeldJoint wj + INNER JOIN PipelineFiltered p ON p.PipelineId = wj.PipelineId + INNER JOIN HJGL_WeldingDaily wd ON wd.WeldingDailyId = wj.WeldingDailyId + WHERE wj.JointAttribute='Ԥƿ' + AND wj.WeldingDailyId IS NOT NULL + AND wd.WeldingDate >= CAST(GETDATE() AS DATE) -- ŻڱȽϣʹڷΧ + AND wd.WeldingDate < DATEADD(DAY, 1, CAST(GETDATE() AS DATE)) + GROUP BY p.UnitWorkId, p.FlowingSection + ), + + -- ۼ + TotalCompletedCTE AS ( + SELECT p.UnitWorkId, p.FlowingSection, SUM(wj.Size) as totalCompletedDia + FROM HJGL_WeldJoint wj + INNER JOIN PipelineFiltered p ON p.PipelineId = wj.PipelineId + WHERE wj.JointAttribute='Ԥƿ' + AND wj.WeldingDailyId IS NOT NULL + GROUP BY p.UnitWorkId, p.FlowingSection + ), + + -- ǰ + WelderCountCTE AS ( + SELECT p.UnitWorkId, p.FlowingSection, + COUNT(DISTINCT pp.PersonId) as WelderCount -- ʹDISTINCTظ + FROM Person_Persons pp + INNER JOIN HJGL_WeldJoint wj ON wj.BackingWelderId = pp.PersonId + INNER JOIN PipelineFiltered p ON p.PipelineId = wj.PipelineId + WHERE wj.JointAttribute='Ԥƿ' + AND wj.WeldingDailyId IS NOT NULL + GROUP BY p.UnitWorkId, p.FlowingSection + )--, + + ---- Ԥ + --WarningWelderCountCTE AS ( + -- SELECT p.UnitWorkId, p.FlowingSection, + -- COUNT(DISTINCT pp.PersonId) as WarningWelderCount + -- FROM Person_Persons pp + -- INNER JOIN HJGL_WeldJoint wj ON wj.BackingWelderId = pp.PersonId + -- INNER JOIN PipelineFiltered p ON p.PipelineId = wj.PipelineId + -- INNER JOIN Welder_WelderQualify wq ON wq.WelderId = pp.PersonId + -- WHERE wj.JointAttribute='Ԥƿ' + -- AND wj.WeldingDailyId IS NOT NULL + -- AND wq.LimitDate < GETDATE() -- ʸԤ + -- GROUP BY p.UnitWorkId, p.FlowingSection + --) + + SELECT DISTINCT + unitWork.UnitWorkId, + unitWork.UnitWorkCode, + unitWork.UnitWorkName, + unitWork.ProjectId, + pipeline.FlowingSection, + isnull(total.TotalDia,0) as TotalDia,--Ԥܴ + p.PlanStartDate,--ƻʼ + p.PlanEndDate,--ƻ + --(DATEDIFF(day, p.PlanStartDate, p.PlanEndDate) +1) as TotalDays,-- + --(case when p.PlanEndDate>= getdate() then (DATEDIFF(day, p.PlanStartDate, p.PlanEndDate)-(DATEDIFF(day,p.PlanStartDate,GETDATE()))) else '' end) as RemainingDays,--ʣ + --(case when DATEDIFF(day, p.PlanStartDate, p.PlanEndDate)>0 then cast(isnull(total.TotalDia,0)/DATEDIFF(day, p.PlanStartDate, p.PlanEndDate) as decimal(18,2)) else 0 end) as AvgDayCompleteDia, --ƽÿӦɹ + ISNULL(currentDay.CurrentDayCompletedDia,0) as CurrentDayCompletedDia, --ɹ + + --cast(case when (case when p.PlanEndDate>= getdate() then (DATEDIFF(day, p.PlanStartDate, p.PlanEndDate)-(DATEDIFF(day,p.PlanStartDate,GETDATE()))) else 0 end)>0 then + --(isnull(total.TotalDia,0)-isnull(totalCompleted.totalCompletedDia,0))/ (case when p.PlanEndDate>= getdate() then (DATEDIFF(day, p.PlanStartDate, p.PlanEndDate)-(DATEDIFF(day,p.PlanStartDate,GETDATE()))) else 0 end) else 0 end as decimal(18,2)) as NextDayComplete, --Ӧ + + isnull(totalCompleted.totalCompletedDia,0) as totalCompletedDia, --ۼ + cast(cast((case when isnull(total.TotalDia,0)>0 then + (isnull(totalCompleted.totalCompletedDia,0) / isnull(total.TotalDia,0)*100) else 0 end) as decimal(18,2)) as varchar(10))+'%' as CompletedRate, --ɰٷֱ + welder.WelderCount, --ǰ + --warningWelder.WarningWelderCount --Ԥ + (case when welder.WelderCount>0 then cast((ISNULL(currentDay.CurrentDayCompletedDia,0)/welder.WelderCount) as decimal(18,2)) else 0 end) as WarningWelderCount--չЧ + FROM WBS_UnitWork AS unitWork + INNER JOIN PipelineFiltered pipeline ON pipeline.UnitWorkId = unitWork.UnitWorkId -- ʹINNER JOINΪpipelineݱ + --LEFT JOIN HJGL_ProductionSchedulingPlan p ON p.PipelineId = unitWork.UnitWorkId AND p.FlowNum = pipeline.FlowingSection + --Ųƻ + left join (select min(PlanStartDate) as PlanStartDate,max(PlanEndDate) as PlanEndDate,PipelineId,FlowNum from HJGL_ProductionSchedulingPlan + group by PipelineId,FlowNum + ) as p on p.PipelineId=unitWork.UnitWorkId and p.FlowNum = pipeline.FlowingSection + + --Ԥܴ + LEFT JOIN TotalDiaCTE total ON total.UnitWorkId = unitWork.UnitWorkId AND total.FlowingSection = pipeline.FlowingSection + --ɹ + LEFT JOIN CurrentDayCompletedCTE currentDay ON currentDay.UnitWorkId = unitWork.UnitWorkId AND currentDay.FlowingSection = pipeline.FlowingSection + --ۼ + LEFT JOIN TotalCompletedCTE totalCompleted ON totalCompleted.UnitWorkId = unitWork.UnitWorkId AND totalCompleted.FlowingSection = pipeline.FlowingSection + --ǰ + LEFT JOIN WelderCountCTE welder ON welder.UnitWorkId = unitWork.UnitWorkId AND welder.FlowingSection = pipeline.FlowingSection + --Ԥ + --LEFT JOIN WarningWelderCountCTE warningWelder ON warningWelder.UnitWorkId = unitWork.UnitWorkId AND warningWelder.FlowingSection = pipeline.FlowingSection + WHERE (@projectId IS NULL OR unitWork.ProjectId = @projectId) + AND pipeline.FlowingSection IS NOT NULL +END +GO + + diff --git a/SGGL/BLL/HJGL/PreDesign/ProductionSchedulingPlanService.cs b/SGGL/BLL/HJGL/PreDesign/ProductionSchedulingPlanService.cs index e31fa98a..46eb918f 100644 --- a/SGGL/BLL/HJGL/PreDesign/ProductionSchedulingPlanService.cs +++ b/SGGL/BLL/HJGL/PreDesign/ProductionSchedulingPlanService.cs @@ -19,15 +19,41 @@ namespace BLL return Funs.DB.HJGL_ProductionSchedulingPlan.FirstOrDefault(e => e.ProductionSchedulingPlanId == productionSchedulingPlanId); } - + /// + /// 根据单位工程、流水段、材质、口径获取排产计划 + /// + /// + /// + /// + /// + /// + /// public static Model.HJGL_ProductionSchedulingPlan GetProductionSchedulingPlan(string loginProjectId, string flowingSection, string unitWorkId, string material, string caliber) { return Funs.DB.HJGL_ProductionSchedulingPlan.FirstOrDefault(e => e.ProjectId == loginProjectId && e.FlowNum == flowingSection && e.PipelineId == unitWorkId && e.Material == material && e.Caliber == caliber); } - public static List GetProductionSchedulingPlanByMaterialLists(string loginProjectId, string flowingSection, string unitWorkId, string material) + /// + /// 根据单位工程、流水段获取排产计划信息 + /// + /// + /// + /// + /// + public static List GetProductionSchedulingPlanByFlowingSection(string loginProjectId, string flowingSection, string unitWorkId) { - return (from x in Funs.DB.HJGL_ProductionSchedulingPlan where x.ProjectId == loginProjectId && x.FlowNum == flowingSection && x.PipelineId == unitWorkId && x.Material == material select x).ToList(); + return (from x in Funs.DB.HJGL_ProductionSchedulingPlan where x.ProjectId == loginProjectId && x.FlowNum == flowingSection && x.PipelineId == unitWorkId select x).ToList(); + } + + /// + /// 根据单位工程获取排产计划信息 + /// + /// + /// + /// + public static List GetProductionSchedulingPlanByUnitWorkId(string loginProjectId, string unitWorkId) + { + return (from x in Funs.DB.HJGL_ProductionSchedulingPlan where x.ProjectId == loginProjectId && x.PipelineId == unitWorkId select x).ToList(); } /// diff --git a/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx b/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx index 06f1bfd1..a26d1829 100644 --- a/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx +++ b/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx @@ -50,7 +50,7 @@ EnableCollapse="false" runat="server" BoxFlex="1" DataKeyNames="UnitWorkId,FlowingSection" AllowCellEditing="true" EnableColumnLines="true" ClicksToEdit="1" DataIDField="" AllowSorting="true" SortField="UnitWorkName,FlowingSection" SortDirection="ASC" - AllowPaging="true" IsDatabasePaging="true" PageSize="15" + AllowPaging="true" IsDatabasePaging="true" PageSize="10" OnSort="Grid2_Sort" OnPageIndexChange="Grid2_PageIndexChange" EnableTextSelection="True" Height="300px" OnRowDataBound="Grid2_RowDataBound"> - - - --%> + + + + + + <%-- - - --%> + + + + + + <%-- - + --%> + + + + + - - + --%> + + + + + @@ -107,8 +127,8 @@ DataField="WelderCount" FieldType="Int" HeaderTextAlign="Center" TextAlign="Left" Width="120px"> - @@ -135,8 +155,8 @@ EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="ProductionSchedulingPlanId" AllowCellEditing="true" EnableColumnLines="true" ClicksToEdit="1" DataIDField="ProductionSchedulingPlanId" AllowSorting="true" SortField="FlowNum,Material,Caliber" SortDirection="ASC" OnSort="Grid1_Sort" - AllowPaging="true" IsDatabasePaging="true" PageSize="15" OnPageIndexChange="Grid1_PageIndexChange" - EnableTextSelection="True" OnRowDataBound="Grid1_RowDataBound" > + AllowPaging="true" IsDatabasePaging="true" PageSize="10" OnPageIndexChange="Grid1_PageIndexChange" + EnableTextSelection="True" OnRowDataBound="Grid1_RowDataBound"> @@ -304,12 +324,12 @@ const daysDifference = timeDifference / (1000 * 60 * 60 * 24); //平均每日应完成量=达因数/天数 const avgDailyWorkload = dain / (daysDifference + 1); - + const currentTime = Math.abs(endDate - Date.now());//获取剩余天数(毫秒) const daysTime = Math.ceil(currentTime / (1000 * 60 * 60 * 24));//将时间差转换为天数 if (daysTime > 0) { - //次日应完成量=剩余工程量(达因数-累计已完成量)/剩余天数(结束时间-当前时间) + //次日应完成量=剩余工程量(达因数-累计已完成量)/剩余天数(结束时间-当前时间) var nextDayCompleteDyne = (dain - completedCount) / daysTime; } @@ -317,9 +337,6 @@ me.updateCellValue(rowId, 'AvgDailyWorkload', avgDailyWorkload.toFixed(2));//平均每天工作量 me.updateCellValue(rowId, 'NextDayCompleteDyne', nextDayCompleteDyne.toFixed(2));//次日应完成量 } - - - } diff --git a/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.cs b/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.cs index 76ece3d7..a25b86cc 100644 --- a/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.cs +++ b/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.cs @@ -7,6 +7,7 @@ using System.Data; using System.Data.SqlClient; using System.IO; using System.Linq; +using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.HJGL.PreDesign { @@ -199,7 +200,6 @@ namespace FineUIPro.Web.HJGL.PreDesign e.Node.Nodes.Clear(); BindNodes(e.Node); } - } #endregion @@ -211,6 +211,153 @@ namespace FineUIPro.Web.HJGL.PreDesign /// protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e) { + #region 实时统计生产看板数据 + string projectId = this.CurrUser.LoginProjectId; + string steelType = string.Empty;//材质id + //统计生产看板当日已完成量、次日应完成量、累计已完成量、已完成百分比、已完成百分比汇总 + if (tvControlItem.SelectedNode.CommandName == "流水段")//点击流水段 + { + var planLists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByFlowingSection(projectId, tvControlItem.SelectedNode.Text, tvControlItem.SelectedNode.ParentNode.NodeID); + if (planLists.Count > 0) + { + foreach (var item in planLists) + { + var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanById(item.ProductionSchedulingPlanId); + if (plan != null) + { + if (plan.Material == "碳钢") + { + steelType = "1"; + } + else if (plan.Material == "不锈钢") + { + steelType = "2"; + } + else if (plan.Material == "铬钼钢") + { + steelType = "3"; + } + else if (plan.Material == "低合金钢") + { + steelType = "4"; + } + else if (plan.Material == "镍合金钢") + { + steelType = "5"; + } + else if (plan.Material == "钛合金钢") + { + steelType = "6"; + } + else if (plan.Material == "其他") + { + steelType = "7"; + } + //当日已完成量 + var currentDay = BLL.WeldJointService.GetCurrentDaySizeSum(projectId, plan.PipelineId, plan.FlowNum, steelType, plan.Caliber); + if (currentDay != null) + { + plan.OnDayCompleteDyne = currentDay; + } + else + { + plan.OnDayCompleteDyne = 0; + } + plan.CompletedCount = BLL.WeldJointService.GetSizeSum(projectId, plan.PipelineId, plan.FlowNum, steelType, plan.Caliber, "2");//累计已完成量 + if (plan.Dain > 0) + { + plan.CompletedRate = (plan.CompletedCount / plan.Dain) * 100;//已完成百分比 + } + else + { + plan.CompletedRate = 0; + } + if (plan.PriorityTotalDyne > 0) + { + decimal? completeDinSum = BLL.WeldJointService.GetSizeSumByUnitWorkIdAndFlowingSection(projectId, plan.PipelineId, plan.FlowNum, "2");//完成总达因 + plan.TotalCompletedRate = (completeDinSum / plan.PriorityTotalDyne) * 100;//已完成百分比汇总 + } + else + { + plan.TotalCompletedRate = 0; + } + BLL.ProductionSchedulingPlanService.UpdateProductionSchedulingPlan(plan); + } + } + } + } + else if (tvControlItem.SelectedNode.CommandName.Split('|').Length == 2)//点击单位工程 + { + var planLists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByUnitWorkId(this.CurrUser.LoginProjectId, tvControlItem.SelectedNode.NodeID); + if (planLists.Count > 0) + { + foreach (var item in planLists) + { + var plan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanById(item.ProductionSchedulingPlanId); + if (plan != null) + { + if (plan.Material == "碳钢") + { + steelType = "1"; + } + else if (plan.Material == "不锈钢") + { + steelType = "2"; + } + else if (plan.Material == "铬钼钢") + { + steelType = "3"; + } + else if (plan.Material == "低合金钢") + { + steelType = "4"; + } + else if (plan.Material == "镍合金钢") + { + steelType = "5"; + } + else if (plan.Material == "钛合金钢") + { + steelType = "6"; + } + else if (plan.Material == "其他") + { + steelType = "7"; + } + //当日已完成量 + var currentDay = BLL.WeldJointService.GetCurrentDaySizeSum(projectId, plan.PipelineId, plan.FlowNum, steelType, plan.Caliber); + if (currentDay != null) + { + plan.OnDayCompleteDyne = currentDay; + } + else + { + plan.OnDayCompleteDyne = 0; + } + plan.CompletedCount = BLL.WeldJointService.GetSizeSum(projectId, plan.PipelineId, plan.FlowNum, steelType, plan.Caliber, "2");//累计已完成量 + if (plan.Dain > 0) + { + plan.CompletedRate = (plan.CompletedCount / plan.Dain) * 100;//已完成百分比 + } + else + { + plan.CompletedRate = 0; + } + if (plan.PriorityTotalDyne > 0) + { + decimal? completeDinSum = BLL.WeldJointService.GetSizeSumByUnitWorkIdAndFlowingSection(projectId, plan.PipelineId, plan.FlowNum, "2");//完成总达因 + plan.TotalCompletedRate = (completeDinSum / plan.PriorityTotalDyne) * 100;//已完成百分比汇总 + } + else + { + plan.TotalCompletedRate = 0; + } + BLL.ProductionSchedulingPlanService.UpdateProductionSchedulingPlan(plan); + } + } + } + } + #endregion this.BindGrid(); } @@ -597,34 +744,22 @@ namespace FineUIPro.Web.HJGL.PreDesign var newPlan = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanById(rowId); if (newPlan != null) { - if (!string.IsNullOrEmpty(values.Value("TotalPriority"))) - { - newPlan.TotalPriority = values.Value("TotalPriority"); - } - else + if (!string.IsNullOrEmpty(totalPriority)) { newPlan.TotalPriority = totalPriority; totalPriority = string.Empty; } + else + { + newPlan.TotalPriority = values.Value("TotalPriority"); + totalPriority = newPlan.TotalPriority; + } newPlan.PlanStartDate = Funs.GetNewDateTime(values.Value("PlanStartDate")); newPlan.PlanEndDate = Funs.GetNewDateTime(values.Value("PlanEndDate")); newPlan.Days = Funs.GetNewInt(values.Value("Days")); newPlan.AvgDailyWorkload = Funs.GetNewDecimal(values.Value("AvgDailyWorkload")); newPlan.NextDayCompleteDyne = Funs.GetNewDecimal(values.Value("NextDayCompleteDyne")); BLL.ProductionSchedulingPlanService.UpdateProductionSchedulingPlan(newPlan); - - //更新合并单元格的总达因(按材质)优先级 - if (!string.IsNullOrEmpty(newPlan.TotalPriority)) - { - var pLists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByMaterialLists(this.CurrUser.LoginProjectId, newPlan.FlowNum, newPlan.PipelineId, newPlan.Material); - foreach (var item in pLists) - { - if (string.IsNullOrEmpty(item.TotalPriority)) - { - totalPriority = newPlan.TotalPriority; - } - } - } } } ShowNotify("保存成功!", MessageBoxIcon.Success); @@ -932,16 +1067,24 @@ namespace FineUIPro.Web.HJGL.PreDesign #region 生产看板 protected void ddlPageSize2_SelectedIndexChanged(object sender, EventArgs e) + { + Grid2.PageSize = Convert.ToInt32(ddlPageSize2.SelectedValue); + this.BindGrid2(); + } + protected void Grid2_Sort(object sender, GridSortEventArgs e) { this.BindGrid2(); } + protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e) + { + this.BindGrid2(); + } /// /// 绑定数据 /// private void BindGrid2() { - List listStr = new List(); listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId)); @@ -961,17 +1104,22 @@ namespace FineUIPro.Web.HJGL.PreDesign /// protected void Grid2_RowDataBound(object sender, GridRowEventArgs e) { - DataRowView row = e.DataItem as DataRowView; + //DataRowView row = e.DataItem as DataRowView; double avgDailyWorkload = 0; double nextDayCompleteDyne = 0; - if (row["AvgDayCompleteDia"] != null && !string.IsNullOrEmpty(row["AvgDayCompleteDia"].ToString())) - { - avgDailyWorkload = Convert.ToDouble(row["AvgDayCompleteDia"]);//平均每日应完成工作量 - } - if (row["NextDayComplete"] != null && !string.IsNullOrEmpty(row["NextDayComplete"].ToString())) - { - nextDayCompleteDyne = Convert.ToDouble(row["NextDayComplete"]);//次日应完成量 - } + //if (row["AvgDayCompleteDia"] != null && !string.IsNullOrEmpty(row["AvgDayCompleteDia"].ToString())) + //{ + // avgDailyWorkload = Convert.ToDouble(row["AvgDayCompleteDia"]);//平均每日应完成工作量 + //} + //if (row["NextDayComplete"] != null && !string.IsNullOrEmpty(row["NextDayComplete"].ToString())) + //{ + // nextDayCompleteDyne = Convert.ToDouble(row["NextDayComplete"]);//次日应完成量 + //} + + //avgDailyWorkload=(e.RowID["lblAvgDayCompleteDia") as AspNet.Label).Text + + avgDailyWorkload = Convert.ToDouble((e.Row.FindControl("lblAvgDayCompleteDia") as AspNet.Label).Text);//平均每日应完成工作量 + nextDayCompleteDyne = Convert.ToDouble((e.Row.FindControl("lblNextDayComplete") as AspNet.Label).Text); //次日应完成量(平均) if (avgDailyWorkload < nextDayCompleteDyne) { e.RowCssClass = "color1"; @@ -979,5 +1127,168 @@ namespace FineUIPro.Web.HJGL.PreDesign } #endregion + #region 格式化字符串 + /// + /// 获取有效总天数 + /// + /// + /// + /// + /// + public static int getTotalDays(string projectId, string unitWorkId, string flowNum) + { + var lists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByFlowingSection(projectId, flowNum, unitWorkId); + List<(DateTime, DateTime)> combinedList = new List<(DateTime, DateTime)>(); + foreach (var item in lists) + { + if (item.PlanStartDate.HasValue && item.PlanEndDate.HasValue) + { + var dateRanges = new List<(DateTime, DateTime)> + { + (new DateTime(item.PlanStartDate.Value.Year, item.PlanStartDate.Value.Month, item.PlanStartDate.Value.Day), new DateTime(item.PlanEndDate.Value.Year, item.PlanEndDate.Value.Month, item.PlanEndDate.Value.Day)), + }; + combinedList.AddRange(dateRanges); + } + } + return GetEffectiveDaysLinq(combinedList); + } + + /// + /// 获取剩余天数 + /// + /// + /// + /// + /// + public static int getRemainingDays(string projectId, string unitWorkId, string flowNum) + { + var lists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByFlowingSection(projectId, flowNum, unitWorkId); + List<(DateTime, DateTime)> combinedList = new List<(DateTime, DateTime)>(); + foreach (var item in lists) + { + if (item.PlanStartDate.HasValue && item.PlanEndDate.HasValue) + { + if (item.PlanEndDate > DateTime.Now) + { + var dateRanges = new List<(DateTime, DateTime)> + { + (new DateTime(item.PlanStartDate.Value.Year, item.PlanStartDate.Value.Month, item.PlanStartDate.Value.Day), new DateTime(item.PlanEndDate.Value.Year, item.PlanEndDate.Value.Month, item.PlanEndDate.Value.Day)), + }; + combinedList.AddRange(dateRanges); + } + } + } + return GetEffectiveDaysLinq(combinedList); + } + + /// + /// 获取平均每日应完成工作量 + /// + /// + /// + /// + /// + public static double getAvgDayCompleteDia(string projectId, string unitWorkId, string flowNum) + { + double AvgDayCompleteDia = 0; + int totalDays = 0; + var lists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByFlowingSection(projectId, flowNum, unitWorkId); + List<(DateTime, DateTime)> combinedList = new List<(DateTime, DateTime)>(); + foreach (var item in lists) + { + if (item.PlanStartDate.HasValue && item.PlanEndDate.HasValue) + { + var dateRanges = new List<(DateTime, DateTime)> + { + (new DateTime(item.PlanStartDate.Value.Year, item.PlanStartDate.Value.Month, item.PlanStartDate.Value.Day), new DateTime(item.PlanEndDate.Value.Year, item.PlanEndDate.Value.Month, item.PlanEndDate.Value.Day)), + }; + combinedList.AddRange(dateRanges); + } + } + totalDays = GetEffectiveDaysLinq(combinedList); + + ///总达因 + decimal? dia = (from x in Funs.DB.HJGL_WeldJoint + join y in Funs.DB.HJGL_Pipeline on x.PipelineId equals y.PipelineId + where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowNum + && x.JointAttribute == "预制口" + select x.Size).Sum(); + if (totalDays > 0) + { + //平均每日应完成工作量=总达因/有效总天数 + AvgDayCompleteDia = Math.Round(Convert.ToDouble(dia / totalDays), 2); + } + return AvgDayCompleteDia; + } + + /// + /// 获取次日应完成量(平均) + /// + /// + /// + /// + /// + public static double getNextDayComplete(string projectId, string unitWorkId, string flowNum) + { + double nextDayComplete = 0; + int remainingDays = 0; + var lists = BLL.ProductionSchedulingPlanService.GetProductionSchedulingPlanByFlowingSection(projectId, flowNum, unitWorkId); + List<(DateTime, DateTime)> combinedList = new List<(DateTime, DateTime)>(); + foreach (var item in lists) + { + if (item.PlanStartDate.HasValue && item.PlanEndDate.HasValue) + { + if (item.PlanEndDate > DateTime.Now) + { + var dateRanges = new List<(DateTime, DateTime)> + { + (new DateTime(item.PlanStartDate.Value.Year, item.PlanStartDate.Value.Month, item.PlanStartDate.Value.Day), new DateTime(item.PlanEndDate.Value.Year, item.PlanEndDate.Value.Month, item.PlanEndDate.Value.Day)), + }; + combinedList.AddRange(dateRanges); + } + } + } + remainingDays = GetEffectiveDaysLinq(combinedList); + + ///总达因 + decimal? totalDia = (from x in Funs.DB.HJGL_WeldJoint + join y in Funs.DB.HJGL_Pipeline on x.PipelineId equals y.PipelineId + where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowNum + && x.JointAttribute == "预制口" + select x.Size).Sum(); + //完成达因 + decimal? completedDia = (from x in Funs.DB.HJGL_WeldJoint + join y in Funs.DB.HJGL_Pipeline on x.PipelineId equals y.PipelineId + where x.ProjectId == projectId && y.UnitWorkId == unitWorkId && y.FlowingSection == flowNum + && x.JointAttribute == "预制口" && x.WeldingDailyId != null && x.WeldingDailyId != "" + select x.Size).Sum(); + if (remainingDays > 0) + { + //次日应完成量(平均)=(总达因-完成达因)/剩余天数 + nextDayComplete = Math.Round(Convert.ToDouble((totalDia - completedDia) / remainingDays), 2); + } + return nextDayComplete; + } + + /// + /// 生成所有日期并去重 + /// + /// + /// + public static int GetEffectiveDaysLinq(List<(DateTime start, DateTime end)> dateRanges) + { + if (dateRanges == null || !dateRanges.Any()) + return 0; + + // 生成所有日期并去重 + var allDates = dateRanges + .SelectMany(range => + Enumerable.Range(0, (range.end - range.start).Days + 1) + .Select(offset => range.start.AddDays(offset).Date)) + .Distinct(); + + return allDates.Count(); + } + #endregion } } \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.designer.cs b/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.designer.cs index 9747bfd8..4a3e9c68 100644 --- a/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.designer.cs +++ b/SGGL/FineUIPro.Web/HJGL/PreDesign/ProductionSchedulingPlan.aspx.designer.cs @@ -7,13 +7,11 @@ // //------------------------------------------------------------------------------ -namespace FineUIPro.Web.HJGL.PreDesign -{ - - - public partial class ProductionSchedulingPlan - { - +namespace FineUIPro.Web.HJGL.PreDesign { + + + public partial class ProductionSchedulingPlan { + /// /// form1 控件。 /// @@ -22,7 +20,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; - + /// /// PageManager1 控件。 /// @@ -31,7 +29,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.PageManager PageManager1; - + /// /// Panel1 控件。 /// @@ -40,7 +38,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel Panel1; - + /// /// panelLeftRegion 控件。 /// @@ -49,7 +47,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel panelLeftRegion; - + /// /// txtSize 控件。 /// @@ -58,7 +56,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.NumberBox txtSize; - + /// /// btnStatics 控件。 /// @@ -67,7 +65,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button btnStatics; - + /// /// hdUnitWorkId 控件。 /// @@ -76,7 +74,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.HiddenField hdUnitWorkId; - + /// /// tvControlItem 控件。 /// @@ -85,7 +83,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Tree tvControlItem; - + /// /// panelCenterRegion 控件。 /// @@ -94,7 +92,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel panelCenterRegion; - + /// /// panelCenterTop 控件。 /// @@ -103,7 +101,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel panelCenterTop; - + /// /// Grid2 控件。 /// @@ -112,7 +110,43 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid Grid2; - + + /// + /// lblTotalDay 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblTotalDay; + + /// + /// lblRemainingDays 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblRemainingDays; + + /// + /// lblAvgDayCompleteDia 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblAvgDayCompleteDia; + + /// + /// lblNextDayComplete 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.WebControls.Label lblNextDayComplete; + /// /// ToolbarSeparator2 控件。 /// @@ -121,7 +155,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarSeparator ToolbarSeparator2; - + /// /// ToolbarText2 控件。 /// @@ -130,7 +164,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarText ToolbarText2; - + /// /// ddlPageSize2 控件。 /// @@ -139,7 +173,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList ddlPageSize2; - + /// /// Grid1 控件。 /// @@ -148,7 +182,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid Grid1; - + /// /// Toolbar3 控件。 /// @@ -157,7 +191,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar Toolbar3; - + /// /// ToolbarFill1 控件。 /// @@ -166,7 +200,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarFill ToolbarFill1; - + /// /// btnSave 控件。 /// @@ -175,7 +209,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button btnSave; - + /// /// btnOut 控件。 /// @@ -184,7 +218,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button btnOut; - + /// /// txtTotalPriority 控件。 /// @@ -193,7 +227,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtTotalPriority; - + /// /// txtPlanStartDate 控件。 /// @@ -202,7 +236,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DatePicker txtPlanStartDate; - + /// /// txtPlanEndDate 控件。 /// @@ -211,7 +245,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DatePicker txtPlanEndDate; - + /// /// ToolbarSeparator1 控件。 /// @@ -220,7 +254,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1; - + /// /// ToolbarText1 控件。 /// @@ -229,7 +263,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.ToolbarText ToolbarText1; - + /// /// ddlPageSize 控件。 /// @@ -238,7 +272,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList ddlPageSize; - + /// /// Menu1 控件。 /// @@ -247,7 +281,7 @@ namespace FineUIPro.Web.HJGL.PreDesign /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Menu Menu1; - + /// /// btnMenuDelete 控件。 ///