using BLL; using FineUIPro.Web.DataShow; using Newtonsoft.Json; using NPOI.SS.Util; using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.common { public partial class main3 : PageBase { public string PassRate { get { return (string)ViewState["PassRate"]; } set { ViewState["PassRate"] = value; } } ///合格率 protected double CheckControlRate; protected double CQualifiedRate; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Model.SGGLDB db = Funs.DB; this.divMajorProjectsUnderConstructionNum.InnerHtml = (from x in db.Solution_LargerHazard where x.States == "2" && x.RecordTime > Const.DtmarkTime select x).Count().ToString(); ////项目信息 getProjectInfo(db); getPersonWorkTime(db); //getSitePerson(db); getCQMSProblem(db); string strSql = ""; strSql = @"select SUM(cht_totalfilm) AS current_total_film , SUM(cht_passfilm) AS current_pass_film from CH_CheckItem ch_checkitem left join PW_JointInfo JointInfo on JointInfo.JOT_ID = ch_checkitem.JOT_ID"; // SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql); if (tb != null && tb.Rows.Count > 0) { try { var rate = 100 * double.Parse(tb.Rows[0]["current_pass_film"].ToString()) / double.Parse(tb.Rows[0]["current_total_film"].ToString()); PassRate = "" + ((int)rate); } catch (Exception ex) { PassRate = "0"; } } var checkControls = from x in Funs.DB.Check_CheckControl select x; int a = checkControls.Count(); divCheckControlAllNum.InnerHtml = a.ToString(); int b = checkControls.Count(x => x.State == BLL.Const.CheckControl_Complete); divCheckControlOKNum.InnerHtml = b.ToString(); divCheckControlNotOKNum.InnerHtml = (checkControls.Count() - checkControls.Count(x => x.State == BLL.Const.CheckControl_Complete)).ToString(); CheckControlRate = 0; if (a > 0) { CheckControlRate = Math.Round(b * 1.0 / a * 100, 1); } //整改率、合格率、焊接一次合格率 getRate(); } } #region 项目信息 protected string ProjectInfo; /// /// 项目信息 /// private List getProjectInfo(Model.SGGLDB db) { ProjectInfo = "[]"; var getProjects = db.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null) && (x.IsDelete == null || x.IsDelete == false)); string picHtml = ""; var getP = from x in db.InformationProject_Picture join y in db.AttachFile on x.PictureId equals y.ToKeyId where y.AttachFileId != null && y.AttachUrl != null orderby x.UploadDate descending select new { x.PictureId, x.Title, x.UploadDate, y.AttachUrl }; if (getP.Count() > 0) { foreach (var item in getP) { var geturl = Funs.GetStrListByStr(item.AttachUrl, ','); foreach (var itemurl in geturl) { if (!string.IsNullOrEmpty(itemurl)) { picHtml += @"
"; } } } } foreach (var p in getProjects) { try { string res = AttachFileService.getFileUrl(p.ProjectId, BLL.Const.SeverProjectSetMenuId); string[] urls = res.Split(','); foreach (string u in urls) { if (!string.IsNullOrEmpty(u)) { picHtml += @"
"; } } } catch (Exception ex) { } } divProjectPic.InnerHtml = picHtml; var array = new DecimalFormat(",###").Format(getProjects.Count()).ToArray(); string projectNum = ""; foreach (var s in array) { if (s != ',') { projectNum += "" + s + ""; } else { projectNum += "" + s + ""; } } this.divProjectNum.InnerHtml = projectNum; var persons = from x in db.SitePerson_Person join y in db.Base_Project on x.ProjectId equals y.ProjectId where x.IsUsed == true && (x.OutTime == null || x.OutTime > DateTime.Now) && (y.ProjectState == Const.ProjectState_1 || y.ProjectState == null) && (y.IsDelete == null || y.IsDelete == false) select x; var array2 = new DecimalFormat(",###").Format(persons.Count()).ToArray(); string personsNum = ""; foreach (var s in array2) { if (s != ',') { personsNum += "" + s + ""; } else { personsNum += "" + s + ""; } } this.divJoinConstructionPersonNum.InnerHtml = personsNum; 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 = "【" + Resources.Lan.ProjectName + "】:" + item.ProjectName //+ "
【项目状态】:" + GetProjectState(item.ProjectId) + "
【" + Resources.Lan.Start_time + "】:" + string.Format("{0:yyyy-MM-dd}", item.StartDate) + "
【" + Resources.Lan.TimeCompletion + "】:" + string.Format("{0:yyyy-MM-dd}", item.EndDate) + "
【" + Resources.Lan.ProjectAddress + "】:" + item.ProjectAddress + "@" + "indexProject.aspx?projectId=" + item.ProjectId, //url = "indexProject.aspx?projectId=" + item.ProjectId, cityname = Resources.Lan.China }; 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 安全人工时 /// /// 获取安全人工时 /// private void getPersonWorkTime(Model.SGGLDB db) { int wHours = 0; var getMax = from x in db.SitePerson_DayReportDetail join y in 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"); } #endregion #region 劳务统计 /// /// 劳务统计 /// private void getSitePerson(Model.SGGLDB db) { int AllCount = 0; int MCount = 0; DateTime dateValue = DateTime.Now.AddDays(-1); List getallin = new List(); var getDayAll = from x in 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();*/ } } #endregion /// /// 获取质量问题 /// private void getCQMSProblem(Model.SGGLDB db) { CQualifiedRate = 0; var imids = db.ProcessControl_InspectionManagementDetail.Select(y => y.InspectionId).Distinct(); var inspectionManagements = from x in db.ProcessControl_InspectionManagement where imids.Contains(x.InspectionId) select x; if (inspectionManagements.Count() > 0) { int okInspectionManagements = inspectionManagements.Where(x => x.IsOnceQualified == true).Count(); if (okInspectionManagements > 0) { CQualifiedRate = Math.Round(okInspectionManagements * 1.0 / inspectionManagements.Count() * 100, 1); } } } protected string VideoURL { get { string username = ConfigurationManager.AppSettings["Video_USER"]; string password = ConfigurationManager.AppSettings["Video_PW"]; return ConfigurationManager.AppSettings["Video_URL"] + "#/screen?username=" + username + "&password=" + Funs.EncryptionPassword(password); } } #region 安全隐患分析 /// /// 安全隐患分析 /// protected string SafeHiddenDanger { get { List series = new List(); Model.SingleSerie s = new Model.SingleSerie(); List listdata = new List(); List list = new List(); 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(item.Count); top5Count += item.Count; } //list.Add("其他"); //listdata.Add(getAllChecks.Count() - top5Count); s.data = listdata; List> res = new List>(); for (int i = 0; i < list.Count() && i < 5; i++) { Dictionary temp = new Dictionary(); temp.Add("name", list[i]); temp.Add("value", listdata[i]); res.Add(temp); } return JsonConvert.SerializeObject(res); } } #endregion protected string VideoHost { get { string video_Url = ConfigurationManager.AppSettings["Video_URL"]; return video_Url; } } protected string VideoPassWord { get { string video_PassWord = string.Empty; var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == "aedadae4-ed77-4b5a-b1ed-6b8b3c075988"); if (project != null) { if (!string.IsNullOrEmpty(project.MonitorPW)) { video_PassWord = Funs.EncryptionPassword(project.MonitorPW); } } return video_PassWord; } } protected string VideoUserName { get { string video_UserName = string.Empty; var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == "aedadae4-ed77-4b5a-b1ed-6b8b3c075988"); if (project != null) { video_UserName = project.ProjectCode; } return video_UserName; } } /// /// 整改率、合格率、焊接一次合格率 /// protected string RectificationRate = string.Empty; protected string PassRates = string.Empty; protected string FistPassRateWelding = string.Empty; private void getRate() { RectificationRate = Resources.Lan.RectificationRate; PassRates = Resources.Lan.PassRate; FistPassRateWelding = Resources.Lan.FistPassRateWelding; } } }