diff --git a/SGGL/FineUIPro.Web/common/main_new.aspx.cs b/SGGL/FineUIPro.Web/common/main_new.aspx.cs index 1804313a..0a109fe3 100644 --- a/SGGL/FineUIPro.Web/common/main_new.aspx.cs +++ b/SGGL/FineUIPro.Web/common/main_new.aspx.cs @@ -13,6 +13,7 @@ using System.Web.UI; using System.Web.UI.WebControls; using Org.BouncyCastle.Ocsp; using FineUIPro.Web.HJGL.FL; +using System.Data; namespace FineUIPro.Web.common { @@ -981,23 +982,51 @@ namespace FineUIPro.Web.common { await Task.Run(() => { - int AllCount = 0; - int MCount = 0; - var getallin = new List(); - if (pids == null) + int AllCount = 0; + int MCount = 0; + //var getallin = new List(); + //if (pids == null) + //{ + // getallin = APIPageDataService.getPersonNum(new List(), 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 dic = new Dictionary(); + foreach (DataRow row in dt.Rows) { - getallin = APIPageDataService.getPersonNum(new List(), DateTime.Now); - } - else - { - getallin = APIPageDataService.getPersonNum(pids.ToList(), DateTime.Now); - } - AllCount = getallin.Count(); - if (AllCount > 0) - { - MCount = getallin.Count(x => x.PostType == Const.PostType_1); + string projectid = row["ProjectId"].ToString(); + string postType = row["PostType"].ToString(); + int PersonNum = int.Parse(row["PersonNum"].ToString()); + if (!dic.ContainsKey(projectid)) + { + dic.Add(projectid, PersonNum); + } + else + { + dic[projectid] = dic[projectid] + PersonNum; + } + AllCount += PersonNum; + if(postType == Const.PostType_1) + { + MCount += PersonNum; + } } + + + div_xcrs.InnerHtml = AllCount.ToString(); div_zyxcrs.InnerHtml = (AllCount - MCount).ToString(); div_glxcrs.InnerHtml = MCount.ToString(); @@ -1006,7 +1035,14 @@ namespace FineUIPro.Web.common foreach (var item in allProjects) { 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; ProjectPersonCount = !string.IsNullOrWhiteSpace(ProjectPersonCount) ? ProjectPersonCount.TrimEnd(',') : string.Empty;