大屏优化

This commit is contained in:
2025-03-17 15:53:00 +08:00
parent 4ee7d38c78
commit 2927c2d985
10 changed files with 1020 additions and 774 deletions
+42 -6
View File
@@ -25,7 +25,7 @@ namespace BLL
&& x.ChangeTime.Value.Month == dateValue.Month
&& x.ChangeTime.Value.Day == dateValue.Day
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType };
if (getDayAll.Count() > 0)
if (getDayAll.Any())
{
var getInMaxs = from x in getDayAll
group x by x.PersonId into g
@@ -36,7 +36,7 @@ namespace BLL
IsIn = g.First().IsIn,
PostType = g.First().PostType
};
if (getInMaxs.Count() > 0)
if (getInMaxs.Any())
{
getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList();
}
@@ -44,6 +44,42 @@ namespace BLL
return getSiteInOutList;
}
}
public static List<Model.PageDataPersonInOutItem> getPersonNum(List<string> projectIds, DateTime dateValue)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var startDate = dateValue.Date;
var endDate = startDate.AddDays(1);
List<Model.PageDataPersonInOutItem> getSiteInOutList = new List<Model.PageDataPersonInOutItem>();
var getDayAll = from x in db.SitePerson_PersonInOutNow
join y in db.SitePerson_Person on x.PersonId equals y.PersonId
join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId
where projectIds.Contains(x.ProjectId)
&& x.ChangeTime >= startDate &&
x.ChangeTime < endDate
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType,x.ProjectId };
if (getDayAll.Any())
{
var getInMaxs = from x in getDayAll
group x by new {x.PersonId,x.ProjectId} into g
select new Model.PageDataPersonInOutItem
{
PersonId = g.First().PersonId,
ProjectId = g.First().ProjectId,
ChangeTime = g.Max(x => x.ChangeTime),
IsIn = g.First().IsIn,
PostType = g.First().PostType
};
if (getInMaxs.Any())
{
getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList();
}
}
return getSiteInOutList;
}
}
#endregion
#region
@@ -150,7 +186,7 @@ namespace BLL
where x.ChangeTime.Value.Year == dateValue.Year && x.ChangeTime.Value.Month == dateValue.Month
&& x.ChangeTime.Value.Day == dateValue.Day
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType };
if (getDayAll.Count() > 0)
if (getDayAll.Any())
{
var getInMaxs = from x in getDayAll
group x by x.PersonId into g
@@ -161,7 +197,7 @@ namespace BLL
IsIn = g.First().IsIn,
PostType = g.First().PostType
};
if (getInMaxs.Count() > 0)
if (getInMaxs.Any())
{
getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList();
}
@@ -181,7 +217,7 @@ namespace BLL
where x.ChangeTime.Value.Year == dateValue.Year && x.ChangeTime.Value.Month == dateValue.Month
&& x.ChangeTime.Value.Day == dateValue.Day && pids.Contains(x.ProjectId)
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType };
if (getDayAll.Count() > 0)
if (getDayAll.Any())
{
var getInMaxs = from x in getDayAll
group x by x.PersonId into g
@@ -192,7 +228,7 @@ namespace BLL
IsIn = g.First().IsIn,
PostType = g.First().PostType
};
if (getInMaxs.Count() > 0)
if (getInMaxs.Any())
{
getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList();
}
+3
View File
@@ -1113,6 +1113,9 @@
<PackageReference Include="System.Numerics.Vectors">
<Version>4.5.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.Caching">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime.CompilerServices.Unsafe">
<Version>4.5.3</Version>
</PackageReference>
+1
View File
@@ -10,6 +10,7 @@ namespace BLL
/// 时间书签(用于筛选数据范围)修改日期 2024-10-19 18:55:14 由2023改成2020
/// </summary>
public static DateTime DtmarkTime = DateTime.Parse("2020-01-01");
public static int CacheMinutes = 10;
#region
/// <summary>
/// 系统管理员ID
+35 -11
View File
@@ -5,6 +5,8 @@
using Model;
using System;
using Newtonsoft.Json;
using Microsoft.SqlServer.Dts.Runtime;
using System.Runtime.Caching;
public static class ProjectService
{
@@ -256,22 +258,44 @@
/// <returns></returns>
public static List<Model.Base_Project> GetAllProjectDropDownList(string[] pids = null)
{
if (pids == null)
string cacheKey = "allProjects";
var memoryCache = MemoryCache.Default;
if (memoryCache.Get(cacheKey) != null)
{
var list = (from x in Funs.DB.Base_Project
orderby x.ProjectCode descending
select x).ToList();
return list;
var result = (List<Model.Base_Project>)memoryCache.Get(cacheKey);
if (pids == null)
{
return result;
}
else
{
result = result.Where(e => pids.Contains(e.ProjectId)).ToList();
return result;
}
}
else
{
var list = (from x in Funs.DB.Base_Project
where pids.Contains(x.ProjectId)
orderby x.ProjectCode descending
select x).ToList();
return list;
}
var list = (from x in Funs.DB.Base_Project
where x.ProjectState == Const.ProjectState_1 || x.ProjectState == null
orderby x.ProjectCode descending
select x).ToList();
var policy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(Const.CacheMinutes),
};
memoryCache.Set(cacheKey, list, policy);
if (pids == null)
{
return list;
}
else
{
var result = list.Where(e => pids.Contains(e.ProjectId)).ToList();
return result;
}
}
}