优化现场人员统计

This commit is contained in:
李超 2025-09-20 18:15:28 +08:00
parent dc3f0bdc97
commit 7c43296f41
1 changed files with 51 additions and 15 deletions

View File

@ -13,6 +13,7 @@ using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using Org.BouncyCastle.Ocsp; using Org.BouncyCastle.Ocsp;
using FineUIPro.Web.HJGL.FL; using FineUIPro.Web.HJGL.FL;
using System.Data;
namespace FineUIPro.Web.common namespace FineUIPro.Web.common
{ {
@ -981,23 +982,51 @@ namespace FineUIPro.Web.common
{ {
await Task.Run(() => await Task.Run(() =>
{ {
int AllCount = 0; int AllCount = 0;
int MCount = 0; int MCount = 0;
var getallin = new List<Model.PageDataPersonInOutItem>(); //var getallin = new List<Model.PageDataPersonInOutItem>();
if (pids == null) //if (pids == null)
//{
// getallin = APIPageDataService.getPersonNum(new List<string>(), DateTime.Now);
//}
//else
//{
// getallin = APIPageDataService.getPersonNum(pids.ToList(), DateTime.Now);
//}
var startDate = DateTime.Now.Date;
var endDate = startDate.AddDays(1);
string strSql = @"select ProjectId,PostType,COUNT(distinct PersonId)PersonNum from SitePerson_PersonInOutNow
where ChangeTime >= '" + startDate.ToString("yyyy-MM-dd") + "' and ChangeTime <='" + endDate.ToString("yyyy-MM-dd") + "' and ProjectId in ('" + string.Join("','", allProjects.Select(x => x.ProjectId)) + @"')
group by ProjectId,PostType";
DataTable dt = SQLHelper.GetDataTableRunText(strSql, null);
Dictionary<string, int> dic = new Dictionary<string, int>();
foreach (DataRow row in dt.Rows)
{ {
getallin = APIPageDataService.getPersonNum(new List<string>(), DateTime.Now); string projectid = row["ProjectId"].ToString();
} string postType = row["PostType"].ToString();
else int PersonNum = int.Parse(row["PersonNum"].ToString());
{ if (!dic.ContainsKey(projectid))
getallin = APIPageDataService.getPersonNum(pids.ToList(), DateTime.Now); {
} dic.Add(projectid, PersonNum);
AllCount = getallin.Count(); }
if (AllCount > 0) else
{ {
MCount = getallin.Count(x => x.PostType == Const.PostType_1); dic[projectid] = dic[projectid] + PersonNum;
}
AllCount += PersonNum;
if(postType == Const.PostType_1)
{
MCount += PersonNum;
}
} }
div_xcrs.InnerHtml = AllCount.ToString(); div_xcrs.InnerHtml = AllCount.ToString();
div_zyxcrs.InnerHtml = (AllCount - MCount).ToString(); div_zyxcrs.InnerHtml = (AllCount - MCount).ToString();
div_glxcrs.InnerHtml = MCount.ToString(); div_glxcrs.InnerHtml = MCount.ToString();
@ -1006,7 +1035,14 @@ namespace FineUIPro.Web.common
foreach (var item in allProjects) foreach (var item in allProjects)
{ {
ProjectPersonMc += "'" + item.ShortName + "',"; ProjectPersonMc += "'" + item.ShortName + "',";
ProjectPersonCount += "'" + getallin.Count(x => x.ProjectId == item.ProjectId) + "',"; if (dic.ContainsKey(item.ProjectId))
{
ProjectPersonCount += "'" + dic[item.ProjectId] + "',";
}
else
{
ProjectPersonCount += "'0',";
}
} }
ProjectPersonMc = !string.IsNullOrWhiteSpace(ProjectPersonMc) ? ProjectPersonMc.TrimEnd(',') : string.Empty; ProjectPersonMc = !string.IsNullOrWhiteSpace(ProjectPersonMc) ? ProjectPersonMc.TrimEnd(',') : string.Empty;
ProjectPersonCount = !string.IsNullOrWhiteSpace(ProjectPersonCount) ? ProjectPersonCount.TrimEnd(',') : string.Empty; ProjectPersonCount = !string.IsNullOrWhiteSpace(ProjectPersonCount) ? ProjectPersonCount.TrimEnd(',') : string.Empty;