From 8259e4c4bff77dd259cd433c0ae4377d6c3e78ab Mon Sep 17 00:00:00 2001 From: 10191 <506754232@qq.com> Date: Sun, 29 Mar 2026 12:01:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HSSE/SitePerson/PersonList.aspx.cs | 120 +++++++++++++++++- 1 file changed, 114 insertions(+), 6 deletions(-) diff --git a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs index 6b59cb57..d746c59d 100644 --- a/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/SitePerson/PersonList.aspx.cs @@ -1,4 +1,5 @@ using BLL; +using FineUIPro.Web.Person; using System; using System.Collections.Generic; using System.Data; @@ -78,18 +79,47 @@ namespace FineUIPro.Web.HSSE.SitePerson var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); if (project != null) { - var personLists = BLL.PersonService.GetPersonList(project.ProjectId); + // var personLists = BLL.PersonService.GetPersonList(project.ProjectId); + String strSql1 = @"select UnitId,count( * ) num from SitePerson_Person + where ProjectId='" + this.CurrUser.LoginProjectId + @"' + group by UnitId"; + + String strSql2 = @" select UnitId,count( * ) num from SitePerson_Person + where ProjectId='" + this.CurrUser.LoginProjectId + @"' and IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' ) + group by UnitId"; + + + DataTable dt1 = SQLHelper.GetDataTableRunText(strSql1, null); + DataTable dt2 = SQLHelper.GetDataTableRunText(strSql2, null); + int proTotal = 0; + int proIn = 0; + if (dt1 != null && dt1.Rows.Count > 0) + { + foreach (DataRow row in dt1.Rows) + { + proTotal += int.Parse(row["num"].ToString()); + } + } + if (dt2 != null && dt2.Rows.Count > 0) + { + foreach (DataRow row in dt2.Rows) + { + proIn += int.Parse(row["num"].ToString()); + } + } TreeNode rootNode = new TreeNode(); rootNode = new TreeNode { Text = project.ProjectName, NodeID = project.ProjectId }; - if (personLists.Count() > 0) + // if (personLists.Count() > 0) + if (proTotal > 0) { - var personIn = personLists.Where(x => x.ProjectId == project.ProjectId && x.IsUsed == true - && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList(); - rootNode.ToolTip = "当前项目人员总数:" + personLists.Count() + ";在场人员数:" + personIn.Count() + ";离场人员数:" + (personLists.Count() - personIn.Count()); + //var personIn = personLists.Where(x => x.ProjectId == project.ProjectId && x.IsUsed == true + // && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList(); + //rootNode.ToolTip = "当前项目人员总数:" + personLists.Count() + ";在场人员数:" + personIn.Count() + ";离场人员数:" + (personLists.Count() - personIn.Count()); + rootNode.ToolTip = "当前项目人员总数:" + proTotal + ";在场人员数:" + proIn + ";离场人员数:" + (proTotal - proIn); } else { @@ -98,7 +128,85 @@ namespace FineUIPro.Web.HSSE.SitePerson rootNode.Expanded = true; rootNode.EnableClickEvent = true; this.tvProjectAndUnit.Nodes.Add(rootNode); - GetUnitLists(rootNode.Nodes, project.ProjectId, personLists); + //GetUnitLists(rootNode.Nodes, project.ProjectId, personLists); + GetUnitLists(rootNode.Nodes, this.ProjectId, dt1, dt2); + + } + } + private void GetUnitLists(TreeNodeCollection nodes, string parentId, DataTable dt1, DataTable dt2) + { + List unitLists = BLL.UnitService.GetUnitByProjectIdList(parentId); + if (unitLists.Count() > 0) + { + if (BLL.ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(parentId, this.CurrUser.UnitId)) + { + unitLists = unitLists.Where(x => x.UnitId == this.CurrUser.UnitId).ToList(); + } + + //添加其他单位/无单位人员 + Model.Base_Unit otherUnit = new Model.Base_Unit + { + UnitId = "0", + UnitName = "其他" + }; + unitLists.Add(otherUnit); + + TreeNode newNode = null; + foreach (var q in unitLists) + { + newNode = new TreeNode + { + Text = q.UnitName, + NodeID = q.UnitId + "|" + parentId, + ToolTip = q.UnitName + }; + int proTotal = 0; + int proIn = 0; + + if (dt1 != null && dt1.Rows.Count > 0) + { + foreach (DataRow row in dt1.Rows) + { + if (q.UnitId == "0" && string.IsNullOrEmpty(row["UnitId"].ToString())) + { + proTotal = int.Parse(row["num"].ToString()); + break; + } + else if (q.UnitId == row["UnitId"].ToString()) + { + proTotal = int.Parse(row["num"].ToString()); + break; + } + } + } + if (dt2 != null && dt2.Rows.Count > 0) + { + foreach (DataRow row in dt2.Rows) + { + if (q.UnitId == "0" && string.IsNullOrEmpty(row["UnitId"].ToString())) + { + proIn = int.Parse(row["num"].ToString()); + break; + } + else if (q.UnitId == row["UnitId"].ToString()) + { + proIn = int.Parse(row["num"].ToString()); + break; + } + } + } + + if (proTotal > 0) + { + newNode.ToolTip = q.UnitName + "人员总数:" + proTotal + ";在场人员数:" + proIn + ";离场人员数:" + (proTotal - proIn); + } + else + { + newNode.ToolTip = q.UnitName + "人员总数:0"; + } + newNode.EnableClickEvent = true; + nodes.Add(newNode); + } } }