首页优化

This commit is contained in:
李鹏飞 2025-03-13 15:41:27 +08:00
parent c6783807ff
commit 70707cac4e
12 changed files with 524 additions and 349 deletions

View File

@ -20,7 +20,9 @@ namespace BLL
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 x.ProjectId == projectId && x.ChangeTime.Value.Year == dateValue.Year && x.ChangeTime.Value.Month == dateValue.Month
where x.ProjectId == projectId
&& 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)

View File

@ -1078,7 +1078,7 @@
<Version>2.1.1</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.1</Version>
<Version>13.0.1</Version>
</PackageReference>
<PackageReference Include="NPOI">
<Version>2.5.5</Version>

View File

@ -19655,7 +19655,7 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v17.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1,6 +1,8 @@
using BLL;
using Model;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
@ -17,7 +19,7 @@ namespace FineUIPro.Web.common
public string[] pids { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
/* if (!IsPostBack)
{
Model.SGGLDB db = Funs.DB;
if (!string.IsNullOrEmpty(CurrUser.CompanyProjectId))
@ -36,18 +38,9 @@ namespace FineUIPro.Web.common
//未遂事故
var wsAccidentList1 = from x in db.Accident_AccidentPersonRecord
join y in db.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
where y.AccidentTypeName.Contains("未遂")
select x;
var wsAccidentList2 = from x in db.Accident_AccidentReportOther
join y in db.Sys_Const on x.AccidentTypeId equals y.ConstValue
where y.ConstText.Contains("未遂")
select x;
this.divWS.InnerHtml = GetNearMissNum().ToString();
//安全人工时
int wHours = db.SitePerson_PersonInOutNumber.Max(x => x.WorkHours) ?? 0;
var countAqrgsSum = Convert.ToDecimal(0);
if (pids == null)
{
@ -255,8 +248,185 @@ namespace FineUIPro.Web.common
//材料到货表格
getCldh();
}
*/
if (!IsPostBack)
{
InitializeProjectIds(); // 项目ID初始化封装
BindSafetyStatistics(); // 安全统计模块
BindQualityStatistics(); // 质量统计模块
BindProjectStatistics(); // 项目统计模块
getZlwt();
//质量共检
getZlgj();
//焊接
getHj();
//关键事项
getGjsx();
//人员信息
getSitePerson();
//项目人员图表
getProjectSitePerson();
//进度
getJd();
//整改数据
getZgsj();
//材料到货表格
getCldh();
}
}
// 初始化项目ID集合
private void InitializeProjectIds()
{
var db = Funs.DB;
pids = !string.IsNullOrEmpty(CurrUser.CompanyProjectId)
? CurrUser.CompanyProjectId.Split(',')
: db.Base_Project
.Where(x => x.ProjectState == "1")
.Select(x => x.ProjectId)
.ToArray();
}
// 安全统计模块封装
private void BindSafetyStatistics()
{
var db = Funs.DB;
// 未遂事故
divWS.InnerHtml = GetNearMissNum().ToString();
// 安全人工时(合并重复逻辑)
var countAqrgsSum = pids?.Any() == true
? CountAqrgs(d1: null, d2: null, pids)
: CountAqrgs();
if (countAqrgsSum > 10000)
{
countAqrgsSum = countAqrgsSum / Convert.ToDecimal(10000.00);
this.divSafeWorkTime.InnerHtml = Math.Round(countAqrgsSum, 2).ToString() + "万";
}
else
{
this.divSafeWorkTime.InnerHtml = countAqrgsSum.ToString().Split('.')[0];
}
// 当月安全人工时
var countMonthAqrgs = pids?.Any() == true
? CountAqrgs(getStartMonth(), getEndMonth(), pids)
: CountAqrgs(getStartMonth(), getEndMonth());
if (countMonthAqrgs > 10000)
{
countMonthAqrgs = countMonthAqrgs / Convert.ToDecimal(10000.00);
this.divSafeWorkTimeMonth.InnerHtml = Math.Round(countMonthAqrgs, 2).ToString() + "万";
}
else
{
this.divSafeWorkTimeMonth.InnerHtml = countMonthAqrgs.ToString().Split('.')[0];
}
// 安全培训人员(合并数据库查询)
var trainingQuery = db.EduTrain_TrainRecord
.Where(x => pids.Contains(x.ProjectId))
.GroupBy(x => 1)
.Select(g => new {
TrainCount = g.Sum(x => x.TrainPersonNum) ?? 0,
BoShengCount = db.Bo_Sheng_TrainPerson
.Where(x => (x.DeleteTag == "False" || x.DeleteTag == null))
.Where(x => pids.Contains(x.ProjectId))
.Count()
}).FirstOrDefault();
divSafePersonNum.InnerHtml = trainingQuery != null
? (trainingQuery.TrainCount + trainingQuery.BoShengCount).ToString()
: "0";
// 安全管理人员(优化关联查询)
var safetyStaffCount = db.SitePerson_Person
.Where(x=> x.IsUsed == true && x.InTime < DateTime.Now && (x.OutTime == null || x.OutTime > DateTime.Now))
.Where(x => pids.Contains(x.ProjectId))
.Join(db.Base_WorkPost.Where(x => x.IsHsse==true),
person => person.WorkPostId,
post => post.WorkPostId,
(person, post) => person)
.Count();
divSafeManagePersonNum.InnerText = safetyStaffCount.ToString();
}
// 质量统计模块封装
private void BindQualityStatistics()
{
var db = Funs.DB;
// 质量管理人员(合并公司+项目级查询)
var qualityQuery = db.Base_WorkPost
.Where(x => x.IsCQMS == true)
.GroupJoin(db.SitePerson_Person.Where(x=> x.IsUsed == true),
post => post.WorkPostId,
person => person.WorkPostId,
(post, persons) => new { post, persons })
.SelectMany(x => x.persons.DefaultIfEmpty(),
(x, person) => new { x.post, person })
.Where(x => pids.Contains(x.person.ProjectId));
divCqmsManageNum.InnerText = qualityQuery.Count().ToString();
// 质量培训人员
divCqmsPxNum.InnerText = db.Comprehensive_InspectionPerson
.Where(x => pids.Contains(x.ProjectId))
.Count(x => x.IsTrain == true).ToString();
}
// 项目统计优化
private void BindProjectStatistics()
{
var db = Funs.DB;
//在建项目
if (pids == null)
{
allProjects = ProjectService.GetAllProjectDropDownList();
}
else
{
allProjects = ProjectService.GetAllProjectDropDownList(pids);
}
int acount = allProjects.Count();
int pcount1 = 0;
int pcount2 = 0;
int pcount3 = 0;
if (acount > 0)
{
pcount1 = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Count();
var pidzjsg = string.Join(",", allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Select(x => x.ProjectId)).Split(',');
if (pids == null)
{
pcount2 = (from x in Funs.DB.SitePerson_Person where x.IsUsed == true && pidzjsg.Contains(x.ProjectId) select x).Count();
}
else
{
pidzjsg = pids;
pcount2 = (from x in Funs.DB.SitePerson_Person where x.IsUsed == true && pids.Contains(x.ProjectId) select x).Count();
}
pcount3 = Count3(pidzjsg);
}
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>";
}
#region
@ -300,12 +470,8 @@ namespace FineUIPro.Web.common
select x;
if (pids != null)
{
getAllPersonInOutList = from x in Funs.DB.SitePerson_PersonInOutNumber
where pids.Contains(x.ProjectId)
select x;
getAllPersonInOutList = getAllPersonInOutList.Where(x => pids.Contains(x.ProjectId));
}
if (getAllPersonInOutList.Count() > 0)
{
if (datetime1.HasValue)
{
getAllPersonInOutList = getAllPersonInOutList.Where(x => x.InOutDate >= datetime1);
@ -314,20 +480,18 @@ namespace FineUIPro.Web.common
{
getAllPersonInOutList = getAllPersonInOutList.Where(x => x.InOutDate <= datetime2);
}
if (getAllPersonInOutList.Count() > 0)
var projects = getAllPersonInOutList
.GroupBy(x => x.ProjectId)
.Select(g => new
{
//cout1 = getAllPersonInOutList.Sum(x => (long)x.WorkHours);
foreach (var pid in pids)
{
var q1 = getAllPersonInOutList.Where(x => x.ProjectId == pid).OrderByDescending(x => x.InOutDate);
var q2 = getAllPersonInOutList.Where(x => x.ProjectId == pid).OrderBy(x => x.InOutDate);
if (q1.Count() > 0)
{
cout1 += (q1.First().WorkHours ?? 0) - (q2.First().WorkHours ?? 0);
}
}
}
}
Project = g.Key,
Items = g.OrderBy(x => x.InOutDate).ToList()
})
.Where(g => g.Items.Any());
cout1 = projects.ToList().Sum(g =>
(g.Items.Last().WorkHours ?? 0) -
(g.Items.First().WorkHours ?? 0));
var getD1 = from x in Funs.DB.Accident_AccidentHandle
join y in Funs.DB.Base_Project on x.ProjectId equals y.ProjectId
@ -340,16 +504,9 @@ namespace FineUIPro.Web.common
if (pids != null)
{
getD1 = from x in Funs.DB.Accident_AccidentHandle
join y in Funs.DB.Base_Project on x.ProjectId equals y.ProjectId
where pids.Contains(x.ProjectId)
select x;
getD2 = from x in Funs.DB.Accident_AccidentReport
join y in Funs.DB.Base_Project on x.ProjectId equals y.ProjectId
where pids.Contains(x.ProjectId)
select x;
getD1 = getD1.Where(x => pids.Contains(x.ProjectId));
getD2 = getD2.Where(x => pids.Contains(x.ProjectId));
}
if (datetime1.HasValue)
{
getD1 = getD1.Where(x => x.AccidentDate >= datetime1);
@ -360,19 +517,16 @@ namespace FineUIPro.Web.common
getD1 = getD1.Where(x => x.AccidentDate <= datetime2);
getD2 = getD2.Where(x => x.CompileDate <= datetime2);
}
if (getD1.Count() > 0)
if (getD1.Any())
{
cout1 = cout1 - getD1.Sum(x => x.WorkHoursLoss ?? 0);
}
if (getD2.Count() > 0)
if (getD2.Any())
{
cout1 = cout1 - getD2.Sum(x => x.WorkingHoursLoss ?? 0);
}
return cout1;
}
/// <summary>
/// 获取出入记录人工时-月报(项目级别)
/// </summary>
@ -823,10 +977,29 @@ namespace FineUIPro.Web.common
var ndtLists = from x in db.ProcessControl_NondestructiveTest_New where x.ProfessionalName == "工艺管道" select x;
if (pids != null)
{
ndtLists = from x in db.ProcessControl_NondestructiveTest_New where x.ProfessionalName == "工艺管道" && pids.Contains(x.ProjectId) select x;
ndtLists = ndtLists.Where(x=>pids.Contains(x.ProjectId));
}
decimal a = 0, b = 0;
if (ndtLists.Count() > 0)
var sumResult = ndtLists
.GroupBy(x => x.ProjectId)
.Select(g => new {
TotalQ = g.OrderByDescending(x => x.CreateDate)
.Select(x => x.TotalQuantity)
.FirstOrDefault(),
Rate = g.OrderByDescending(x => x.CreateDate)
.Select(x => x.TotalRate)
.FirstOrDefault()
})
.Where(x => x.TotalQ.HasValue).ToList()
.Select(x => new {
A = Math.Floor(x.TotalQ.Value * (decimal.Parse(x.Rate)) / 100),
B = x.TotalQ.Value
});
a = sumResult.Sum(x=>x.A);
b = sumResult.Sum(x => x.B);
/* if (ndtLists.Count() > 0)
{
foreach (var project in allProjects)
{
@ -843,7 +1016,7 @@ namespace FineUIPro.Web.common
}
}
}
}
}*/
if (b > 0)
{
result = Convert.ToDouble(decimal.Round(decimal.Parse((a / b * 100).ToString()), 2));

View File

@ -37,8 +37,8 @@
<Reference Include="AOP.Common">
<HintPath>..\FineUIPro\Reference BLL\AOP.Common.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Baidu.AI" version="4.15.9" targetFramework="net45" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
</packages>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细信息,请访问
https://go.microsoft.com/fwlink/?LinkId=301879
@ -46,7 +46,7 @@
</system.Web>
-->
<system.web>
<compilation debug="false" targetFramework="4.6.1"/>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime />
<pages controlRenderingCompatibilityVersion="4.0" />
</system.web>
@ -86,7 +86,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35" />

View File

@ -54,8 +54,8 @@
<HintPath>..\packages\Aspose.Words.24.12.0\lib\net461\Aspose.Words.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Swashbuckle.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cd1bb07a5ac7c7bc, processorArchitecture=MSIL">
<HintPath>..\packages\Swashbuckle.Core.5.6.0\lib\net40\Swashbuckle.Core.dll</HintPath>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>

View File

@ -25,7 +25,7 @@
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net461" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
<package id="Modernizr" version="2.8.3" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
<package id="Swashbuckle" version="5.6.0" targetFramework="net461" />
<package id="Swashbuckle.Core" version="5.6.0" targetFramework="net461" />
<package id="System.Data.DataSetExtensions" version="4.5.0" targetFramework="net461" />