大屏优化

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

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();
}

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>

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

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)
{
string cacheKey = "allProjects";
var memoryCache = MemoryCache.Default;
if (memoryCache.Get(cacheKey) != null)
{
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 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 list = (from x in Funs.DB.Base_Project
where pids.Contains(x.ProjectId)
orderby x.ProjectCode descending
select x).ToList();
return list;
var result = list.Where(e => pids.Contains(e.ProjectId)).ToList();
return result;
}
}
}

View File

@ -128,6 +128,7 @@
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.Management" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">

View File

@ -1,4 +1,4 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mainProject2.aspx.cs" Inherits="FineUIPro.Web.common.mainProject2" %>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="mainProject2.aspx.cs" Inherits="FineUIPro.Web.common.mainProject2" Async="true" %>
<!DOCTYPE html>
@ -84,11 +84,11 @@
<div class="yj-bars">
<div class="yj-bar">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,Quawarning %>" /></div>
<div class="num"><%=getEarlyWarningCounts() %></div>
<div class="num"><%=EarlyWarningCounts %></div>
</div>
<div class="yj-bar">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,MechanicalWarning %>" /></div>
<div class="num"><%=GetJxyjNum() %></div>
<div class="num"><%=JxyjNum %></div>
</div>
</div>
<div class="wd-box">
@ -96,22 +96,22 @@
<div class="inner">
<div class="inner-box">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,ApprovalCompleted %>" /></div>
<div class="num"><%=GetCompletedNum() %></div>
<div class="num"><%=CompletedNum %></div>
</div>
<span></span>
<div class="inner-box">
<div class="lab" style="width: 1rem"><asp:Literal runat="server" Text="<%$ Resources:Lan,NumberOfTrainees %>" /></div>
<div class="num"><%=GetTrainPersonNum() %></div>
<div class="num"><%=TrainPersonNum %></div>
</div>
<span></span>
<div class="inner-box">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,NumberOfConstructions %>" /></div>
<div class="num"><%=GetConstructionNum() %></div>
<div class="num"><%=ConstructionNum %></div>
</div>
<span></span>
<div class="inner-box">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,NumberOfCompletions %>" /></div>
<div class="num"><%=GetFinishedNum() %></div>
<div class="num"><%=FinishedNum %></div>
</div>
</div>
</div>
@ -120,22 +120,22 @@
<div class="inner">
<div class="inner-box">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,ApprovalCompleted %>" /></div>
<div class="num"><%=GetSuperCompletedNum() %></div>
<div class="num"><%=SuperCompletedNum %></div>
</div>
<span></span>
<div class="inner-box">
<div class="lab" style="width: 1rem;"><asp:Literal runat="server" Text="<%$ Resources:Lan,NumberOfTrainees %>" /></div>
<div class="num"><%=GetSuperTrainPersonNum() %></div>
<div class="num"><%=SuperTrainPersonNum %></div>
</div>
<span></span>
<div class="inner-box">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,NumberOfConstructions %>" /></div>
<div class="num"><%=GetSuperConstructionNum() %></div>
<div class="num"><%=SuperConstructionNum %></div>
</div>
<span></span>
<div class="inner-box">
<div class="lab"><asp:Literal runat="server" Text="<%$ Resources:Lan,NumberOfCompletions %>" /></div>
<div class="num"><%=GetSuperFinishedNum() %></div>
<div class="num"><%=SuperFinishedNum %></div>
</div>
</div>
</div>

File diff suppressed because it is too large Load Diff

View File

@ -6,10 +6,12 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Org.BouncyCastle.Ocsp;
namespace FineUIPro.Web.common
{
@ -145,6 +147,8 @@ namespace FineUIPro.Web.common
// 质量统计模块封装
private async Task BindQualityStatisticsAsync()
{
await Task.Run(() => {
var db = Funs.DB;
// 质量管理人员(合并公司+项目级查询)
var qualityQuery = db.Base_WorkPost
@ -161,13 +165,13 @@ namespace FineUIPro.Web.common
divCqmsPxNum.InnerText = db.Comprehensive_InspectionPerson
.Where(x => pids.Contains(x.ProjectId))
.Count(x => x.IsTrain == true).ToString();
});
}
// 项目统计优化
private async Task BindProjectStatisticsAsync()
{
await Task.Run(() => {
var db = Funs.DB;
int acount = allProjects.Count();
int pcount1 = 0;
int pcount2 = 0;
@ -190,6 +194,7 @@ namespace FineUIPro.Web.common
div_zjxmCount.InnerHtml = pcount1.ToString() + "<div class=\"th\">个</div>";
div_cjrsCount.InnerHtml = pcount2.ToString() + "<div class=\"th\">人</div>";
div_wdgcCount.InnerHtml = pcount3.ToString() + "<div class=\"th\">个</div>";
});
}
@ -304,7 +309,7 @@ namespace FineUIPro.Web.common
var getAllPersonInOutList = from x in db.SitePerson_PersonInOutNumber
select x;
if (getAllPersonInOutList.Count() > 0)
if (getAllPersonInOutList.Any())
{
var getInMonths = (from x in getAllPersonInOutList select new { x.InOutDate.Year, x.InOutDate.Month }).Distinct();
if (sDate.HasValue)
@ -348,10 +353,10 @@ namespace FineUIPro.Web.common
return await Task.Run(() =>
{
Model.SingleSerie series = new Model.SingleSerie();
var project1s = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null);
var consts = Funs.DB.Sys_Const.Where(x => x.GroupId == ConstValue.GroupId_ProjectState);
var project1s = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).ToList();
var consts = Funs.DB.Sys_Const.Where(x => x.GroupId == ConstValue.GroupId_ProjectState).ToList();
string name = string.Empty;
if (project1s.Count() > 0)
if (project1s.Any())
{
foreach (var project1 in project1s)
{
@ -432,7 +437,7 @@ namespace FineUIPro.Web.common
select x;
listdata.Add(projects.Count());
decimal progress = 0;
if (projects.Count() > 0)
if (projects.Any())
{
convert.Add(province);
foreach (var item in projects)
@ -570,7 +575,6 @@ namespace FineUIPro.Web.common
return await Task.Run(() =>
{
Model.SingleSerie series = new Model.SingleSerie();
var project1s = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null);
Model.SGGLDB db = Funs.DB;
string str = string.Empty;
foreach (var item in allProjects)
@ -871,7 +875,7 @@ namespace FineUIPro.Web.common
AllCount = getallin.Count();
if (AllCount > 0)
{
MCount = getallin.Where(x => x.PostType == Const.PostType_1).Count();
MCount = getallin.Count(x => x.PostType == Const.PostType_1);
}
div_xcrs.InnerHtml = AllCount.ToString();
@ -888,20 +892,13 @@ namespace FineUIPro.Web.common
{
await Task.Run(() =>
{
var list = new List<Model.Base_Project>();
if (pids == null)
{
list = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null)).ToList();
}
else
{
list = Funs.DB.Base_Project.Where(x => pids.Contains(x.ProjectId)).ToList();
}
var allperson =
APIPageDataService.getPersonNum(allProjects.Select(x => x.ProjectId).ToList(), DateTime.Now);
foreach (var item in list)
foreach (var item in allProjects)
{
ProjectPersonMc += "'" + item.ShortName + "',";
ProjectPersonCount += "'" + APIPageDataService.getPersonNum(item.ProjectId, DateTime.Now).Count() + "',";
ProjectPersonCount += "'" + allperson.Count(x=>x.ProjectId==item.ProjectId) + "',";
}
ProjectPersonMc = ProjectPersonMc.TrimEnd(',');
ProjectPersonCount = ProjectPersonCount.TrimEnd(',');
@ -914,21 +911,14 @@ namespace FineUIPro.Web.common
protected string ProjectMc;
protected async Task GetJdAsync()
{
var list = new List<Model.Base_Project>();
if (pids == null)
{
list = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null)).ToList();
}
else
{
list = Funs.DB.Base_Project.Where(x => pids.Contains(x.ProjectId)).ToList();
}
if (list.Count > 0)
var list = allProjects;
if (list.Any())
{
var progressCompletions = from x in Funs.DB.JDGL_ProgressCompletion select x ;
foreach (var item in list)
{
var pCs = progressCompletions.Where(x => x.ProjectId == item.ProjectId).ToList();
ProjectJd += "'" + pCs.Sum(x => x.RealNum ?? 0).ToString("0.##") + "',";
ProjectMc += "'" + item.ShortName + "',";
}
@ -1001,15 +991,7 @@ namespace FineUIPro.Web.common
protected string sbclHead = "<div class=\"th-p\">项目</div><div class=\"th-p\">采购量</div><div class=\"th-p\">到货量</div><div class=\"th-p\">已到货百分比</div>";
private async Task GetCldhAsync()
{
var list = new List<Model.Base_Project>();
if (pids == null)
{
list = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null)).ToList();
}
else
{
list = Funs.DB.Base_Project.Where(x => pids.Contains(x.ProjectId)).ToList();
}
var list = allProjects;
var PipelinList = Funs.DB.CLGL_PipelineMaterialSumList.Where(x => x.Type == "M");
var SbclList = Funs.DB.CLGL_ContractListSum.Where(x => x.C1 == "设备");
foreach (var item in list)
@ -1025,7 +1007,7 @@ namespace FineUIPro.Web.common
gdclHtml += "<div class=\"th-p\" title =\"" + item.ShortName + "\">" + pname + "</div>";
var pid = BLL.ProjectService.GetCLProjectCodeByProjectId(item.ProjectId).ToString();
//管子
var num1 = PipelinList.Where(x => x.ProjectId == pid && x.C1 == "管子").FirstOrDefault();
var num1 = PipelinList.FirstOrDefault(x => x.ProjectId == pid && x.C1 == "管子");
if (num1 != null)
{
gdclHtml += "<div class=\"th-p\">" + (num1.C7 == "" ? "0%" : num1.C7) + "</div>";
@ -1128,23 +1110,38 @@ namespace FineUIPro.Web.common
/// <returns></returns>
private int GetNearMissNum()
{
string cacheKey = "NearMissNum_" + string.Join("_",pids);
var memoryCache = MemoryCache.Default;
if (memoryCache.Get(cacheKey) != null)
{
return (int)memoryCache.Get(cacheKey);
}
int result = 0;
if (pids == null)
{
var result = (from x in Funs.DB.Accident_AccidentPersonRecord
result = (from x in Funs.DB.Accident_AccidentPersonRecord
join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
where x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime
select x).Count();
return result;
}
else
{
var result = (from x in Funs.DB.Accident_AccidentPersonRecord
result = (from x in Funs.DB.Accident_AccidentPersonRecord
join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
where x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime
&& pids.Contains(x.ProjectId)
select x).Count();
}
var policy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(Const.CacheMinutes),
};
memoryCache.Set(cacheKey, result, policy);
return result;
}
}
}
}

View File

@ -9,6 +9,7 @@
<package id="RestSharp" version="106.15.0" targetFramework="net461" />
<package id="SharpZipLib" version="1.3.2" targetFramework="net461" />
<package id="System.Configuration.ConfigurationManager" version="6.0.1" targetFramework="net461" />
<package id="System.Runtime.Caching" version="6.0.0" targetFramework="net461" />
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net461" />
<package id="System.Security.Permissions" version="6.0.0" targetFramework="net461" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net461" />

View File

@ -12,7 +12,11 @@ namespace Model
get;
set;
}
public string ProjectId
{
get;
set;
}
public DateTime? ChangeTime
{
get;