首页优化

This commit is contained in:
李鹏飞 2025-03-18 11:56:52 +08:00
parent 8db8992061
commit 5fa3744594
2 changed files with 127 additions and 73 deletions

View File

@ -16,49 +16,56 @@ namespace BLL
{ {
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{ {
List<Model.PageDataPersonInOutItem> getSiteInOutList = new List<Model.PageDataPersonInOutItem>(); var startDate = dateValue.Date;
var getDayAll = from x in db.SitePerson_PersonInOutNow var endDate = startDate.AddDays(1);
join y in db.SitePerson_Person on x.PersonId equals y.PersonId var query =
join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId from x in db.SitePerson_PersonInOutNow
where x.ProjectId == projectId where x.ChangeTime >= startDate && x.ChangeTime < endDate && x.ProjectId == projectId
&& x.ChangeTime.Value.Year == dateValue.Year group x by new { x.PersonId, x.ProjectId } into g
&& x.ChangeTime.Value.Month == dateValue.Month select new
&& x.ChangeTime.Value.Day == dateValue.Day {
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType }; g.Key.PersonId,
if (getDayAll.Any()) g.Key.ProjectId,
{ MaxChangeTime = g.Max(x => x.ChangeTime)
var getInMaxs = from x in getDayAll };
group x by x.PersonId into g var finalQuery =
select new Model.PageDataPersonInOutItem from record in query
{ join detail in db.SitePerson_PersonInOutNow
PersonId = g.First().PersonId, on new { record.PersonId, record.ProjectId, record.MaxChangeTime }
ChangeTime = g.Max(x => x.ChangeTime), equals new { detail.PersonId, detail.ProjectId, MaxChangeTime = detail.ChangeTime }
IsIn = g.First().IsIn, join y in db.SitePerson_Person on record.PersonId equals y.PersonId
PostType = g.First().PostType join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId
}; where detail.IsIn == true
if (getInMaxs.Any()) select new Model.PageDataPersonInOutItem
{ {
getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList(); PersonId = record.PersonId,
} ProjectId = record.ProjectId,
} ChangeTime = record.MaxChangeTime,
return getSiteInOutList; IsIn = true,
PostType = z.PostType
};
return finalQuery.ToList();
} }
} }
public static List<Model.PageDataPersonInOutItem> getPersonNum(List<string> projectIds, DateTime dateValue) public static List<Model.PageDataPersonInOutItem> getPersonNum(List<string> projectIds, DateTime dateValue)
{ {
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{ {
var startDate = dateValue.Date; var startDate = dateValue.Date;
var endDate = startDate.AddDays(1); var endDate = startDate.AddDays(1);
List<Model.PageDataPersonInOutItem> getSiteInOutList = new List<Model.PageDataPersonInOutItem>(); /* List<Model.PageDataPersonInOutItem> getSiteInOutList = new List<Model.PageDataPersonInOutItem>();
var getDayAll = from x in db.SitePerson_PersonInOutNow var getDayAll = from x in db.SitePerson_PersonInOutNow
join y in db.SitePerson_Person on x.PersonId equals y.PersonId join y in db.SitePerson_Person on x.PersonId equals y.PersonId
join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId
where projectIds.Contains(x.ProjectId) where x.ChangeTime >= startDate &&
&& x.ChangeTime >= startDate &&
x.ChangeTime < endDate x.ChangeTime < endDate
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType,x.ProjectId }; select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType,x.ProjectId };
if (projectIds.Any())
{
getDayAll= getDayAll.Where(x => projectIds.Contains(x.ProjectId));
}
if (getDayAll.Any()) if (getDayAll.Any())
{ {
var getInMaxs = from x in getDayAll var getInMaxs = from x in getDayAll
@ -71,12 +78,43 @@ namespace BLL
IsIn = g.First().IsIn, IsIn = g.First().IsIn,
PostType = g.First().PostType PostType = g.First().PostType
}; };
if (getInMaxs.Any()) getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList();
}*/
var query =
from x in db.SitePerson_PersonInOutNow
where x.ChangeTime >= startDate && x.ChangeTime < endDate
group x by new { x.PersonId, x.ProjectId } into g
select new
{ {
getSiteInOutList = getInMaxs.Where(x => x.IsIn == true).ToList(); g.Key.PersonId,
} g.Key.ProjectId,
} MaxChangeTime = g.Max(x => x.ChangeTime)
return getSiteInOutList; };
if (projectIds.Any())
{
query = query.Where(x => projectIds.Contains(x.ProjectId));
}
var finalQuery =
from record in query
join detail in db.SitePerson_PersonInOutNow
on new { record.PersonId, record.ProjectId, record.MaxChangeTime }
equals new { detail.PersonId, detail.ProjectId, MaxChangeTime = detail.ChangeTime }
join y in db.SitePerson_Person on record.PersonId equals y.PersonId
join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId
where detail.IsIn == true
select new Model.PageDataPersonInOutItem
{
PersonId= record.PersonId,
ProjectId = record.ProjectId,
ChangeTime = record.MaxChangeTime,
IsIn = true,
PostType = z.PostType
};
return finalQuery.ToList();
} }
} }
@ -210,16 +248,17 @@ namespace BLL
{ {
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{ {
DateTime dt1 = dateValue.Date;
DateTime dt2= dateValue.Date.AddDays(1);
List<Model.PageDataPersonInOutItem> getSiteInOutList = new List<Model.PageDataPersonInOutItem>(); List<Model.PageDataPersonInOutItem> getSiteInOutList = new List<Model.PageDataPersonInOutItem>();
var getDayAll = from x in db.SitePerson_PersonInOutNow var getDayAll = from x in db.SitePerson_PersonInOutNow
join y in db.SitePerson_Person on x.PersonId equals y.PersonId join y in db.SitePerson_Person on x.PersonId equals y.PersonId
join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId join z in db.Base_WorkPost on y.WorkPostId equals z.WorkPostId
where x.ChangeTime.Value.Year == dateValue.Year && x.ChangeTime.Value.Month == dateValue.Month where pids.Contains(x.ProjectId) && x.ChangeTime<= dt2 && x.ChangeTime>= dt1
&& x.ChangeTime.Value.Day == dateValue.Day && pids.Contains(x.ProjectId)
select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType }; select new { x.PersonId, x.ChangeTime, x.IsIn, z.PostType };
if (getDayAll.Any()) if (getDayAll.Any())
{ {
var getInMaxs = from x in getDayAll var getInMaxs = from x in getDayAll.ToList()
group x by x.PersonId into g group x by x.PersonId into g
select new Model.PageDataPersonInOutItem select new Model.PageDataPersonInOutItem
{ {

View File

@ -39,7 +39,7 @@ namespace FineUIPro.Web.common
GetHjAsync(), // 焊接 GetHjAsync(), // 焊接
GetGjsxAsync(), // 关键事项 GetGjsxAsync(), // 关键事项
GetSitePersonAsync(), // 人员信息 GetSitePersonAsync(), // 人员信息
GetProjectSitePersonAsync(), // 项目人员图表 //GetProjectSitePersonAsync(), // 项目人员图表
GetJdAsync(), // 进度 GetJdAsync(), // 进度
GetZgsjAsync(), // 整改数据 GetZgsjAsync(), // 整改数据
GetCldhAsync() // 材料到货表格 GetCldhAsync() // 材料到货表格
@ -58,11 +58,11 @@ namespace FineUIPro.Web.common
{ {
var db = Funs.DB; var db = Funs.DB;
pids = !string.IsNullOrEmpty(CurrUser.CompanyProjectId) pids = !string.IsNullOrEmpty(CurrUser.CompanyProjectId)
? CurrUser.CompanyProjectId.Split(',') ? CurrUser.CompanyProjectId.Split(',')
: db.Base_Project : db.Base_Project
.Where(x => x.ProjectState == "1") .Where(x => x.ProjectState == "1")
.Select(x => x.ProjectId) .Select(x => x.ProjectId)
.ToArray(); .ToArray();
//在建项目 //在建项目
if (pids == null) if (pids == null)
{ {
@ -112,7 +112,7 @@ namespace FineUIPro.Web.common
else else
{ {
this.divSafeWorkTimeMonth.InnerHtml = countMonthAqrgs.ToString().Split('.')[0]; this.divSafeWorkTimeMonth.InnerHtml = countMonthAqrgs.ToString().Split('.')[0];
} }
// 安全培训人员(合并数据库查询) // 安全培训人员(合并数据库查询)
var trainingQuery = db.EduTrain_TrainRecord var trainingQuery = db.EduTrain_TrainRecord
.Where(x => pids.Contains(x.ProjectId)) .Where(x => pids.Contains(x.ProjectId))
@ -128,7 +128,7 @@ namespace FineUIPro.Web.common
divSafePersonNum.InnerHtml = trainingQuery != null divSafePersonNum.InnerHtml = trainingQuery != null
? (trainingQuery.TrainCount + trainingQuery.BoShengCount).ToString() ? (trainingQuery.TrainCount + trainingQuery.BoShengCount).ToString()
: "0"; : "0";
@ -137,12 +137,12 @@ namespace FineUIPro.Web.common
.Where(x=> x.IsUsed == true && x.InTime < DateTime.Now && (x.OutTime == null || x.OutTime > DateTime.Now)) .Where(x=> x.IsUsed == true && x.InTime < DateTime.Now && (x.OutTime == null || x.OutTime > DateTime.Now))
.Where(x => pids.Contains(x.ProjectId)) .Where(x => pids.Contains(x.ProjectId))
.Join(db.Base_WorkPost.Where(x => x.IsHsse==true), .Join(db.Base_WorkPost.Where(x => x.IsHsse==true),
person => person.WorkPostId, person => person.WorkPostId,
post => post.WorkPostId, post => post.WorkPostId,
(person, post) => person) (person, post) => person)
.Count(); .Count();
divSafeManagePersonNum.InnerText = safetyStaffCount.ToString(); divSafeManagePersonNum.InnerText = safetyStaffCount.ToString();
}); });
} }
// 质量统计模块封装 // 质量统计模块封装
private async Task BindQualityStatisticsAsync() private async Task BindQualityStatisticsAsync()
@ -150,21 +150,21 @@ namespace FineUIPro.Web.common
await Task.Run(() => { await Task.Run(() => {
var db = Funs.DB; var db = Funs.DB;
// 质量管理人员(合并公司+项目级查询) // 质量管理人员(合并公司+项目级查询)
var qualityQuery = db.Base_WorkPost var qualityQuery = db.Base_WorkPost
.Where(x => x.IsCQMS == true) .Where(x => x.IsCQMS == true)
.GroupJoin(db.SitePerson_Person.Where(x=> x.IsUsed == true), .GroupJoin(db.SitePerson_Person.Where(x=> x.IsUsed == true),
post => post.WorkPostId, post => post.WorkPostId,
person => person.WorkPostId, person => person.WorkPostId,
(post, persons) => new { post, persons }) (post, persons) => new { post, persons })
.SelectMany(x => x.persons.DefaultIfEmpty(), .SelectMany(x => x.persons.DefaultIfEmpty(),
(x, person) => new { x.post, person }) (x, person) => new { x.post, person })
.Where(x => pids.Contains(x.person.ProjectId)); .Where(x => pids.Contains(x.person.ProjectId));
divCqmsManageNum.InnerText = qualityQuery.Count().ToString(); divCqmsManageNum.InnerText = qualityQuery.Count().ToString();
// 质量培训人员 // 质量培训人员
divCqmsPxNum.InnerText = db.Comprehensive_InspectionPerson divCqmsPxNum.InnerText = db.Comprehensive_InspectionPerson
.Where(x => pids.Contains(x.ProjectId)) .Where(x => pids.Contains(x.ProjectId))
.Count(x => x.IsTrain == true).ToString(); .Count(x => x.IsTrain == true).ToString();
}); });
} }
// 项目统计优化 // 项目统计优化
@ -178,16 +178,16 @@ namespace FineUIPro.Web.common
int pcount3 = 0; int pcount3 = 0;
if (acount > 0) if (acount > 0)
{ {
pcount1 = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Count(); pcount1 = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Select( x => x.ProjectId).Count();
var pidzjsg = string.Join(",", allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Select(x => x.ProjectId)).Split(','); var pidzjsg = string.Join(",", allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Select(x => x.ProjectId)).Split(',');
if (pids == null) if (pids == null)
{ {
pcount2 = (from x in Funs.DB.SitePerson_Person where x.IsUsed == true && pidzjsg.Contains(x.ProjectId) select x).Count(); pcount2 = (from x in Funs.DB.SitePerson_Person where x.IsUsed == true && pidzjsg.Contains(x.ProjectId) select x.ProjectId).Count();
} }
else else
{ {
pidzjsg = pids; pidzjsg = pids;
pcount2 = (from x in Funs.DB.SitePerson_Person where x.IsUsed == true && pids.Contains(x.ProjectId) select x).Count(); pcount2 = (from x in Funs.DB.SitePerson_Person where x.IsUsed == true && pids.Contains(x.ProjectId) select x.ProjectId).Count();
} }
pcount3 = Count3(pidzjsg); pcount3 = Count3(pidzjsg);
} }
@ -238,7 +238,7 @@ namespace FineUIPro.Web.common
var datetime2 = d2; var datetime2 = d2;
var getAllPersonInOutList = from x in Funs.DB.SitePerson_PersonInOutNumber var getAllPersonInOutList = from x in Funs.DB.SitePerson_PersonInOutNumber
select x; select new { x.ProjectId, x.InOutDate, x.WorkHours };
if (pids != null) if (pids != null)
{ {
getAllPersonInOutList = getAllPersonInOutList.Where(x => pids.Contains(x.ProjectId)); getAllPersonInOutList = getAllPersonInOutList.Where(x => pids.Contains(x.ProjectId));
@ -353,7 +353,7 @@ namespace FineUIPro.Web.common
return await Task.Run(() => return await Task.Run(() =>
{ {
Model.SingleSerie series = new Model.SingleSerie(); Model.SingleSerie series = new Model.SingleSerie();
var project1s = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).ToList(); var project1s = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Select(x=> new { x.ProjectId, x.ProjectName, x.ProjectState2, x.Province, x.ShortName }).ToList();
var consts = Funs.DB.Sys_Const.Where(x => x.GroupId == ConstValue.GroupId_ProjectState).ToList(); var consts = Funs.DB.Sys_Const.Where(x => x.GroupId == ConstValue.GroupId_ProjectState).ToList();
string name = string.Empty; string name = string.Empty;
if (project1s.Any()) if (project1s.Any())
@ -421,11 +421,11 @@ namespace FineUIPro.Web.common
var accidentList1 = from x in db.Accident_AccidentPersonRecord var accidentList1 = from x in db.Accident_AccidentPersonRecord
join y in db.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId join y in db.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
where y.AccidentTypeName.Contains("未遂") where y.AccidentTypeName.Contains("未遂")
select x; select new { x.ProjectId, x.AccidentDate } ;
var accidentList2 = from x in db.Accident_AccidentReportOther var accidentList2 = from x in db.Accident_AccidentReportOther
join y in db.Sys_Const on x.AccidentTypeId equals y.ConstValue join y in db.Sys_Const on x.AccidentTypeId equals y.ConstValue
where y.ConstText.Contains("未遂") where y.ConstText.Contains("未遂")
select x; select new { x.ProjectId, x.AccidentDate };
var allProvinceProjectList = (from x in allProjects var allProvinceProjectList = (from x in allProjects
join y in provinceDic on x.Province equals y.ProvinceCode join y in provinceDic on x.Province equals y.ProvinceCode
where provinces.Contains(y.CnShortName ) where provinces.Contains(y.CnShortName )
@ -640,7 +640,7 @@ namespace FineUIPro.Web.common
protected int Count3(string[] pids) protected int Count3(string[] pids)
{ {
int cout1 = 0; int cout1 = 0;
cout1 = Funs.DB.Solution_LargerHazard.Where(x => x.States == Const.State_2 && pids.Contains(x.ProjectId)).Count(); cout1 = Funs.DB.Solution_LargerHazard.Count(x => x.States == Const.State_2 && pids.Contains(x.ProjectId));
return cout1; return cout1;
} }
#endregion #endregion
@ -872,11 +872,11 @@ namespace FineUIPro.Web.common
var getallin = new List<Model.PageDataPersonInOutItem>(); var getallin = new List<Model.PageDataPersonInOutItem>();
if (pids == null) if (pids == null)
{ {
getallin = APIPageDataService.getPersonNumByCompany(DateTime.Now); getallin = APIPageDataService.getPersonNum(new List<string>(),DateTime.Now);
} }
else else
{ {
getallin = APIPageDataService.getPersonNumByCompany(DateTime.Now, pids); getallin = APIPageDataService.getPersonNum(pids.ToList(), DateTime.Now);
} }
AllCount = getallin.Count(); AllCount = getallin.Count();
if (AllCount > 0) if (AllCount > 0)
@ -887,6 +887,15 @@ namespace FineUIPro.Web.common
div_xcrs.InnerHtml = AllCount.ToString(); div_xcrs.InnerHtml = AllCount.ToString();
div_zyxcrs.InnerHtml = (AllCount - MCount).ToString(); div_zyxcrs.InnerHtml = (AllCount - MCount).ToString();
div_glxcrs.InnerHtml = MCount.ToString(); div_glxcrs.InnerHtml = MCount.ToString();
//项目现场人员统计
foreach (var item in allProjects)
{
ProjectPersonMc += "'" + item.ShortName + "',";
ProjectPersonCount += "'" + getallin.Count(x => x.ProjectId == item.ProjectId) + "',";
}
ProjectPersonMc = ProjectPersonMc.TrimEnd(',');
ProjectPersonCount = ProjectPersonCount.TrimEnd(',');
}); });
} }
#endregion #endregion
@ -937,10 +946,16 @@ namespace FineUIPro.Web.common
#region #region
protected async Task GetZgsjAsync() protected async Task GetZgsjAsync()
{ {
div_zgsj.InnerHtml = (GetGeneralClosedNum() + GetGeneralNotClosedNum()).ToString(); await Task.Run(() =>
div_zgywc.InnerHtml = GetGeneralClosedNum().ToString(); {
div_zgwwc.InnerHtml = GetGeneralNotClosedNum().ToString(); int GeneralClosedNum = GetGeneralClosedNum();
div_zgwcl.InnerHtml = (100.0 * GetGeneralClosedNum() / (GetGeneralNotClosedNum() + GetGeneralClosedNum())).ToString("0.##") + "%"; int GeneralNotClosedNum = GetGeneralNotClosedNum();
div_zgsj.InnerHtml = (GeneralClosedNum + GeneralNotClosedNum).ToString();
div_zgywc.InnerHtml = GeneralClosedNum.ToString();
div_zgwwc.InnerHtml = GeneralNotClosedNum.ToString();
div_zgwcl.InnerHtml = (100.0 * GeneralClosedNum / (GeneralNotClosedNum + GeneralClosedNum)).ToString("0.##") + "%";
});
} }
/// <summary> /// <summary>