20231024
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using BLL;
|
||||
using FineUIPro.Web.DataShow;
|
||||
using Model;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -82,26 +83,61 @@ namespace FineUIPro.Web.HSSE.SitePerson
|
||||
var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId);
|
||||
if (project != null)
|
||||
{
|
||||
var personLists = BLL.PersonService.GetPersonList(project.ProjectId);
|
||||
string strSql1 = @"select UnitId,count(1) num from SitePerson_Person
|
||||
where ProjectId=@ProjectId
|
||||
group by UnitId";
|
||||
List<SqlParameter> listStr1 = new List<SqlParameter>
|
||||
{
|
||||
new SqlParameter("@ProjectId", this.ProjectId)
|
||||
};
|
||||
SqlParameter[] parameter1 = listStr1.ToArray();
|
||||
DataTable tb1 = SQLHelper.GetDataTableRunText(strSql1, parameter1);
|
||||
string strSql2 = @"select UnitId,count(1) num from SitePerson_Person
|
||||
where ProjectId=@ProjectId and IsUsed =1 and InTime <getdate() and (OutTime is null or OutTime >getdate())
|
||||
group by UnitId";
|
||||
List<SqlParameter> listStr2 = new List<SqlParameter>
|
||||
{
|
||||
new SqlParameter("@ProjectId", this.ProjectId)
|
||||
};
|
||||
SqlParameter[] parameter2 = listStr2.ToArray();
|
||||
DataTable tb2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
||||
int total = 0;
|
||||
int totalIn = 0;
|
||||
Dictionary<string, int> dicTotal = new Dictionary<string, int>();
|
||||
Dictionary<string, int> dicTotalIn = new Dictionary<string, int>();
|
||||
|
||||
if (tb1 != null)
|
||||
{
|
||||
foreach (DataRow row in tb1.Rows)
|
||||
{
|
||||
total += int.Parse(row["num"].ToString());
|
||||
dicTotal.Add(row["UnitId"].ToString(), int.Parse(row["num"].ToString()));
|
||||
}
|
||||
}
|
||||
if (tb2 != null)
|
||||
{
|
||||
foreach (DataRow row in tb2.Rows)
|
||||
{
|
||||
totalIn += int.Parse(row["num"].ToString());
|
||||
dicTotalIn.Add(row["UnitId"].ToString(), int.Parse(row["num"].ToString()));
|
||||
|
||||
}
|
||||
}
|
||||
TreeNode rootNode = new TreeNode();
|
||||
rootNode = new TreeNode
|
||||
{
|
||||
Text = project.ProjectName,
|
||||
NodeID = project.ProjectId
|
||||
};
|
||||
if (personLists.Count() > 0)
|
||||
{
|
||||
var personIn = personLists.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.IsUsed == 1
|
||||
&& x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList();
|
||||
rootNode.ToolTip = "当前项目人员总数:" + personLists.Count() + ";在场人员数:" + personIn.Count() + ";离场人员数:" + (personLists.Count() - personIn.Count());
|
||||
}
|
||||
else
|
||||
{
|
||||
rootNode.ToolTip = "当前项目人员总数:0";
|
||||
}
|
||||
|
||||
|
||||
|
||||
rootNode.ToolTip = "当前项目人员总数:" + total + ";在场人员数:" + totalIn + ";离场人员数:" + (total - totalIn);
|
||||
|
||||
|
||||
rootNode.Expanded = true;
|
||||
this.tvProjectAndUnit.Nodes.Add(rootNode);
|
||||
GetUnitLists(rootNode.Nodes, this.ProjectId, personLists);
|
||||
GetUnitLists(rootNode.Nodes, this.ProjectId, dicTotal, dicTotalIn);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +201,66 @@ namespace FineUIPro.Web.HSSE.SitePerson
|
||||
}
|
||||
}
|
||||
}
|
||||
private void GetUnitLists(TreeNodeCollection nodes, string parentId, Dictionary<string, int> dicTotal, Dictionary<string, int> dicTotalIn)
|
||||
{
|
||||
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)
|
||||
{
|
||||
int total = 0;
|
||||
int totalIn = 0;
|
||||
if (q.UnitId != "0")
|
||||
{
|
||||
if (dicTotal.ContainsKey(q.UnitId))
|
||||
{
|
||||
total = dicTotal[q.UnitId];
|
||||
}
|
||||
if (dicTotalIn.ContainsKey(q.UnitId))
|
||||
{
|
||||
totalIn = dicTotalIn[q.UnitId];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (dicTotal.ContainsKey(""))
|
||||
{
|
||||
total = dicTotal[""];
|
||||
}
|
||||
if (dicTotalIn.ContainsKey(""))
|
||||
{
|
||||
totalIn = dicTotalIn[""];
|
||||
}
|
||||
}
|
||||
newNode = new TreeNode
|
||||
{
|
||||
Text = q.UnitName,
|
||||
NodeID = q.UnitId + "|" + parentId,
|
||||
ToolTip = q.UnitName
|
||||
};
|
||||
|
||||
|
||||
newNode.ToolTip = q.UnitName + "人员总数:" + total + ";在场人员数:" + totalIn + ";离场人员数:" + (total - totalIn);
|
||||
|
||||
newNode.EnableClickEvent = true;
|
||||
nodes.Add(newNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
@@ -197,10 +293,10 @@ namespace FineUIPro.Web.HSSE.SitePerson
|
||||
strSql += " AND UnitId =@UnitId ";
|
||||
listStr.Add(new SqlParameter("@UnitId", unitId));
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// strSql += " AND UnitId IS NULL";
|
||||
//}
|
||||
else if( unitId == "0")
|
||||
{
|
||||
strSql += " AND UnitId IS NULL";
|
||||
}
|
||||
if (drpIsUsedName.SelectedValue == "待审核")
|
||||
{
|
||||
strSql += " AND IsUsed = @IsUsed";
|
||||
|
||||
Reference in New Issue
Block a user