From ce55496fc082eee010774973b325280f670c3afe Mon Sep 17 00:00:00 2001 From: geh <1923421292@qq.com> Date: Mon, 11 Aug 2025 14:21:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=BD=E5=B7=A5=E4=BA=BA=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SUBQHSE_V2025-08-04-geh(施工人力).sql | 112 ++ SGGL/BLL/BLL.csproj | 2 +- SGGL/BLL/Common/Const.cs | 7 + .../JDGL/SGManPower/ManPowerPlanService.cs | 104 ++ .../Excel/DataIn/施工人力计划导入模板.xls | Bin 0 -> 26112 bytes SGGL/FineUIPro.Web/FineUIPro.Web.csproj | 72 ++ .../JDGL/SGManPower/ManPowerPlan.aspx | 160 +++ .../JDGL/SGManPower/ManPowerPlan.aspx.cs | 346 ++++++ .../SGManPower/ManPowerPlan.aspx.designer.cs | 98 ++ .../JDGL/SGManPower/ManPowerPlanChart.aspx | 35 + .../JDGL/SGManPower/ManPowerPlanChart.aspx.cs | 191 +++ .../ManPowerPlanChart.aspx.designer.cs | 71 ++ .../JDGL/SGManPower/ManPowerPlanEdit.aspx | 77 ++ .../JDGL/SGManPower/ManPowerPlanEdit.aspx.cs | 130 ++ .../ManPowerPlanEdit.aspx.designer.cs | 134 +++ .../JDGL/SGManPower/ManPowerPlanGrid.aspx | 106 ++ .../JDGL/SGManPower/ManPowerPlanGrid.aspx.cs | 1054 +++++++++++++++++ .../ManPowerPlanGrid.aspx.designer.cs | 188 +++ .../JDGL/SGManPower/ManPowerPlanIn.aspx | 76 ++ .../JDGL/SGManPower/ManPowerPlanIn.aspx.cs | 640 ++++++++++ .../ManPowerPlanIn.aspx.designer.cs | 125 ++ .../JDGL/SGManPower/ManPowerStat.aspx | 720 +++++++++++ .../JDGL/SGManPower/ManPowerStat.aspx.cs | 377 ++++++ .../SGManPower/ManPowerStat.aspx.designer.cs | 26 + .../JDGL/SGManPower/ManPowerWork.aspx | 45 + .../JDGL/SGManPower/ManPowerWork.aspx.cs | 34 + .../SGManPower/ManPowerWork.aspx.designer.cs | 98 ++ .../JDGL/SGManPower/ManPowerWorkChart.aspx | 104 ++ .../JDGL/SGManPower/ManPowerWorkChart.aspx.cs | 136 +++ .../ManPowerWorkChart.aspx.designer.cs | 89 ++ .../JDGL/SGManPower/ManPowerWorkGrid.aspx | 95 ++ .../JDGL/SGManPower/ManPowerWorkGrid.aspx.cs | 741 ++++++++++++ .../ManPowerWorkGrid.aspx.designer.cs | 152 +++ SGGL/Model/Model.cs | 313 +++++ 34 files changed, 6657 insertions(+), 1 deletion(-) create mode 100644 DataBase/版本日志/SUBQHSE_V2025-08-04-geh(施工人力).sql create mode 100644 SGGL/BLL/JDGL/SGManPower/ManPowerPlanService.cs create mode 100644 SGGL/FineUIPro.Web/File/Excel/DataIn/施工人力计划导入模板.xls create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlan.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlan.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlan.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanChart.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanChart.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanChart.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanEdit.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanEdit.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanEdit.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanGrid.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanGrid.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanGrid.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanIn.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanIn.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerPlanIn.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.designer.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.cs create mode 100644 SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.designer.cs diff --git a/DataBase/版本日志/SUBQHSE_V2025-08-04-geh(施工人力).sql b/DataBase/版本日志/SUBQHSE_V2025-08-04-geh(施工人力).sql new file mode 100644 index 00000000..4c3e3f23 --- /dev/null +++ b/DataBase/版本日志/SUBQHSE_V2025-08-04-geh(施工人力).sql @@ -0,0 +1,112 @@ +INSERT INTO [dbo].[Sys_Menu] ([MenuId], [MenuName], [Icon], [Url], [SortIndex], [SuperMenu], [MenuType], [IsOffice], [IsEnd], [IsUsed]) VALUES (N'B1F87873-FEC8-4BEC-8AB6-AFDEDB26ECEE', N'现场考勤人力', NULL, N'JDGL/SGManPower/ManPowerWork.aspx', 20, N'1BCD283A-F33C-488C-8FCA-F7B7B9C1A003', N'Menu_JDGL', '0', '0', '1'); +INSERT INTO [dbo].[Sys_Menu] ([MenuId], [MenuName], [Icon], [Url], [SortIndex], [SuperMenu], [MenuType], [IsOffice], [IsEnd], [IsUsed]) VALUES (N'CE4D8228-3971-4F81-B992-5FC564CBFDA6', N'人力统计分析', NULL, N'JDGL/SGManPower/ManPowerStat.aspx', 30, N'1BCD283A-F33C-488C-8FCA-F7B7B9C1A003', N'Menu_JDGL', '0', '0', '1'); +INSERT INTO [dbo].[Sys_Menu] ([MenuId], [MenuName], [Icon], [Url], [SortIndex], [SuperMenu], [MenuType], [IsOffice], [IsEnd], [IsUsed]) VALUES (N'D87CD627-A18C-4C5D-962D-424E582F2379', N'施工人力计划', NULL, N'JDGL/SGManPower/ManPowerPlan.aspx', 10, N'1BCD283A-F33C-488C-8FCA-F7B7B9C1A003', N'Menu_JDGL', '0', '0', '1'); +go + +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'2DC82E2D-3578-445E-9AA2-11D65E3F8775', N'D87CD627-A18C-4C5D-962D-424E582F2379', N'删除', 3); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'856EA8BF-DE2D-4344-B265-780358C69F8D', N'D87CD627-A18C-4C5D-962D-424E582F2379', N'增加', 1); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'AC79636E-969A-42AB-82AC-19D3945EC703', N'D87CD627-A18C-4C5D-962D-424E582F2379', N'保存', 4); +INSERT INTO [dbo].[Sys_ButtonToMenu] ([ButtonToMenuId], [MenuId], [ButtonName], [SortIndex]) VALUES (N'FEDA3FD4-2436-460F-A75A-027D2D267CE4', N'D87CD627-A18C-4C5D-962D-424E582F2379', N'修改', 2); + +go + + + +--施工计划人力表 +CREATE TABLE [dbo].[JDGL_SGManPower] ( + [Id] nvarchar(50) COLLATE Chinese_PRC_CI_AS NOT NULL, + [ProjectId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, + [UnitId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, + [UnitWorkId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, + [WorkPostId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, + [Version] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, + [Quantity] int NULL, + [PlanDate] datetime NULL, + [CompileMan] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL, + [CompileTime] datetime NULL, + [Remarks] nvarchar(500) COLLATE Chinese_PRC_CI_AS NULL, + CONSTRAINT [PK_JDGL_SGManPower] PRIMARY KEY CLUSTERED ([Id]) +WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) +ON [PRIMARY] +) +ON [PRIMARY] +GO + +ALTER TABLE [dbo].[JDGL_SGManPower] SET (LOCK_ESCALATION = TABLE) +GO + +EXEC sp_addextendedproperty +'MS_Description', N'主健', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'Id' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'项目id', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'ProjectId' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'单位id', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'UnitId' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'装置id', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'UnitWorkId' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'岗位id', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'WorkPostId' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'版本', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'Version' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'数量', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'Quantity' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'日期', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'PlanDate' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'编制人', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'CompileMan' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'编制时间', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'CompileTime' +GO + +EXEC sp_addextendedproperty +'MS_Description', N'备注', +'SCHEMA', N'dbo', +'TABLE', N'JDGL_SGManPower', +'COLUMN', N'Remarks' \ No newline at end of file diff --git a/SGGL/BLL/BLL.csproj b/SGGL/BLL/BLL.csproj index 1cdc35b9..f2c35878 100644 --- a/SGGL/BLL/BLL.csproj +++ b/SGGL/BLL/BLL.csproj @@ -609,6 +609,7 @@ + @@ -1311,7 +1312,6 @@ 5.0.0 - + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + +
+
+
+ + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.cs new file mode 100644 index 00000000..22c84aed --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.cs @@ -0,0 +1,377 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web.Services; +using BLL; + +namespace FineUIPro.Web.JDGL.SGManPower +{ + public partial class ManPowerStat : PageBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + } + } + + #region Ajax方法 + + /// + /// 通过Ajax获取图表数据 + /// + /// 数据类型: total, annual, monthly + /// 图表标识: One, Two, Three, Four + /// 序列化的图表数据 + [WebMethod(EnableSession = true)] + public static string GetChartData(string type, string chart, string year = null, string month = null) + { + try + { + // 创建页面实例以访问非静态方法 + ManPowerStat pageInstance = new ManPowerStat(); + + string title = ""; + switch (chart) + { + case "One": + title = "五环管理人员统计分析"; + break; + case "Two": + title = "施工单位管理人员统计分析"; + break; + case "Three": + title = "作业人员统计分析"; + break; + case "Four": + title = "过程人力统计分析"; + break; + } + + string result = pageInstance.GetManpowerData(type, title, year, month); + return result; + } + catch (Exception ex) + { + // 记录异常日志 + throw new Exception("数据获取失败: " + ex.Message); + } + } + + #endregion + + #region 辅助方法 + + // ... existing code ... + /// + /// 获取人力统计数据 + /// + /// 筛选类型 + /// 图表标题 + /// 年份(可选) + /// 月份(可选) + /// BusinessColumn对象 + public string GetManpowerData(string filterType, string chartTitle, string year = null, string month = null) + { + try + { + List series = new List(); + Model.BusinessColumn businessColumn = new Model.BusinessColumn(); + List listCategories = new List(); + businessColumn.title = chartTitle; + businessColumn.xFontNum = 8; + + // 延迟执行查询,只获取需要的数据 + var actualBaseQuery = Funs.DB.T_d_EmployInOutRecord.Where(x => + x.ProjectId == this.CurrUser.LoginProjectId); + + var planBaseQuery = + Funs.DB.JDGL_SGManPower.Where(x => x.ProjectId == this.CurrUser.LoginProjectId); + + //var UnitType = string.Empty; //1:总包 2:分包 + // var PostType = string.Empty; //1:一般管理岗位 4:特种管理岗位 + var Units = (from x in Funs.DB.Project_ProjectUnit + join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId + where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == "2" + select x.UnitId).ToList(); + + var workPosts = (from x in Funs.DB.Base_WorkPost + where (x.PostType == "1" || x.PostType == "4") + select x.WorkPostId).ToList(); + + if (chartTitle == "五环管理人员统计分析") + { + actualBaseQuery = actualBaseQuery.Where(x => x.UnitId == Const.UnitId_CWCEC); + planBaseQuery = planBaseQuery.Where(x => x.UnitId == Const.UnitId_CWCEC); + } + else if (chartTitle == "施工单位管理人员统计分析") + { + actualBaseQuery = + actualBaseQuery.Where(x => Units.Contains(x.UnitId) && workPosts.Contains(x.PostId)); + planBaseQuery = + planBaseQuery.Where(x => Units.Contains(x.UnitId) && workPosts.Contains(x.WorkPostId)); + } + else if (chartTitle == "作业人员统计分析") + { + actualBaseQuery = + actualBaseQuery.Where(x => Units.Contains(x.UnitId) && !workPosts.Contains(x.PostId)); + planBaseQuery = + planBaseQuery.Where(x => Units.Contains(x.UnitId) && !workPosts.Contains(x.WorkPostId)); + } + else if (chartTitle == "过程人力统计分析") + { + } + + // 根据年份或月份筛选数据 + if (filterType == "annual" && !string.IsNullOrEmpty(year)) + { + int selectedYear = int.Parse(year); + actualBaseQuery = actualBaseQuery.Where(x => + x.RecordDate.HasValue && x.RecordDate.Value.Year == selectedYear); + planBaseQuery = + planBaseQuery.Where(x => x.PlanDate.HasValue && x.PlanDate.Value.Year == selectedYear); + } + else if (filterType == "monthly" && !string.IsNullOrEmpty(year) && !string.IsNullOrEmpty(month)) + { + int selectedYear = int.Parse(year); + int selectedMonth = int.Parse(month); + actualBaseQuery = actualBaseQuery.Where(x => x.RecordDate.HasValue && + x.RecordDate.Value.Year == selectedYear && + x.RecordDate.Value.Month == selectedMonth); + planBaseQuery = planBaseQuery.Where(x => x.PlanDate.HasValue && + x.PlanDate.Value.Year == selectedYear && + x.PlanDate.Value.Month == selectedMonth); + } + + // 根据筛选类型进行不同的分组统计 + Dictionary actualData; + Dictionary planData; + + switch (filterType) + { + case "annual": + // 按月分组(年度视图显示每个月的数据) + var actualAnnualQuery = from x in actualBaseQuery + where x.RecordDate.HasValue + group x by new { x.RecordDate.Value.Year, x.RecordDate.Value.Month } + into g + select new + { + Year = g.Key.Year, + Month = g.Key.Month, + ActualCount = g.Count() + }; + + var planAnnualQuery = from x in planBaseQuery + where x.PlanDate.HasValue + group x by new { x.PlanDate.Value.Year, x.PlanDate.Value.Month } + into g + select new + { + Year = g.Key.Year, + Month = g.Key.Month, + PlanCount = g.Sum(x => x.Quantity ?? 0) + }; + + actualData = actualAnnualQuery.ToDictionary( + x => new DateTime(x.Year, x.Month, 1), + x => (double)x.ActualCount); + + planData = planAnnualQuery.ToDictionary( + x => new DateTime(x.Year, x.Month, 1), + x => (double)x.PlanCount); + break; + + case "monthly": + // 按天分组(月度视图显示每天的数据) + var actualMonthlyQuery = from x in actualBaseQuery + where x.RecordDate.HasValue + group x by new { x.RecordDate.Value.Year, x.RecordDate.Value.Month, x.RecordDate.Value.Day } + into g + select new + { + Year = g.Key.Year, + Month = g.Key.Month, + Day = g.Key.Day, + ActualCount = g.Count() + }; + + var planMonthlyQuery = from x in planBaseQuery + where x.PlanDate.HasValue + group x by new { x.PlanDate.Value.Year, x.PlanDate.Value.Month, x.PlanDate.Value.Day } + into g + select new + { + Year = g.Key.Year, + Month = g.Key.Month, + Day = g.Key.Day, + PlanCount = g.Sum(x => x.Quantity ?? 0) + }; + + actualData = actualMonthlyQuery.ToDictionary( + x => new DateTime(x.Year, x.Month, x.Day), + x => (double)x.ActualCount); + + planData = planMonthlyQuery.ToDictionary( + x => new DateTime(x.Year, x.Month, x.Day), + x => (double)x.PlanCount); + break; + + case "total": + default: + // 按月分组(默认情况) + var actualDefaultQuery = from x in actualBaseQuery + where x.RecordDate.HasValue + group x by new { x.RecordDate.Value.Year, x.RecordDate.Value.Month } + into g + select new + { + Year = g.Key.Year, + Month = g.Key.Month, + ActualCount = g.Count() + }; + + var planDefaultQuery = from x in planBaseQuery + where x.PlanDate.HasValue + group x by new { x.PlanDate.Value.Year, x.PlanDate.Value.Month } + into g + select new + { + Year = g.Key.Year, + Month = g.Key.Month, + PlanCount = g.Sum(x => x.Quantity ?? 0) + }; + + actualData = actualDefaultQuery.ToDictionary( + x => new DateTime(x.Year, x.Month, 1), + x => (double)x.ActualCount); + + planData = planDefaultQuery.ToDictionary( + x => new DateTime(x.Year, x.Month, 1), + x => (double)x.PlanCount); + break; + } + + // 获取所有日期并排序 + var allDates = actualData.Keys.Union(planData.Keys).Distinct().OrderBy(d => d).ToList(); + + // 准备数据系列 + List actualSeries = + allDates.Select(date => actualData.ContainsKey(date) ? actualData[date] : 0).ToList(); + List planSeries = + allDates.Select(date => planData.ContainsKey(date) ? planData[date] : 0).ToList(); + + // 准备类别(横坐标) + switch (filterType) + { + case "annual": + // 显示选定年份的12个月份 + listCategories = allDates.Select(date => date.ToString("yyyy年MM月")).ToList(); + break; + case "monthly": + // 显示选定月份的每日数据 + listCategories = allDates.Select(date => date.ToString("MM月dd日")).ToList(); + break; + case "total": + default: + listCategories = allDates.Select(date => date.ToString("yyyy年MM月")).ToList(); + break; + } + + // 实际数据系列 + Model.SingleSerie actualSerie = new Model.SingleSerie + { + name = "实际", + data = actualSeries + }; + series.Add(actualSerie); + + // 计划数据系列 + Model.SingleSerie planSerie = new Model.SingleSerie + { + name = "计划", + data = planSeries + }; + series.Add(planSerie); + + businessColumn.categories = listCategories; + businessColumn.series = series; + return JsonConvert.SerializeObject(businessColumn); + } + catch (Exception ex) + { + // 记录异常日志 + // LogHelper.Error("获取人力统计数据失败", ex); + throw new Exception("数据获取失败: " + ex.Message); + } + } +// ... existing code ... + + #endregion + + #region 五环管理人员统计分析 + + /// + /// 五环管理人员统计分析 + /// + public string One + { + get + { + string dataType = Request.QueryString["type"] ?? "total"; + return GetManpowerData(dataType, "五环管理人员统计分析"); + } + } + + #endregion + + #region 施工单位管理人员统计分析 + + /// + /// 施工单位管理人员统计分析 + /// + public string Two + { + get + { + string dataType = Request.QueryString["type"] ?? "total"; + return GetManpowerData(dataType, "施工单位管理人员统计分析"); + } + } + + #endregion + + #region 作业人员统计分析 + + /// + /// 作业人员统计分析 + /// + public string Three + { + get + { + string dataType = Request.QueryString["type"] ?? "total"; + return GetManpowerData(dataType, "作业人员统计分析"); + } + } + + #endregion + + #region 过程人力统计分析 + + /// + /// 过程人力统计分析 + /// + public string Four + { + get + { + string dataType = Request.QueryString["type"] ?? "total"; + return GetManpowerData(dataType, "过程人力统计分析"); + } + } + + #endregion + } +} \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.designer.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.designer.cs new file mode 100644 index 00000000..23353898 --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerStat.aspx.designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.JDGL.SGManPower +{ + + + public partial class ManPowerStat + { + + /// + /// Head1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlHead Head1; + } +} diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx new file mode 100644 index 00000000..653dac6f --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx @@ -0,0 +1,45 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManPowerWork.aspx.cs" Inherits="FineUIPro.Web.JDGL.SGManPower.ManPowerWork" %> + + + + + + 现场人力考勤 + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.cs new file mode 100644 index 00000000..2d546e52 --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +namespace FineUIPro.Web.JDGL.SGManPower +{ + public partial class ManPowerWork : PageBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + BLL.UnitService.GetUnit(this.drpUnit, this.CurrUser.LoginProjectId, true);//单位 + this.txtStartTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-30)); + this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(30)); + DropMainContractCode_SelectedIndexChanged(null, null); + } + } + + + protected void DropMainContractCode_SelectedIndexChanged(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(drpUnit.SelectedValue)) + { + panelCenterRegion.IFrameUrl = "./ManPowerWorkGrid.aspx?UnitId=" + drpUnit.SelectedValue + + "&StartTime=" + this.txtStartTime.Text + "&EndTime=" + + this.txtEndTime.Text; + } + } + } +} \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.designer.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.designer.cs new file mode 100644 index 00000000..c7909ffd --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWork.aspx.designer.cs @@ -0,0 +1,98 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.JDGL.SGManPower +{ + + + public partial class ManPowerWork + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Panel3 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel Panel3; + + /// + /// panelCenterRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelCenterRegion; + + /// + /// Toolbar2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar2; + + /// + /// drpUnit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpUnit; + + /// + /// txtStartTime 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DatePicker txtStartTime; + + /// + /// txtEndTime 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DatePicker txtEndTime; + + /// + /// btnSubmit 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnSubmit; + } +} diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx new file mode 100644 index 00000000..f62accd2 --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx @@ -0,0 +1,104 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManPowerWorkChart.aspx.cs" Inherits="FineUIPro.Web.JDGL.SGManPower.ManPowerWorkChart" %> +<%@ Register Src="~/Controls/ChartControl.ascx" TagName="ChartControl" TagPrefix="uc1" %> + + + + + + 现场考勤人力图表 + + + + +
+ + + + + + +
← 左右滑动查看图表 →
+
+
+
+ <%--

总人力需求计划

--%> + +
+
+
+
+
+
+
+
+ + + + \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.cs new file mode 100644 index 00000000..5af304f4 --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using BLL; +using System.Data; +using System.Data.SqlClient; + +namespace FineUIPro.Web.JDGL.SGManPower +{ + public partial class ManPowerWorkChart : PageBase + { + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + // 初始化图表数据 + InitializeChartData(); + } + } + + private void InitializeChartData() + { + try + { + // 获取查询参数 + string unitId = Request.Params["UnitId"]; + string startTime = Request.Params["StartTime"]; + string endTime = Request.Params["EndTime"]; + string workPostId = Request.Params["WorkPostId"]; + + // 检查必要参数 + if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime)) + { + ShowNotify("缺少必要的参数,无法生成图表", MessageBoxIcon.Warning); + return; + } + + DateTime startDate = Convert.ToDateTime(startTime); + DateTime endDate = Convert.ToDateTime(endTime); + + // 使用原生SQL查询直接在数据库中进行聚合计算,提高性能 + string strSql = @" + SELECT + RecordDate, + COUNT(1) as TotalCount + FROM T_d_EmployInOutRecord + WHERE ProjectId = @ProjectId + AND RecordDate >= @StartDate + AND RecordDate <= @EndDate"; + + var parameters = new List + { + new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId), + new SqlParameter("@StartDate", startDate), + new SqlParameter("@EndDate", endDate) + }; + + // 添加单位筛选条件 + if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null) + { + strSql += " AND UnitId = @UnitId"; + parameters.Add(new SqlParameter("@UnitId", unitId)); + } + + // 添加岗位筛选条件 + if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null) + { + strSql += " AND PostId = @WorkPostId"; + parameters.Add(new SqlParameter("@WorkPostId", workPostId)); + } + + // 按日期分组并排序 + strSql += " GROUP BY RecordDate ORDER BY RecordDate"; + + // 执行查询 + var dt = SQLHelper.GetDataTableRunText(strSql, parameters.ToArray()); + + // 如果没有数据,显示提示信息 + if (dt.Rows.Count == 0) + { + ShowNotify("在指定时间范围内没有找到人力统计数据", MessageBoxIcon.Warning); + return; + } + + // 根据数据点数量动态调整图表宽度,确保每个数据点有足够的显示空间 + int chartWidth = Math.Max(1000, dt.Rows.Count * 50); // 每个数据点至少50像素宽,最小1000像素 + + // 创建图表数据对象 + Model.DataSourceChart dataSourceChart = new Model.DataSourceChart + { + Title = "现场考勤人力统计图表", + ChartType = System.Web.UI.DataVisualization.Charting.SeriesChartType.Column, + Width = chartWidth, + Height = 500, + IsNotEnable3D = false + }; + + // 创建数据系列 + Model.DataSourceTeam dataSourceTeam = new Model.DataSourceTeam + { + DataPointName = "人员数量", + DataSourcePoints = new List() + }; + + // 添加数据点 + foreach (DataRow row in dt.Rows) + { + if (row["RecordDate"] != DBNull.Value) + { + DateTime recordDate = Convert.ToDateTime(row["RecordDate"]); + int totalCount = Convert.ToInt32(row["TotalCount"]); + + Model.DataSourcePoint point = new Model.DataSourcePoint + { + PointText = recordDate.ToString("MM-dd"), + PointValue = totalCount.ToString() + }; + dataSourceTeam.DataSourcePoints.Add(point); + } + } + + dataSourceChart.DataSourceTeams = new List { dataSourceTeam }; + + // 生成图表 + Chart1.CreateChart(dataSourceChart); + } + catch (Exception ex) + { + ShowNotify($"生成图表时发生错误: {ex.Message}", MessageBoxIcon.Error); + } + } + } +} diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.designer.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.designer.cs new file mode 100644 index 00000000..4c46ad3d --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkChart.aspx.designer.cs @@ -0,0 +1,89 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.JDGL.SGManPower +{ + + + public partial class ManPowerWorkChart + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Panel1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel Panel1; + + /// + /// panelCenterRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelCenterRegion; + + /// + /// ContentPanel1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ContentPanel ContentPanel1; + + /// + /// scrollHint 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl scrollHint; + + /// + /// chartContainer 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlGenericControl chartContainer; + + /// + /// Chart1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::Web.Controls.ChartControl Chart1; + } +} diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx new file mode 100644 index 00000000..c3f47eee --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx @@ -0,0 +1,95 @@ +<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ManPowerWorkGrid.aspx.cs" Inherits="FineUIPro.Web.JDGL.SGManPower.ManPowerWorkGrid" %> + + + + + + + 施工人力计划 + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.cs new file mode 100644 index 00000000..49442c9d --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.cs @@ -0,0 +1,741 @@ +using BLL; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; + +namespace FineUIPro.Web.JDGL.SGManPower +{ + public partial class ManPowerWorkGrid : PageBase + { + #region Page_Init + + // 注意:动态创建的代码需要放置于Page_Init(不是Page_Load),这样每次构造页面时都会执行 + protected void Page_Init(object sender, EventArgs e) + { + InitGrid(); + } + + public DataTable GridTable = new DataTable(); + + private void InitGrid() + { + FineUIPro.BoundField bf; + FineUIPro.RenderField rf; + FineUIPro.TextBox txTextBox; + + // 设置Grid的编辑属性 + Grid1.AllowCellEditing = true; + Grid1.ClicksToEdit = 1; + Grid1.EnableAfterEditEvent = true; + + UnitId = Request.Params["UnitId"]; + StartTime = Request.Params["StartTime"]; + EndTime = Request.Params["EndTime"]; + + GridTable.Columns.Add("Id"); + + // 添加隐藏列来存储额外的ID信息 + GridTable.Columns.Add("UnitId"); + GridTable.Columns.Add("WorkPostId"); + + ListItem[] list = new ListItem[4]; + list[0] = new ListItem("序号", "SerialNumber"); + list[1] = new ListItem("单位", "UnitName"); + list[2] = new ListItem("岗位", "WorkPostName"); + list[3] = new ListItem("累计", "TotalCount"); + + foreach (var item in list) + { + bf = new FineUIPro.BoundField(); + bf.ColumnID = item.Value; + bf.DataField = item.Value; + bf.HeaderText = item.Text; + bf.HeaderTextAlign = TextAlign.Center; + bf.TextAlign = TextAlign.Center; + bf.Locked = true; + Grid1.Columns.Add(bf); + GridTable.Columns.Add(item.Value); + } + + // 动态获取日期范围 + DateTime startDate = Convert.ToDateTime(StartTime); + DateTime endDate = Convert.ToDateTime(EndTime); + var dateRange = Enumerable.Range(0, (endDate - startDate).Days + 1) + .Select(i => startDate.AddDays(i)) + .ToList(); + + // 按年分组日期 + var groupedByYear = dateRange.GroupBy(d => d.Year) + .OrderBy(g => g.Key) + .ToList(); + + foreach (var yearGroup in groupedByYear) + { + GroupField yearGroupField = new GroupField(); + yearGroupField.HeaderText = $"{yearGroup.Key}年"; + yearGroupField.TextAlign = TextAlign.Center; + + // 按月分组 + var groupedByMonth = yearGroup.GroupBy(d => d.Month) + .OrderBy(g => g.Key) + .ToList(); + + foreach (var monthGroup in groupedByMonth) + { + GroupField monthGroupField = new GroupField(); + monthGroupField.HeaderText = $"{monthGroup.Key}月"; + monthGroupField.TextAlign = TextAlign.Center; + + // 添加具体日期的列 + foreach (var date in monthGroup.OrderBy(d => d)) + { + bf = new FineUIPro.BoundField(); + bf.ColumnID = date.ToString("yyyy-MM-dd"); + bf.DataField = date.ToString("yyyy-MM-dd"); + bf.HeaderText = date.ToString("dd"); + bf.HeaderTextAlign = TextAlign.Center; + bf.TextAlign = TextAlign.Center; + monthGroupField.Columns.Add(bf); + GridTable.Columns.Add(date.ToString("yyyy-MM-dd")); + } + + yearGroupField.Columns.Add(monthGroupField); + } + + Grid1.Columns.Add(yearGroupField); + } + } + + #endregion + + public string UnitId + { + get => (string)ViewState["UnitId"]; + set => ViewState["UnitId"] = value; + } + + public string StartTime + { + get => (string)ViewState["StartTime"]; + set => ViewState["StartTime"] = value; + } + + public string EndTime + { + get => (string)ViewState["EndTime"]; + set => ViewState["EndTime"] = value; + } + + protected void Page_Load(object sender, EventArgs e) + { + if (!IsPostBack) + { + Funs.DropDownPageSize(this.ddlPageSize); + // 设置Grid的PageSize与下拉框默认值一致 + Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); + WorkPostService.InitWorkPostDropDownList(this.drpWorkPost, true); //岗位 + + // 绑定表格 + this.BindGrid(); + } + } + + + #region 绑定数据 + + /// + /// 绑定数据 + /// + private void BindGrid() + { + // 清空现有数据 + GridTable.Clear(); + // 重新添加列定义(保持列结构) + if (GridTable.Columns.Count == 0) + { + GridTable.Columns.Add("Id"); + GridTable.Columns.Add("UnitId"); + GridTable.Columns.Add("WorkPostId"); + + // 添加动态日期列(这部分已经在InitGrid中定义了) + ListItem[] list = new ListItem[4]; + list[0] = new ListItem("序号", "SerialNumber"); + list[1] = new ListItem("单位", "UnitName"); + list[2] = new ListItem("岗位", "WorkPostName"); + list[3] = new ListItem("累计", "TotalCount"); + foreach (var item in list) + { + GridTable.Columns.Add(item.Value); + } + + // 日期列会在InitGrid中添加,这里不需要重复添加 + } + else + { + // 清空行数据但保持列结构 + GridTable.Rows.Clear(); + } + + // 使用原生SQL查询来提高性能,直接在数据库层面进行分组统计 + string strSql = @" + SELECT UnitId, PostId, RecordDate, COUNT(1) as RecordCount + FROM T_d_EmployInOutRecord + WHERE ProjectId = @ProjectId + AND RecordDate >= @StartDate + AND RecordDate <= @EndDate"; + + var parameters = new List + { + new System.Data.SqlClient.SqlParameter("@ProjectId", this.CurrUser.LoginProjectId), + new System.Data.SqlClient.SqlParameter("@StartDate", Convert.ToDateTime(StartTime)), + new System.Data.SqlClient.SqlParameter("@EndDate", Convert.ToDateTime(EndTime)) + }; + + if (UnitId != Const._Null) + { + strSql += " AND UnitId = @UnitId"; + parameters.Add(new System.Data.SqlClient.SqlParameter("@UnitId", UnitId)); + } + + if (drpWorkPost.SelectedValue != Const._Null) + { + strSql += " AND PostId = @PostId"; + parameters.Add(new System.Data.SqlClient.SqlParameter("@PostId", drpWorkPost.SelectedValue)); + } + + strSql += " GROUP BY UnitId, PostId, RecordDate"; + + // 执行查询获取分组数据 + var dt = SQLHelper.GetDataTableRunText(strSql, parameters.ToArray()); + + // 将数据转换为更易处理的格式 + var groupedData = new List(); + var groupedDict = new Dictionary(); + + foreach (System.Data.DataRow row in dt.Rows) + { + string key = $"{row["UnitId"]}_{row["PostId"]}"; + DateTime recordDate = Convert.ToDateTime(row["RecordDate"]); + int count = Convert.ToInt32(row["RecordCount"]); + + if (!groupedDict.ContainsKey(key)) + { + dynamic group = new System.Dynamic.ExpandoObject(); + group.UnitId = row["UnitId"]; + group.PostId = row["PostId"]; + group.DailyCounts = new Dictionary(); + group.TotalCount = 0; + groupedDict[key] = group; + groupedData.Add(group); + } + + groupedDict[key].DailyCounts[recordDate] = count; + groupedDict[key].TotalCount += count; + } + + Grid1.RecordCount = groupedData.Count(); + + // 分页处理 + var pagedData = groupedData.Skip(Grid1.PageSize * Grid1.PageIndex).Take(Grid1.PageSize).ToList(); + + // 只获取当前页需要的单位和岗位信息,避免加载全部数据 + var unitIds = pagedData.Where(x => x.UnitId != null).Select(x => x.UnitId.ToString()).Distinct().ToList(); + var postIds = pagedData.Where(x => x.PostId != null).Select(x => x.PostId.ToString()).Distinct().ToList(); + + var units = new Dictionary(); + var workPosts = new Dictionary(); + + if (unitIds.Any()) + { + var unitQuery = from u in Funs.DB.Base_Unit + where unitIds.Contains(u.UnitId) + select new { u.UnitId, u.UnitName }; + foreach (var u in unitQuery) + { + units[u.UnitId] = u.UnitName; + } + } + + if (postIds.Any()) + { + var postQuery = from p in Funs.DB.Base_WorkPost + where postIds.Contains(p.WorkPostId) + select new { p.WorkPostId, p.WorkPostName }; + foreach (var p in postQuery) + { + workPosts[p.WorkPostId] = p.WorkPostName; + } + } + + foreach (var group in pagedData) + { + DataRow row = GridTable.NewRow(); + + // 基本信息 + row["Id"] = Guid.NewGuid().ToString(); // 生成唯一ID用于行标识 + row["SerialNumber"] = GridTable.Rows.Count + 1; // 序号 + + // 单位信息 + string unitName = ""; + if (group.UnitId != null && units.ContainsKey(group.UnitId.ToString())) + { + unitName = units[group.UnitId.ToString()]; + } + row["UnitName"] = unitName; + row["UnitId"] = group.UnitId ?? (object)DBNull.Value; + + // 岗位信息 + string workPostName = ""; + if (group.PostId != null && workPosts.ContainsKey(group.PostId.ToString())) + { + workPostName = workPosts[group.PostId.ToString()]; + } + row["WorkPostName"] = workPostName; + row["WorkPostId"] = group.PostId ?? (object)DBNull.Value; + + // 每日数量填充 + foreach (var kvp in group.DailyCounts) + { + string dateColumnId = kvp.Key.ToString("yyyy-MM-dd"); + + // 确保列存在 + if (GridTable.Columns.Contains(dateColumnId)) + { + row[dateColumnId] = kvp.Value; + } + } + + // 设置累计数量 + row["TotalCount"] = group.TotalCount; + + GridTable.Rows.Add(row); + } + + Grid1.DataSource = GridTable; + Grid1.DataBind(); + // 计算汇总数据 + OutputSummaryData(); + } + + #region 计算合计 + + /// + /// 计算合计 + /// + private void OutputSummaryData() + { + // 创建用于存储合计值的对象 + JObject summary = new JObject(); + + // 设置固定列的合计值 + summary.Add("UnitName", "合计"); + + // 计算TotalCount列的合计值 + int totalCountSum = 0; + foreach (DataRow row in GridTable.Rows) + { + if (row["TotalCount"] != DBNull.Value && row["TotalCount"] != null) + { + int value; + if (int.TryParse(row["TotalCount"].ToString(), out value)) + { + totalCountSum += value; + } + } + } + + summary.Add("TotalCount", totalCountSum.ToString()); + + // 计算日期列的合计值 + foreach (DataColumn column in GridTable.Columns) + { + // 检查是否为日期列(格式为 yyyy-MM-dd) + DateTime date; + if (DateTime.TryParseExact(column.ColumnName, "yyyy-MM-dd", null, + System.Globalization.DateTimeStyles.None, out date)) + { + // 计算该列的合计值 + int columnSum = 0; + foreach (DataRow row in GridTable.Rows) + { + if (row[column.ColumnName] != DBNull.Value && row[column.ColumnName] != null) + { + int value; + if (int.TryParse(row[column.ColumnName].ToString(), out value)) + { + columnSum += value; + } + } + } + + summary.Add(column.ColumnName, columnSum.ToString()); + } + } + + // 设置汇总数据 + Grid1.SummaryData = summary; + } + + #endregion + + #endregion + + #region GV 数据操作 + + /// + /// 分页 + /// + /// + /// + protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e) + { + this.Grid1.PageIndex = e.NewPageIndex; + this.BindGrid(); + } + + /// + /// 排序 + /// + /// + /// + protected void Grid1_Sort(object sender, GridSortEventArgs e) + { + this.Grid1.SortDirection = e.SortDirection; + this.Grid1.SortField = e.SortField; + this.BindGrid(); + } + + /// + /// 分页显示条数下拉框 + /// + /// + /// + protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e) + { + Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue); + this.BindGrid(); + } + + #endregion + + #region 数据查询 + + /// + /// 查询 + /// + /// + /// + protected void btnQuery_OnClick(object sender, EventArgs e) + { + BindGrid(); + } + + /// + /// 统计图表 + /// + /// + /// + protected void btnGetChart_Click(object sender, EventArgs e) + { + if (!string.IsNullOrEmpty(UnitId) && !string.IsNullOrEmpty(StartTime) && !string.IsNullOrEmpty(EndTime)) + { + // 构建基础URL参数 + string urlParams = string.Format("UnitId={0}&StartTime={1}&EndTime={2}", UnitId, StartTime, EndTime); + + // 添加岗位参数(如果已选择) + if (drpWorkPost.SelectedValue != Const._Null && !string.IsNullOrEmpty(drpWorkPost.SelectedValue)) + { + urlParams += "&WorkPostId=" + drpWorkPost.SelectedValue; + } + + PageContext.RegisterStartupScript( + Window2.GetShowReference(string.Format("ManPowerWorkChart.aspx?{0}", urlParams), "人力计划图表")); + } + else + { + ShowNotify("请先选确保时间范围已设置", MessageBoxIcon.Warning); + } + } + + #endregion + + + #region 关闭弹出窗 + + /// + /// 关闭弹出窗 + /// + /// + /// + protected void Window1_Close(object sender, WindowCloseEventArgs e) + { + BindGrid(); + } + + #endregion + + #region 导出按钮 + + /// 导出按钮 + /// + /// + /// + protected void btnOut_Click(object sender, EventArgs e) + { + Response.ClearContent(); + string filename = Funs.GetNewFileName(); + Response.AddHeader("content-disposition", + "attachment; filename=" + + System.Web.HttpUtility.UrlEncode("现场考勤人力表" + filename, System.Text.Encoding.UTF8) + ".xls"); + Response.ContentType = "application/excel"; + Response.ContentEncoding = System.Text.Encoding.UTF8; + this.BindGrid(); + // 生成并写入Excel表格 + Response.Write(GetGridTableHtml(Grid1)); + Response.End(); + } + + /// + /// 导出方法 - 支持多级表头 + /// + /// + /// + /// + private string GetGridTableHtml(Grid grid) + { + StringBuilder sb = new StringBuilder(); + + MultiHeaderTable mht = new MultiHeaderTable(); + mht.ResolveMultiHeaderTable(grid.Columns); + + sb.Append(""); + sb.Append(""); + + // 生成多级表头 + foreach (List rows in mht.MultiTable) + { + sb.Append(""); + foreach (object[] cell in rows) + { + int rowspan = 1; + int colspan = Convert.ToInt32(cell[1]); + GridColumn column = cell[2] as GridColumn; + + // 对于锁定列(固定列),确保rowspan为3 + if (column.Locked) + { + rowspan = 3; + } + + sb.AppendFormat("{3}", + " rowspan=\"" + rowspan + "\"", + colspan != 1 ? " colspan=\"" + colspan + "\"" : "", + colspan != 1 ? " style=\"text-align:center;\"" : "", + column.HeaderText); + } + + sb.Append(""); + } + + // 生成数据行 + foreach (GridRow row in grid.Rows) + { + sb.Append(""); + + foreach (GridColumn column in mht.Columns) + { + string html = row.Values[column.ColumnIndex].ToString(); + + // 特殊处理固定列 + if (column.ColumnID == "UnitName") + { + html = row.Values[column.ColumnIndex].ToString(); + } + else if (column.ColumnID == "WorkPostName") + { + html = row.Values[column.ColumnIndex].ToString(); + } + else if (column.ColumnID == "TotalCount") + { + html = row.Values[column.ColumnIndex].ToString(); + } + // 处理日期列(格式为 yyyy-MM-dd) + else if (DateTime.TryParseExact(column.ColumnID, "yyyy-MM-dd", null, + System.Globalization.DateTimeStyles.None, out _)) + { + html = row.Values[column.ColumnIndex].ToString(); + } + + sb.AppendFormat("", html); + } + + sb.Append(""); + } + + // 添加合计行 + if (grid.SummaryData != null) + { + sb.Append(""); + + foreach (GridColumn column in mht.Columns) + { + string summaryValue = ""; + // 检查SummaryData中是否有该列的合计值 + if (grid.SummaryData.Properties().Any(p => p.Name == column.ColumnID)) + { + var property = grid.SummaryData.Properties().FirstOrDefault(p => p.Name == column.ColumnID); + if (property != null) + { + summaryValue = property.Value.ToString(); + } + } + else if (column.ColumnID == "UnitName") + { + summaryValue = "合计"; + } + + sb.AppendFormat("", summaryValue); + } + + sb.Append(""); + } + + sb.Append("
{0}
{0}
"); + + return sb.ToString(); + } + + + #region 多表头处理 + + /// + /// 处理多表头的类 + /// + public class MultiHeaderTable + { + // 包含 rowspan,colspan 的多表头,方便生成 HTML 的 table 标签 + public List> MultiTable = new List>(); + + // 最终渲染的列数组 + public List Columns = new List(); + + public void ResolveMultiHeaderTable(GridColumnCollection columns) + { + List row = new List(); + foreach (GridColumn column in columns) + { + object[] cell = new object[4]; + cell[0] = 1; // rowspan + cell[1] = 1; // colspan + cell[2] = column; + cell[3] = null; + + row.Add(cell); + } + + ResolveMultiTable(row, 0); + ResolveColumns(row); + } + + private void ResolveColumns(List row) + { + foreach (object[] cell in row) + { + GroupField groupField = cell[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + List subrow = new List(); + foreach (GridColumn column in groupField.Columns) + { + subrow.Add(new object[] + { + 1, + 1, + column, + groupField + }); + } + + ResolveColumns(subrow); + } + else + { + Columns.Add(cell[2] as GridColumn); + } + } + } + + private void ResolveMultiTable(List row, int level) + { + List nextrow = new List(); + + foreach (object[] cell in row) + { + GroupField groupField = cell[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + // 如果当前列包含子列,则更改当前列的 colspan,以及增加父列(向上递归)的colspan + cell[1] = Convert.ToInt32(groupField.Columns.Count); + PlusColspan(level - 1, cell[3] as GridColumn, groupField.Columns.Count - 1); + + foreach (GridColumn column in groupField.Columns) + { + nextrow.Add(new object[] + { + 1, + 1, + column, + groupField + }); + } + } + else + { + // 如果当前列不包含子列,但不是最末级列(不是叶子节点),则增加rowspan + if (level > 0) + { + cell[0] = level + 1; + } + } + } + + MultiTable.Add(row); + + if (nextrow.Count > 0) + { + ResolveMultiTable(nextrow, level + 1); + } + } + + private void PlusColspan(int level, GridColumn column, int colspan) + { + if (level < 0) + { + return; + } + + foreach (List rows in MultiTable) + { + foreach (object[] cells in rows) + { + if (cells[2] == column) + { + cells[1] = Convert.ToInt32(cells[1]) + colspan; + + PlusColspan(level - 1, cells[3] as GridColumn, colspan); + break; + } + } + } + } + } + + #endregion + + #endregion + + } +} \ No newline at end of file diff --git a/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.designer.cs b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.designer.cs new file mode 100644 index 00000000..ef9efffd --- /dev/null +++ b/SGGL/FineUIPro.Web/JDGL/SGManPower/ManPowerWorkGrid.aspx.designer.cs @@ -0,0 +1,152 @@ +//------------------------------------------------------------------------------ +// <自动生成> +// 此代码由工具生成。 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace FineUIPro.Web.JDGL.SGManPower +{ + + + public partial class ManPowerWorkGrid + { + + /// + /// form1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::System.Web.UI.HtmlControls.HtmlForm form1; + + /// + /// PageManager1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.PageManager PageManager1; + + /// + /// Panel3 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel Panel3; + + /// + /// panelCenterRegion 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Panel panelCenterRegion; + + /// + /// Grid1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Grid Grid1; + + /// + /// Toolbar4 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Toolbar Toolbar4; + + /// + /// drpWorkPost 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList drpWorkPost; + + /// + /// btnQuery 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnQuery; + + /// + /// btnOut 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnOut; + + /// + /// btnGetChart 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Button btnGetChart; + + /// + /// ToolbarSeparator1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarSeparator ToolbarSeparator1; + + /// + /// ToolbarText1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.ToolbarText ToolbarText1; + + /// + /// ddlPageSize 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.DropDownList ddlPageSize; + + /// + /// Window1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Window Window1; + + /// + /// Window2 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Window Window2; + } +} diff --git a/SGGL/Model/Model.cs b/SGGL/Model/Model.cs index b090a5fb..ab2ea1b0 100644 --- a/SGGL/Model/Model.cs +++ b/SGGL/Model/Model.cs @@ -1412,6 +1412,9 @@ namespace Model partial void InsertJDGL_QuantityList(JDGL_QuantityList instance); partial void UpdateJDGL_QuantityList(JDGL_QuantityList instance); partial void DeleteJDGL_QuantityList(JDGL_QuantityList instance); + partial void InsertJDGL_SGManPower(JDGL_SGManPower instance); + partial void UpdateJDGL_SGManPower(JDGL_SGManPower instance); + partial void DeleteJDGL_SGManPower(JDGL_SGManPower instance); partial void InsertJDGL_SteelStructureCompletion(JDGL_SteelStructureCompletion instance); partial void UpdateJDGL_SteelStructureCompletion(JDGL_SteelStructureCompletion instance); partial void DeleteJDGL_SteelStructureCompletion(JDGL_SteelStructureCompletion instance); @@ -6544,6 +6547,14 @@ namespace Model } } + public System.Data.Linq.Table JDGL_SGManPower + { + get + { + return this.GetTable(); + } + } + public System.Data.Linq.Table JDGL_SteelStructureCompletion { get @@ -228031,6 +228042,308 @@ namespace Model } } + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.JDGL_SGManPower")] + public partial class JDGL_SGManPower : INotifyPropertyChanging, INotifyPropertyChanged + { + + private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); + + private string _Id; + + private string _ProjectId; + + private string _UnitId; + + private string _UnitWorkId; + + private string _WorkPostId; + + private string _Version; + + private System.Nullable _Quantity; + + private System.Nullable _PlanDate; + + private string _CompileMan; + + private System.Nullable _CompileTime; + + private string _Remarks; + + #region 可扩展性方法定义 + partial void OnLoaded(); + partial void OnValidate(System.Data.Linq.ChangeAction action); + partial void OnCreated(); + partial void OnIdChanging(string value); + partial void OnIdChanged(); + partial void OnProjectIdChanging(string value); + partial void OnProjectIdChanged(); + partial void OnUnitIdChanging(string value); + partial void OnUnitIdChanged(); + partial void OnUnitWorkIdChanging(string value); + partial void OnUnitWorkIdChanged(); + partial void OnWorkPostIdChanging(string value); + partial void OnWorkPostIdChanged(); + partial void OnVersionChanging(string value); + partial void OnVersionChanged(); + partial void OnQuantityChanging(System.Nullable value); + partial void OnQuantityChanged(); + partial void OnPlanDateChanging(System.Nullable value); + partial void OnPlanDateChanged(); + partial void OnCompileManChanging(string value); + partial void OnCompileManChanged(); + partial void OnCompileTimeChanging(System.Nullable value); + partial void OnCompileTimeChanged(); + partial void OnRemarksChanging(string value); + partial void OnRemarksChanged(); + #endregion + + public JDGL_SGManPower() + { + OnCreated(); + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Id", DbType="NVarChar(50) NOT NULL", CanBeNull=false, IsPrimaryKey=true)] + public string Id + { + get + { + return this._Id; + } + set + { + if ((this._Id != value)) + { + this.OnIdChanging(value); + this.SendPropertyChanging(); + this._Id = value; + this.SendPropertyChanged("Id"); + this.OnIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")] + public string ProjectId + { + get + { + return this._ProjectId; + } + set + { + if ((this._ProjectId != value)) + { + this.OnProjectIdChanging(value); + this.SendPropertyChanging(); + this._ProjectId = value; + this.SendPropertyChanged("ProjectId"); + this.OnProjectIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitId", DbType="NVarChar(50)")] + public string UnitId + { + get + { + return this._UnitId; + } + set + { + if ((this._UnitId != value)) + { + this.OnUnitIdChanging(value); + this.SendPropertyChanging(); + this._UnitId = value; + this.SendPropertyChanged("UnitId"); + this.OnUnitIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitWorkId", DbType="NVarChar(50)")] + public string UnitWorkId + { + get + { + return this._UnitWorkId; + } + set + { + if ((this._UnitWorkId != value)) + { + this.OnUnitWorkIdChanging(value); + this.SendPropertyChanging(); + this._UnitWorkId = value; + this.SendPropertyChanged("UnitWorkId"); + this.OnUnitWorkIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkPostId", DbType="NVarChar(50)")] + public string WorkPostId + { + get + { + return this._WorkPostId; + } + set + { + if ((this._WorkPostId != value)) + { + this.OnWorkPostIdChanging(value); + this.SendPropertyChanging(); + this._WorkPostId = value; + this.SendPropertyChanged("WorkPostId"); + this.OnWorkPostIdChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Version", DbType="NVarChar(50)")] + public string Version + { + get + { + return this._Version; + } + set + { + if ((this._Version != value)) + { + this.OnVersionChanging(value); + this.SendPropertyChanging(); + this._Version = value; + this.SendPropertyChanged("Version"); + this.OnVersionChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Quantity", DbType="Int")] + public System.Nullable Quantity + { + get + { + return this._Quantity; + } + set + { + if ((this._Quantity != value)) + { + this.OnQuantityChanging(value); + this.SendPropertyChanging(); + this._Quantity = value; + this.SendPropertyChanged("Quantity"); + this.OnQuantityChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_PlanDate", DbType="DateTime")] + public System.Nullable PlanDate + { + get + { + return this._PlanDate; + } + set + { + if ((this._PlanDate != value)) + { + this.OnPlanDateChanging(value); + this.SendPropertyChanging(); + this._PlanDate = value; + this.SendPropertyChanged("PlanDate"); + this.OnPlanDateChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CompileMan", DbType="NVarChar(50)")] + public string CompileMan + { + get + { + return this._CompileMan; + } + set + { + if ((this._CompileMan != value)) + { + this.OnCompileManChanging(value); + this.SendPropertyChanging(); + this._CompileMan = value; + this.SendPropertyChanged("CompileMan"); + this.OnCompileManChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_CompileTime", DbType="DateTime")] + public System.Nullable CompileTime + { + get + { + return this._CompileTime; + } + set + { + if ((this._CompileTime != value)) + { + this.OnCompileTimeChanging(value); + this.SendPropertyChanging(); + this._CompileTime = value; + this.SendPropertyChanged("CompileTime"); + this.OnCompileTimeChanged(); + } + } + } + + [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Remarks", DbType="NVarChar(500)")] + public string Remarks + { + get + { + return this._Remarks; + } + set + { + if ((this._Remarks != value)) + { + this.OnRemarksChanging(value); + this.SendPropertyChanging(); + this._Remarks = value; + this.SendPropertyChanged("Remarks"); + this.OnRemarksChanged(); + } + } + } + + public event PropertyChangingEventHandler PropertyChanging; + + public event PropertyChangedEventHandler PropertyChanged; + + protected virtual void SendPropertyChanging() + { + if ((this.PropertyChanging != null)) + { + this.PropertyChanging(this, emptyChangingEventArgs); + } + } + + protected virtual void SendPropertyChanged(String propertyName) + { + if ((this.PropertyChanged != null)) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); + } + } + } + [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.JDGL_SteelStructureCompletion")] public partial class JDGL_SteelStructureCompletion : INotifyPropertyChanging, INotifyPropertyChanged {