优化 菜单

This commit is contained in:
李超 2026-03-29 12:01:01 +08:00
parent 2063ad795e
commit 8259e4c4bf
1 changed files with 114 additions and 6 deletions

View File

@ -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<Model.Base_Unit> 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);
}
}
}