using BLL; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web { public partial class index1 : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.userName.InnerText = this.CurrUser.UserName; this.spDate.InnerText = DateTime.Now.ToLongDateString().ToString() + " " + WeekDayService.CaculateWeekDayT(DateTime.Now); var getW = WeatherService.GetWeather(null); if (getW != null) { divWeather.InnerHtml = getW.WeatherRef + " " + getW.CurrTem + "°C"; } ////项目信息 var getProjectLists = getProjectInfo(); ////合同 getHTContract(); ///劳务统计 getSitePerson(); /// 获取安全人工时 getPersonWorkTime(); /// 获取质量问题 getCQMSProblem(); /// 获取施工产值 getOutputValue(getProjectLists); /// 获取风险管控 getHazard(); } } #region 项目信息 protected string ProjectInfo; /// /// 项目信息 /// private List getProjectInfo() { ProjectInfo = "[]"; var getProjects = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null)); this.divProjectNum.InnerHtml = getProjects.Count().ToString(); var getProjectMap = getProjects.Where(x => x.MapCoordinates.Length > 0); if (getProjectMap.Count() > 0) { List list = new List(); foreach (var item in getProjectMap) { Model.SingleSerie newS = new Model.SingleSerie { name = "【项目名称】:" + item.ProjectName //+ "
【项目状态】:" + GetProjectState(item.ProjectId) + "
【开工时间】:" + string.Format("{0:yyyy-MM-dd}", item.StartDate) + "
【竣工时间】:" + string.Format("{0:yyyy-MM-dd}", item.EndDate) + "
【项目地址】:" + item.ProjectAddress, url = "indexProject.aspx?projectId=" + item.ProjectId, cityname = "中国" }; var strMap = Funs.GetStrListByStr(item.MapCoordinates, ','); if (strMap.Count > 1) { newS.value = new[] { Funs.GetNewDecimalOrZero(strMap[0]), Funs.GetNewDecimalOrZero(strMap[1]) }; list.Add(newS); } } ProjectInfo = JsonConvert.SerializeObject(list); } return getProjects.ToList(); } #endregion #region 劳务统计 protected double OnDutyRate; /// /// 劳务统计 /// private void getSitePerson() { OnDutyRate = 0; int AllCount = 0; int MCount = 0; DateTime dateValue = DateTime.Now.AddDays(-1); List getallin = new List(); var getDayAll = from x in Funs.DB.SitePerson_PersonInOut where x.ChangeTime.Value.Year == dateValue.Year && x.ChangeTime.Value.Month == dateValue.Month && x.ChangeTime.Value.Day == dateValue.Day && x.IsIn == true select x; if (getDayAll.Count() > 0) { var getInMaxs = from x in getDayAll select new Model.PageDataPersonInOutItem { PersonId = x.PersonId, PostType = x.PostType, WorkPostId = x.WorkPostId, }; if (getInMaxs.Count() > 0) { getallin = getInMaxs.Distinct().ToList(); } } AllCount = getallin.Count(); if (AllCount > 0) { MCount = getallin.Where(x => x.PostType == Const.PostType_1).Count(); /////管理人数 this.divGLPerson.InnerHtml = MCount.ToString()+ ""; /////作业人数 this.divZYPerson.InnerHtml = (AllCount - MCount).ToString()+ ""; int getPersonCount = Funs.DB.SitePerson_Person.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && !x.OutTime.HasValue && x.AuditorDate.HasValue).Count(); if (getPersonCount > 0) { OnDutyRate = Math.Round(AllCount * 100.0 / getPersonCount, 1); } } } #endregion #region 安全人工时 /// /// 获取安全人工时 /// private void getPersonWorkTime() { int wHours = 0; var getMax = from x in Funs.DB.SitePerson_DayReportDetail join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId select x; if (getMax.Count() > 0) { wHours = Convert.ToInt32(getMax.Sum(x => x.PersonWorkTime) ?? 0); } this.divSafeWorkTime.InnerHtml = wHours.ToString("0000000000"); ///整改单 var getRectify = from x in Funs.DB.Check_RectifyNotices where x.States != Const.State_0 && x.States != null && x.ProjectId != null select x; int allcout = getRectify.Count(); if (allcout > 0) { this.divAllRectify.InnerHtml = allcout.ToString()+ ""; int ccount = getRectify.Where(x => x.States == "5").Count(); this.divRectifyRate.InnerHtml = Math.Round(ccount * 1.0 / allcout * 100, 1).ToString()+ "%"; } } #endregion #region 获取合同 private void getHTContract() { this.divHTNum.InnerHtml = "0"; decimal d = 0; //foreach (var item in getC) //{ // d += item.ContractAmount ?? 0; //} this.divHTAmount.InnerHtml = Math.Round((d / 100000000), 4).ToString(); } #endregion #region 获取质量问题 protected double CRectificationRate; protected double CQualifiedRate; /// /// 获取质量问题 /// private void getCQMSProblem() { ///整改率 CRectificationRate = 0; ///合格率 CQualifiedRate = 0; var getJointCheckDetail = from x in Funs.DB.Check_JointCheckDetail select x; var getCheckControl = from x in Funs.DB.Check_CheckControl select x; ///问题总数 int AllCount = getJointCheckDetail.Count() + getCheckControl.Count(); this.divCQMSAllNum.InnerHtml = AllCount.ToString()+ ""; if (AllCount > 0) { ///问题完成数 var getJOk = getJointCheckDetail.Where(x => x.State == "6").Count(); var getCOk = getCheckControl.Where(x => x.State == "7").Count(); int CCount = getJOk + getCOk; if (CCount > 0) { CRectificationRate = Math.Round(CCount * 1.0 / AllCount * 100, 1); } } //质量共检数据 var inspectionManagements = from x in Funs.DB.ProcessControl_InspectionManagement select x; int a = inspectionManagements.Count(); //验收数据 int b = inspectionManagements.Count(x => x.IsOnceQualified == true); if (a > 0 && b > 0) { CQualifiedRate = Math.Round(b * 1.0 / a * 100, 1); } } #endregion /// /// 进度 /// protected string projectJDHtml; /// /// 月施工计划产值 /// protected string MonthPlanOutPutValue; /// /// 月施工实际产值 /// protected string MonthActualOutPutValue; /// /// 获取当年施工产值 /// private void getOutputValue(List getProjectLists) { MonthPlanOutPutValue = "[0,0,0,0,0,0,0,0,0,0,0,0]"; MonthActualOutPutValue = "[0,0,0,0,0,0,0,0,0,0,0,0]"; projectJDHtml = ""; DateTime date = DateTime.Now.AddYears(-1); var getOutputValue = Funs.DB.Sys_OutputValueProject.Where(x => x.Year > date.Year || (x.Year == date.Year && x.Month >= date.Month)); if (getOutputValue.Count() > 0) { this.divYearPlanOutPutValue.InnerHtml = (getOutputValue.Sum(x => x.PlanOutPutValue ?? 0)).ToString(); this.divYearActualOutPutValue.InnerHtml = (getOutputValue.Sum(x => x.ActualOutPutValue ?? 0)).ToString(); } DateTime dateValue = DateTime.Now.AddMonths(-1).AddDays(-1); var getPersonAll = from x in Funs.DB.SitePerson_Person select x; List getIn = new List(); var getDayAll = from x in Funs.DB.SitePerson_PersonInOut where x.ChangeTime.Value.Year == dateValue.Year && x.ChangeTime.Value.Month == dateValue.Month && x.ChangeTime.Value.Day == dateValue.Day && x.IsIn == true select x; foreach (var item in getProjectLists) { getIn.Clear(); var projectClockIns = getDayAll.Where(x => x.ProjectId == item.ProjectId); if (projectClockIns.Count() > 0) { var getInMaxs = from x in projectClockIns select new Model.PageDataPersonInOutItem { PersonId = x.PersonId, PostType = x.PostType, WorkPostId = x.WorkPostId, }; if (getInMaxs.Count() > 0) { getIn = getInMaxs.Distinct().ToList(); } } var getPersons = getPersonAll.Where(x => x.ProjectId == item.ProjectId && x.IsUsed == true && x.InTime <= dateValue && !x.OutTime.HasValue); string shortName = item.ShortName; string jdRate = "0%"; if (getPersons.Count() > 0 && getIn.Count > 0) { decimal a = Convert.ToDecimal(getIn.Count); decimal b = Convert.ToDecimal(getPersons.Count()); jdRate = Math.Round(a * 100 / b, 1).ToString() + "%"; } projectJDHtml += @"
【在建】" + shortName + "
"; } } #region 安全隐患分析 /// /// 安全隐患分析 /// protected string SafeHiddenDanger { get { List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); Model.SingleSerie s = new Model.SingleSerie(); List listdata = new List(); List list = new List(); businessColumn.title = "安全隐患分析"; var getTypes = from x in Funs.DB.HSSE_Hazard_HazardRegisterTypes select x; var getAllChecks = from x in Funs.DB.HSSE_Hazard_HazardRegister select x; var getChecks = from x in Funs.DB.HSSE_Hazard_HazardRegister group x by x.RegisterTypesId into g select new { g.First().RegisterTypesId, Count = g.Count(x => x.RegisterTypesId == g.First().RegisterTypesId) }; var top5Checks = getChecks.OrderByDescending(x => x.Count).Take(5); int top5Count = 0; string typeName = string.Empty; foreach (var item in top5Checks) { typeName = string.Empty; var type = getTypes.FirstOrDefault(x => x.RegisterTypesId == item.RegisterTypesId); if (type != null) { typeName = type.RegisterTypesName; } list.Add(typeName); listdata.Add(1.0*item.Count); top5Count += item.Count; } list.Add("其他"); listdata.Add(getAllChecks.Count() - top5Count); s.data = listdata; series.Add(s); businessColumn.legend = list; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } #endregion protected string riskData1; protected string riskData2; protected string riskData3; protected string riskData4; #region 风险管控 /// /// 获取风险管控 /// private void getHazard() { var getHazards = from x in Funs.DB.Hazard_HazardSelectedItem join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId select new { x.HazardSelectedItemId, y.RiskLevel }; var riskLevels = from x in Funs.DB.Base_RiskLevel select x; List RiskLevelNum = new List(); List series = new List(); riskData1 = getHazards.Count(x => x.RiskLevel == 1).ToString(); riskData2= getHazards.Count(x => x.RiskLevel == 2).ToString(); riskData3 = getHazards.Count(x => x.RiskLevel == 3).ToString(); riskData4 = getHazards.Count(x => x.RiskLevel == 4).ToString(); } #endregion #region 作业许可数量统计 /// /// 作业许可数量统计 /// protected string License { get { List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); businessColumn.title = "作业许可数量统计"; Model.SingleSerie s = new Model.SingleSerie(); List listdata = new List(); listCategories.Add("动火"); listdata.Add(Funs.DB.License_FireWork.Where(x => x.States == Const.State_3).Count()); listCategories.Add("高处"); listdata.Add(Funs.DB.License_HeightWork.Where(x => x.States == Const.State_3).Count()); listCategories.Add("受限"); listdata.Add(Funs.DB.License_LimitedSpace.Where(x => x.States == Const.State_3).Count()); listCategories.Add("射线"); listdata.Add(Funs.DB.License_RadialWork.Where(x => x.States == Const.State_3).Count()); listCategories.Add("断路"); listdata.Add(Funs.DB.License_OpenCircuit.Where(x => x.States == Const.State_3).Count()); listCategories.Add("动土"); listdata.Add(Funs.DB.License_BreakGround.Where(x => x.States == Const.State_3).Count()); listCategories.Add("夜间"); listdata.Add(Funs.DB.License_NightWork.Where(x => x.States == Const.State_3).Count()); listCategories.Add("吊装"); listdata.Add(Funs.DB.License_LiftingWork.Where(x => x.States == Const.State_3).Count()); s.data = listdata; series.Add(s); businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } #endregion } }