diff --git a/SGGL/FineUIPro.Web/common/main.aspx.cs b/SGGL/FineUIPro.Web/common/main.aspx.cs index 71dc1758..8859fce1 100644 --- a/SGGL/FineUIPro.Web/common/main.aspx.cs +++ b/SGGL/FineUIPro.Web/common/main.aspx.cs @@ -98,31 +98,56 @@ namespace FineUIPro.Web.common // } //} - string sql = @"select c.ConstText,b.PostType,count( *) num from SitePerson_Person a left join Base_WorkPost b on a.WorkPostId=b.WorkPostId - LEFT JOIN Sys_Const AS c ON c.ConstValue = b.PostType and c.GroupId = 'PostType' where IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' ) - and AuditorDate is not null - group by c.ConstText,b.PostType "; - List listStr = new List(); - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter); - int allcount = 0; - int mcount = 0; - if (tb != null) - { - foreach (DataRow row in tb.Rows) - { - allcount += int.Parse(row["num"].ToString()); - if (!string.IsNullOrEmpty(row["ConstText"].ToString()) && row["ConstText"].ToString().Contains("管理")) - { - mcount += int.Parse(row["num"].ToString()); - } - } - } + //string sql = @"select c.ConstText,b.PostType,count( *) num from SitePerson_Person a left join Base_WorkPost b on a.WorkPostId=b.WorkPostId + // LEFT JOIN Sys_Const AS c ON c.ConstValue = b.PostType and c.GroupId = 'PostType' where IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' ) + // and AuditorDate is not null + // group by c.ConstText,b.PostType "; + //List listStr = new List(); + //SqlParameter[] parameter = listStr.ToArray(); + //DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter); + //int allcount = 0; + //int mcount = 0; + //if (tb != null) + //{ + // foreach (DataRow row in tb.Rows) + // { + // allcount += int.Parse(row["num"].ToString()); + // if (!string.IsNullOrEmpty(row["ConstText"].ToString()) && row["ConstText"].ToString().Contains("管理")) + // { + // mcount += int.Parse(row["num"].ToString()); + // } + // } + //} //this.divALLPerson.InnerHtml = allcount.ToString(); - this.divGLPerson.InnerHtml = mcount.ToString(); - this.divZYPerson.InnerHtml = (allcount - mcount).ToString(); - OnDutyRate = Math.Round(getallin.Count() * 1.0 / allcount * 100, 1); + + var ProjectTotal1 = (from x in Funs.DB.HSSE_MonthReportItem + join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId + where ("成达公司HSE管理人数" == x.ReportItem || "分包商HSE管理人数" == x.ReportItem) && y.Years == DateTime.Now.Year + select x.YearTotal).Sum(); + + if (ProjectTotal1.HasValue) + { + this.divGLPerson.InnerHtml = ProjectTotal1.Value.ToString(); + } + + var ProjectTotal2 = (from x in Funs.DB.HSSE_MonthReportItem + join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId + where ("成达公司现场人数" == x.ReportItem || "分包商现场人数" == x.ReportItem) && y.Years == DateTime.Now.Year + select x.YearTotal).Sum(); + + if (ProjectTotal2.HasValue && ProjectTotal1.HasValue) + { + this.divZYPerson.InnerHtml = (ProjectTotal2.Value - ProjectTotal1.Value).ToString(); + } + else if (ProjectTotal2.HasValue) + { + this.divZYPerson.InnerHtml = ProjectTotal2.Value.ToString(); + } + + + + // OnDutyRate = Math.Round(getallin.Count() * 1.0 / allcount * 100, 1); } @@ -154,7 +179,7 @@ namespace FineUIPro.Web.common this.divSafeWorkTime.InnerHtml = "0000000000"; var ProjectTotal = (from x in Funs.DB.HSSE_MonthReportItem join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId - where "安全生产人工时数" == x.ReportItem + where "安全生产人工时数" == x.ReportItem && y.Years== DateTime.Now.Year select x.YearTotal).Sum(); if (ProjectTotal.HasValue) diff --git a/SGGL/FineUIPro.Web/common/mainProject.aspx.cs b/SGGL/FineUIPro.Web/common/mainProject.aspx.cs index 95e508c0..bd2b5021 100644 --- a/SGGL/FineUIPro.Web/common/mainProject.aspx.cs +++ b/SGGL/FineUIPro.Web/common/mainProject.aspx.cs @@ -148,49 +148,73 @@ namespace FineUIPro.Web.common /// private void getSitePerson() { - var getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList(); + //var getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList(); + //string sql = @"select c.ConstText,b.PostType,count( *) num from SitePerson_Person a left join Base_WorkPost b on a.WorkPostId=b.WorkPostId + // LEFT JOIN Sys_Const AS c ON c.ConstValue = b.PostType and c.GroupId = 'PostType' where IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' ) + // and a.ProjectId='" + this.ProjectId + @"' and a.AuditorDate is not null + // group by c.ConstText,b.PostType "; + // List listStr = new List(); + // SqlParameter[] parameter = listStr.ToArray(); + // DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter); + // int allcount = getEmployInOutRecords.Count(); + // int mcount = 0; + // if (tb != null) + // { + // foreach (DataRow row in tb.Rows) + // { + // //allcount += int.Parse(row["num"].ToString()); + // if (!string.IsNullOrEmpty(row["ConstText"].ToString()) && row["ConstText"].ToString().Contains("管理")) + // { + // mcount += int.Parse(row["num"].ToString()); + // } + // } + // } + // this.divALLPerson.InnerHtml = allcount.ToString(); - string sql = @"select c.ConstText,b.PostType,count( *) num from SitePerson_Person a left join Base_WorkPost b on a.WorkPostId=b.WorkPostId - LEFT JOIN Sys_Const AS c ON c.ConstValue = b.PostType and c.GroupId = 'PostType' where IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' ) - and a.ProjectId='" + this.ProjectId + @"' and a.AuditorDate is not null - group by c.ConstText,b.PostType "; - List listStr = new List(); - SqlParameter[] parameter = listStr.ToArray(); - DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter); - int allcount = getEmployInOutRecords.Count(); - int mcount = 0; - if (tb != null) + //if (allcount > mcount) + //{ + // this.divGLPerson.InnerHtml = mcount.ToString(); + // this.divZYPerson.InnerHtml = (allcount - mcount).ToString(); + //} + //else + //{ + // this.divGLPerson.InnerHtml = allcount.ToString(); + // this.divZYPerson.InnerHtml = "0"; + //} + var ProjectTotal1 = (from x in Funs.DB.HSSE_MonthReportItem + join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId + where ("成达公司HSE管理人数" == x.ReportItem || "分包商HSE管理人数" == x.ReportItem) && y.Years == DateTime.Now.Year && y.ProjectId==CurrUser.LoginProjectId + select x.YearTotal).Sum(); + + + + + + + var ProjectTotal2 = (from x in Funs.DB.HSSE_MonthReportItem + join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId + where ("成达公司现场人数" == x.ReportItem || "分包商现场人数" == x.ReportItem) && y.Years == DateTime.Now.Year && y.ProjectId == CurrUser.LoginProjectId + select x.YearTotal).Sum(); + + if (ProjectTotal1.HasValue) { - foreach (DataRow row in tb.Rows) - { - //allcount += int.Parse(row["num"].ToString()); - if (!string.IsNullOrEmpty(row["ConstText"].ToString()) && row["ConstText"].ToString().Contains("管理")) - { - mcount += int.Parse(row["num"].ToString()); - } - } + this.divGLPerson.InnerHtml = ProjectTotal1.Value.ToString(); } - this.divALLPerson.InnerHtml = allcount.ToString(); - - - if (allcount > mcount) - { - this.divGLPerson.InnerHtml = mcount.ToString(); - this.divZYPerson.InnerHtml = (allcount - mcount).ToString(); - } - else - { - this.divGLPerson.InnerHtml = allcount.ToString(); - this.divZYPerson.InnerHtml = "0"; - } - - if (CurrUser.LoginProjectId == "b11a16ea-148c-4bae-a5a1-32158b599482") + if (ProjectTotal2.HasValue) { - this.divALLPerson.InnerHtml = "1301"; - this.divGLPerson.InnerHtml = "172"; - this.divZYPerson.InnerHtml = "1129"; + this.divALLPerson.InnerHtml = ProjectTotal2.Value.ToString(); } + if (ProjectTotal1.HasValue && ProjectTotal2.HasValue) + { + this.divZYPerson.InnerHtml = (ProjectTotal2.Value - ProjectTotal1.Value).ToString(); + } + else if(ProjectTotal2.HasValue) + { + this.divZYPerson.InnerHtml = ProjectTotal2.Value .ToString(); + + } +