From bfc46a7830c590cbec82d61e590edfe4afc11f98 Mon Sep 17 00:00:00 2001 From: 10191 <506754232@qq.com> Date: Sat, 25 Apr 2026 11:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/mainMenu_PDigData.aspx.cs | 198 ++++++++++++------ 1 file changed, 135 insertions(+), 63 deletions(-) diff --git a/SGGL/FineUIPro.Web/common/mainMenu_PDigData.aspx.cs b/SGGL/FineUIPro.Web/common/mainMenu_PDigData.aspx.cs index 6ebcfaf8..1709c629 100644 --- a/SGGL/FineUIPro.Web/common/mainMenu_PDigData.aspx.cs +++ b/SGGL/FineUIPro.Web/common/mainMenu_PDigData.aspx.cs @@ -3,6 +3,7 @@ using FineUIPro.Web.DataShow; using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.Data; using System.Linq; namespace FineUIPro.Web.common @@ -35,9 +36,9 @@ namespace FineUIPro.Web.common { this.ProjectId = this.CurrUser.LoginProjectId; } - getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList(); - getAllPersons = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).ToList(); - getPersons = getAllPersons.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList(); + //getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList(); + //getAllPersons = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).ToList(); + //getPersons = getAllPersons.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList(); ///当前现场总人数 getSitePerson(); } @@ -53,9 +54,12 @@ namespace FineUIPro.Web.common //var getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.ProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList(); // int AllCount = getEmployInOutRecords.Count(); - - var getallin = APIPageDataService.getPersonNum(this.ProjectId, DateTime.Now); - int AllCount = getallin.Count(); + var AllCount = (from x in Funs.DB.T_d_EmployInOutRecord + join y in Funs.DB.SitePerson_Person on new { ss1 = x.ProjectId, ss = x.IDCardNo } equals new { ss1 = y.ProjectId, ss = y.IdentityCard } + where y.ProjectId == this.CurrUser.LoginProjectId && y.IsUsed == true && x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date + select x.IDCardNo).Distinct().Count(); + //var getallin = APIPageDataService.getPersonNum(this.ProjectId, DateTime.Now); + // int AllCount = getallin.Count(); if (AllCount > 0) { ////总人数 @@ -103,18 +107,18 @@ namespace FineUIPro.Web.common #endregion #region 现场人员 - /// - /// - /// - public static List getEmployInOutRecords; - /// - /// - /// - public static List getAllPersons; - /// - /// - /// - public static List getPersons; + ///// + ///// + ///// + //public static List getEmployInOutRecords; + ///// + ///// + ///// + //public static List getAllPersons; + ///// + ///// + ///// + //public static List getPersons; /// /// 按单位统计 @@ -123,6 +127,24 @@ namespace FineUIPro.Web.common { get { + string sql = @"SELECT + p.UnitId + ,ISNULL((case when u.UnitName=''then null else u.UnitName end),'未知') AS UnitName + ,COUNT( distinct IDCardNo) AS numa + ,COUNT( distinct PersonId) AS numb + FROM dbo.SitePerson_Person AS P + LEFT JOIN ( select ProjectId,IDCardNo,SUM(ISNULL(ManHours,0)) ManHours from t_d_EmployInOutRecord where RecordDate >='" + DateTime.Now.ToString("yyyy-MM-dd") + @"' + AND RecordDate <= '" + DateTime.Now.ToString("yyyy-MM-dd") + @"' + group by ProjectId,IDCardNo) T ON P.ProjectId=T.ProjectId AND T.IDCardNo=P.IdentityCard + LEFT JOIN dbo.Base_Unit AS U ON P.UnitId=U.UnitId + LEFT JOIN dbo.Project_ProjectUnit AS pu ON pu.UnitId=p.UnitId and pu.ProjectId=p.ProjectId + WHERE pu.ProjectId is not null and P.ProjectId ='" + CurrUser.LoginProjectId + @"' and P.InTime <=GETDATE() and ( P.OutTime is null or P.OutTime > GETDATE()) and p.IsUsed =1 + + GROUP BY P.UnitId,U.UnitName + + "; + DataTable tb41 = SQLHelper.GetDataTableRunText(sql); + List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); @@ -131,35 +153,54 @@ namespace FineUIPro.Web.common List listdata = new List(); List listdata2 = new List(); businessColumn.title = "现场人员"; - int manCount = 0; - var units = getAllPersons.Select(x => x.UnitId).Distinct(); - if (units.Count() > 0) + if (tb41.Rows.Count > 0) { - foreach (var unitId in units) + foreach (DataRow row in tb41.Rows) { - var unitRords = from x in getEmployInOutRecords - join y in getAllPersons on x.IDCardNo equals y.IdentityCard - where y.UnitId == unitId && y.PersonId != null && x.UnitId == unitId - select x; - var unitPersons = getPersons.Where(x => x.UnitId == unitId); - int rcount = unitRords.Distinct().Count(); - if (rcount > 0) + listCategories.Add(UnitService.GetShortUnitNameByUnitId(row["UnitId"].ToString()) ?? "未知"); + if (!string.IsNullOrEmpty(row["numa"].ToString())) { - manCount += rcount; - listCategories.Add(UnitService.GetShortUnitNameByUnitId(unitId)); - listdata.Add(rcount); - listdata2.Add(unitPersons.Count()); + listdata.Add(double.Parse(row["numa"].ToString())); } + else + { + listdata.Add(0); + + } + + listdata2.Add(double.Parse(row["numb"].ToString())); } } - int nullCount = getEmployInOutRecords.Count() - manCount; - if (nullCount > 0) - { - listCategories.Add("未知"); - listdata.Add(nullCount); - listdata2.Add(0); - } + //int manCount = 0; + //var units = getAllPersons.Select(x => x.UnitId).Distinct(); + //if (units.Count() > 0) + //{ + // foreach (var unitId in units) + // { + // var unitRords = from x in getEmployInOutRecords + // join y in getAllPersons on x.IDCardNo equals y.IdentityCard + // where y.UnitId == unitId && y.PersonId != null && x.UnitId == unitId + // select x; + // var unitPersons = getPersons.Where(x => x.UnitId == unitId); + // int rcount = unitRords.Distinct().Count(); + // if (rcount > 0) + // { + // manCount += rcount; + // listCategories.Add(UnitService.GetShortUnitNameByUnitId(unitId)); + // listdata.Add(rcount); + // listdata2.Add(unitPersons.Count()); + // } + // } + //} + + //int nullCount = getEmployInOutRecords.Count() - manCount; + //if (nullCount > 0) + //{ + // listCategories.Add("未知"); + // listdata.Add(nullCount); + // listdata2.Add(0); + //} s.data = listdata; series.Add(s); @@ -179,6 +220,20 @@ namespace FineUIPro.Web.common { get { + string sql = @" + select b.*,a.numa,c.WorkPostName from( + select a.PostId, a.PostName, COUNT(1) numa from T_d_EmployInOutRecord a left join SitePerson_Person b on a.IDCardNo = b.IdentityCard and a.ProjectId =b.ProjectId + where a.ProjectId = '" + CurrUser.LoginProjectId + "' and RecordDate = '" + DateTime.Now.ToString("yyyy-MM-dd") + @"' 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 PostId,PostName)a right join + ( + select WorkPostId, COUNT(1) numb from SitePerson_Person + where ProjectId = '" + 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 WorkPostId + )b on a.PostId = b.WorkPostId left join Base_WorkPost c on b.WorkPostId=c.WorkPostId + "; + + DataTable tb41 = SQLHelper.GetDataTableRunText(sql); + List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); @@ -187,34 +242,51 @@ namespace FineUIPro.Web.common Model.SingleSerie s2 = new Model.SingleSerie(); List listdata2 = new List(); businessColumn.title = "现场人员"; - var getTypes = (from x in getEmployInOutRecords - join y in getAllPersons on x.IDCardNo equals y.IdentityCard - join z in Funs.DB.Base_WorkPost on y.WorkPostId equals z.WorkPostId - select new { y.WorkPostId, z.WorkPostName }).Distinct(); - if (getTypes.Count() > 0) + if (tb41.Rows.Count > 0) { - foreach (var item in getTypes) + foreach (DataRow item in tb41.Rows) { - listCategories.Add(item.WorkPostName ?? "未知"); - var unitRords = getEmployInOutRecords.Where(x => x.PostId == item.WorkPostId); - var unitPersons = getPersons.Where(x => x.WorkPostId == item.WorkPostId); - listdata.Add(unitRords.Count()); - listdata2.Add(unitPersons.Count()); - } - } - else - { - var getpTypes = getPersons.Select(x => x.WorkPostId).Distinct(); - foreach (var item in getpTypes) - { - listCategories.Add(WorkPostService.getWorkPostNameById(item)); - var unitRords = getEmployInOutRecords.Where(x => x.PostId == item); - var unitPersons = getPersons.Where(x => x.WorkPostId == item); - listdata.Add(unitRords.Count()); - listdata2.Add(unitPersons.Count()); + listCategories.Add(item["WorkPostName"].ToString()); + if (!string.IsNullOrEmpty(item["numa"].ToString())) + { + listdata.Add(double.Parse(item["numa"].ToString())); + } + else + { + listdata.Add(0); + } + listdata2.Add(double.Parse(item["numb"].ToString())); } } + //var getTypes = (from x in getEmployInOutRecords + // join y in getAllPersons on x.IDCardNo equals y.IdentityCard + // join z in Funs.DB.Base_WorkPost on y.WorkPostId equals z.WorkPostId + // select new { y.WorkPostId, z.WorkPostName }).Distinct(); + //if (getTypes.Count() > 0) + //{ + // foreach (var item in getTypes) + // { + // listCategories.Add(item.WorkPostName ?? "未知"); + // var unitRords = getEmployInOutRecords.Where(x => x.PostId == item.WorkPostId); + // var unitPersons = getPersons.Where(x => x.WorkPostId == item.WorkPostId); + // listdata.Add(unitRords.Count()); + // listdata2.Add(unitPersons.Count()); + // } + //} + //else + //{ + // var getpTypes = getPersons.Select(x => x.WorkPostId).Distinct(); + // foreach (var item in getpTypes) + // { + // listCategories.Add(WorkPostService.getWorkPostNameById(item)); + // var unitRords = getEmployInOutRecords.Where(x => x.PostId == item); + // var unitPersons = getPersons.Where(x => x.WorkPostId == item); + // listdata.Add(unitRords.Count()); + // listdata2.Add(unitPersons.Count()); + // } + //} + s.data = listdata; series.Add(s); s2.data = listdata2;