diff --git a/SGGL/BLL/API/HSSE/APICheckSpecialService.cs b/SGGL/BLL/API/HSSE/APICheckSpecialService.cs index 76ddef25..7a6318bf 100644 --- a/SGGL/BLL/API/HSSE/APICheckSpecialService.cs +++ b/SGGL/BLL/API/HSSE/APICheckSpecialService.cs @@ -234,6 +234,10 @@ namespace BLL CompleteStatusName = x.CompleteStatus == true ? "已整改" : "待整改", CompletedDate = string.Format("{0:yyyy-MM-dd}", x.CompletedDate), AttachUrl1 = APIUpLoadFileService.getFileUrl(x.CheckSpecialDetailId, null), + + CheckItemDetailSetId = x.CheckItemSetId, + CheckItemDetailContent = x.CheckItemSetContent, + Rectification_Date = x.Rectification_Date }; return getInfo.ToList(); } diff --git a/SGGL/BLL/ZHGL/DataStatistics/DataStatisticsService.cs b/SGGL/BLL/ZHGL/DataStatistics/DataStatisticsService.cs index e84bceac..ee85ae92 100644 --- a/SGGL/BLL/ZHGL/DataStatistics/DataStatisticsService.cs +++ b/SGGL/BLL/ZHGL/DataStatistics/DataStatisticsService.cs @@ -72,9 +72,9 @@ namespace BLL /// /// /// - public static List RectifyNoticesStatistics(string projectId, string unitId, DateTime? startTime, DateTime? endTime) + public static List RectifyNoticesStatistics(string projectId, string unitId, DateTime? startTime, DateTime? endTime) { - List GetCheckStatistics = new List(); + List GetCheckStatistics = new List(); var getProjects = ProjectService.GetProjectWorkList(); if (projectId != Const._Null && !string.IsNullOrEmpty(projectId)) { @@ -89,38 +89,127 @@ namespace BLL } foreach (var item in getUnits) { - var getHazardRegister = from x in Funs.DB.Check_RectifyNotices - where x.ProjectId == pitem.ProjectId && x.UnitId == item.UnitId - && x.States != "0" - select x; - if (startTime.HasValue) - { - getHazardRegister = getHazardRegister.Where(x => x.CheckedDate >= startTime); - } - if (endTime.HasValue) - { - getHazardRegister = getHazardRegister.Where(x => x.CheckedDate <= endTime); - } - Model.ChartAnalysisItem newItem = new Model.ChartAnalysisItem + + Model.RecityNoticesItem newItem = new Model.RecityNoticesItem { DataId = SQLHelper.GetNewID(), DataAllName = pitem.ProjectName, DataName = item.UnitName, }; - newItem.DataSumCount = getHazardRegister.Count(); - newItem.DataCount1 = getHazardRegister.Where(x => x.States == "1").Count(); - newItem.DataCount2 = getHazardRegister.Where(x => x.States == "2").Count(); - newItem.DataCount3 = getHazardRegister.Where(x => x.States == "3").Count(); - newItem.DataCount4 = getHazardRegister.Where(x => x.States == "4").Count(); - newItem.DataCount5 = getHazardRegister.Where(x => x.States == "5").Count(); - if (newItem.DataCount2 > 0) + //安全巡检隐患数 + var getHazardRegister = from x in Funs.DB.View_Hazard_HazardRegister + where x.ProblemTypes == "1" && x.ProjectId == pitem.ProjectId && x.ResponsibleUnit == item.UnitId + select x; + if (startTime.HasValue) { - newItem.DataCountRate = (float)newItem.DataCount5 / (float)newItem.DataCount2 * 100; + getHazardRegister = getHazardRegister.Where(x => x.CheckTime >= startTime); + } + if (endTime.HasValue) + { + getHazardRegister = getHazardRegister.Where(x => x.CheckTime <= endTime); + } + newItem.DataSumCount1 = getHazardRegister.Where(x=>x.Type==0).Count(); + newItem.DataSumCountYzg1 = getHazardRegister.Where(x => x.Type == 0 && x.States == "2").Count(); + newItem.DataSumCountDzg1 = getHazardRegister.Where(x => x.Type == 0 && x.States == "1").Count(); + if (newItem.DataSumCountYzg1 > 0) + { + newItem.DataSumCountZgl1 =Math.Round((float)newItem.DataSumCountYzg1 / (float)newItem.DataSumCount1 * 100,2).ToString()+"%"; } else { - newItem.DataCountRate = 0; + newItem.DataSumCountZgl1 ="0%"; } + + + //常规巡检隐患数 + newItem.DataSumCount2 = getHazardRegister.Where(x => x.Type == 1).Count(); + newItem.DataSumCountYzg2 = getHazardRegister.Where(x => x.Type == 1 && x.States == "2").Count(); + newItem.DataSumCountDzg2 = getHazardRegister.Where(x => x.Type == 1 && x.States == "1").Count(); + if (newItem.DataSumCountYzg2 > 0) + { + newItem.DataSumCountZgl2 = Math.Round((float)newItem.DataSumCountYzg2 / (float)newItem.DataSumCount2 * 100, 2).ToString() + "%"; + } + else + { + newItem.DataSumCountZgl2 = "0%"; + } + + //专项检查隐患数 + var getCheckSpecial = from x in Funs.DB.Check_CheckSpecialDetail + join y in Funs.DB.Check_CheckSpecial on x.CheckSpecialId equals y.CheckSpecialId + where x.UnitId == item.UnitId && y.ProjectId == pitem.ProjectId + select new { y.CheckTime,x.UnitId,y.ProjectId,x.CompleteStatus }; + if (startTime.HasValue) + { + getCheckSpecial = getCheckSpecial.Where(x => x.CheckTime >= startTime); + } + if (endTime.HasValue) + { + getCheckSpecial = getCheckSpecial.Where(x => x.CheckTime <= endTime); + } + newItem.DataSumCount3= getCheckSpecial.Count(); + newItem.DataSumCountYzg3 = getCheckSpecial.Where(x =>x.CompleteStatus == true).Count(); + newItem.DataSumCountDzg3 = getCheckSpecial.Where(x =>x.CompleteStatus == false).Count(); + if (newItem.DataSumCountYzg3 > 0) + { + newItem.DataSumCountZgl3 =Math.Round((float)newItem.DataSumCountYzg3 / (float)newItem.DataSumCount3 * 100, 2).ToString() + "%"; ; + } + else + { + newItem.DataSumCountZgl3 = "0%"; + } + + //综合检查隐患数 + var getCheckColligation = from x in Funs.DB.Check_CheckColligationDetail + join y in Funs.DB.Check_CheckColligation on x.CheckColligationId equals y.CheckColligationId + where x.UnitId == item.UnitId && y.ProjectId == pitem.ProjectId + select new { y.CheckTime, x.UnitId, y.ProjectId, x.CompleteStatus }; + if (startTime.HasValue) + { + getCheckColligation = getCheckColligation.Where(x => x.CheckTime >= startTime); + } + if (endTime.HasValue) + { + getCheckColligation = getCheckColligation.Where(x => x.CheckTime <= endTime); + } + newItem.DataSumCount4 = getCheckColligation.Count(); + newItem.DataSumCountYzg4 = getCheckColligation.Where(x => x.CompleteStatus == true).Count(); + newItem.DataSumCountDzg4 = getCheckColligation.Where(x => x.CompleteStatus == false).Count(); + if (newItem.DataSumCountYzg4 > 0) + { + newItem.DataSumCountZgl4 = Math.Round((float)newItem.DataSumCountYzg4 / (float)newItem.DataSumCount4 * 100, 2).ToString(); + } + else + { + newItem.DataSumCountZgl4 = "0%"; + } + + //var getHazardRegister = from x in Funs.DB.Check_RectifyNotices + // where x.ProjectId == pitem.ProjectId && x.UnitId == item.UnitId + // && x.States != "0" + // select x; + //if (startTime.HasValue) + //{ + // getHazardRegister = getHazardRegister.Where(x => x.CheckedDate >= startTime); + //} + //if (endTime.HasValue) + //{ + // getHazardRegister = getHazardRegister.Where(x => x.CheckedDate <= endTime); + //} + //newItem.DataSumCount = getHazardRegister.Count(); + //newItem.DataCount1 = getHazardRegister.Where(x => x.States == "1").Count(); + //newItem.DataCount2 = getHazardRegister.Where(x => x.States == "2").Count(); + //newItem.DataCount3 = getHazardRegister.Where(x => x.States == "3").Count(); + //newItem.DataCount4 = getHazardRegister.Where(x => x.States == "4").Count(); + //newItem.DataCount5 = getHazardRegister.Where(x => x.States == "5").Count(); + //if (newItem.DataCount2 > 0) + //{ + // newItem.DataCountRate = (float)newItem.DataCount5 / (float)newItem.DataCount2 * 100; + //} + //else + //{ + // newItem.DataCountRate = 0; + //} GetCheckStatistics.Add(newItem); } } diff --git a/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx b/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx index 573d7312..9c3e4bd6 100644 --- a/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx +++ b/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx @@ -44,8 +44,8 @@ + SortDirection="ASC" OnSort="Grid1_Sort" EnableColumnLines="true" AllowPaging="true" + IsDatabasePaging="true" PageSize="15" OnPageIndexChange="Grid1_PageIndexChange" EnableTextSelection="True" AllowColumnLocking="true"> @@ -72,7 +72,7 @@ + EnableLock="true" Locked="true"> @@ -81,29 +81,53 @@ HeaderText="项目" TextAlign="Left" HeaderTextAlign="Center"> --%> + HeaderText="单位" TextAlign="Left" HeaderTextAlign="Center" EnableLock="true" Locked="true"> - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <%-- - - - - - - - - - + HeaderText="已整改" TextAlign="Left" HeaderTextAlign="Center"> + --%> diff --git a/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx.cs b/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx.cs index 7b45c22c..d3a22b67 100644 --- a/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx.cs +++ b/SGGL/FineUIPro.Web/HSSE/Check/RectifyNoticesStatistics.aspx.cs @@ -1,5 +1,6 @@ using BLL; using System; +using System.Collections.Generic; using System.Data; using System.Text; using AspNet = System.Web.UI.WebControls; @@ -122,7 +123,7 @@ namespace FineUIPro.Web.HSSE.Check Response.ContentEncoding = System.Text.Encoding.UTF8; this.Grid1.PageSize = this.Grid1.RecordCount; BindGrid(); - Response.Write(GetGridTableHtml(Grid1)); + Response.Write(GetGridTableHtmlNew(Grid1)); Response.End(); } @@ -162,6 +163,252 @@ namespace FineUIPro.Web.HSSE.Check return sb.ToString(); } + + /// + /// 格式化html + /// + /// + /// + private string GetGridTableHtmlNew(Grid grid) + { + StringBuilder sb = new StringBuilder(); + + MultiHeaderTable mht = new MultiHeaderTable(); + mht.ResolveMultiHeaderTable(Grid1.Columns); + + + sb.Append(""); + + + sb.Append(""); + + ////列数 + //var rowCount = ""; + //var list = Funs.DB.Base_Project.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).OrderBy(x => x.ProjectCode).ToList(); + //for (int i = 0; i < list.Count; i++) + //{ + // rowCount+="{}" + //} + + foreach (List rows in mht.MultiTable) + { + sb.Append(""); + foreach (object[] cell in rows) + { + int rowspan = Convert.ToInt32(cell[0]); + int colspan = Convert.ToInt32(cell[1]); + GridColumn column = cell[2] as GridColumn; + + sb.AppendFormat("{3}", + rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "", + colspan != 1 ? " colspan=\"" + colspan + "\"" : "", + colspan != 1 ? " style=\"text-align:center;\"" : "", + column.HeaderText); + } + sb.Append(""); + } + + + foreach (GridRow row in grid.Rows) + { + sb.Append(""); + int i = 0; + string MenuC = ""; + foreach (GridColumn column in mht.Columns) + { + string html = row.Values[column.ColumnIndex].ToString(); + if (column.ColumnID == "tfNumber") + { + html = (row.FindControl("spanNumber") as System.Web.UI.HtmlControls.HtmlGenericControl).InnerText; + } + else if (column.ColumnID == "tfGender") + { + html = (row.FindControl("labGender") as AspNet.Label).Text; + } + else if (column.ColumnID == "tfPageIndex") + { + html = (row.FindControl("lblPageIndex") as AspNet.Label).Text; + } + + + sb.AppendFormat("", html); + + } + + sb.Append(""); + } + + sb.Append("
{0}
"); + + return sb.ToString(); + } + + + public static string MidStrEx(string sourse, string startstr, string endstr) + { + string result = string.Empty; + int startindex, endindex; + try + { + startindex = sourse.IndexOf(startstr); + if (startindex == -1) + return result; + string tmpstr = sourse.Substring(startindex + startstr.Length); + endindex = tmpstr.IndexOf(endstr); + if (endindex == -1) + return result; + result = tmpstr.Remove(endindex); + } + catch (Exception ex) + { + + } + return result; + } + + + #region 多表头处理 + + /// + /// 处理多表头的类 + /// + public class MultiHeaderTable + { + // 包含 rowspan,colspan 的多表头,方便生成 HTML 的 table 标签 + public List> MultiTable = new List>(); + // 最终渲染的列数组 + public List Columns = new List(); + + + public void ResolveMultiHeaderTable(GridColumnCollection columns) + { + List row = new List(); + foreach (GridColumn column in columns) + { + object[] cell = new object[4]; + cell[0] = 1; // rowspan + cell[1] = 1; // colspan + cell[2] = column; + cell[3] = null; + + row.Add(cell); + } + + ResolveMultiTable(row, 0); + + ResolveColumns(row); + } + + private void ResolveColumns(List row) + { + foreach (object[] cell in row) + { + GroupField groupField = cell[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + List subrow = new List(); + foreach (GridColumn column in groupField.Columns) + { + subrow.Add(new object[] + { + 1, + 1, + column, + groupField + }); + } + + ResolveColumns(subrow); + } + else + { + Columns.Add(cell[2] as GridColumn); + } + } + + } + + private void ResolveMultiTable(List row, int level) + { + List nextrow = new List(); + + foreach (object[] cell in row) + { + GroupField groupField = cell[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + // 如果当前列包含子列,则更改当前列的 colspan,以及增加父列(向上递归)的colspan + cell[1] = Convert.ToInt32(groupField.Columns.Count); + PlusColspan(level - 1, cell[3] as GridColumn, groupField.Columns.Count - 1); + + foreach (GridColumn column in groupField.Columns) + { + nextrow.Add(new object[] + { + 1, + 1, + column, + groupField + }); + } + } + } + + MultiTable.Add(row); + + // 如果当前下一行,则增加上一行(向上递归)中没有子列的列的 rowspan + if (nextrow.Count > 0) + { + PlusRowspan(level); + + ResolveMultiTable(nextrow, level + 1); + } + } + + private void PlusRowspan(int level) + { + if (level < 0) + { + return; + } + + foreach (object[] cells in MultiTable[level]) + { + GroupField groupField = cells[2] as GroupField; + if (groupField != null && groupField.Columns.Count > 0) + { + // ... + } + else + { + cells[0] = Convert.ToInt32(cells[0]) + 1; + } + } + + PlusRowspan(level - 1); + } + + private void PlusColspan(int level, GridColumn parent, int plusCount) + { + if (level < 0) + { + return; + } + + foreach (object[] cells in MultiTable[level]) + { + GridColumn column = cells[2] as GridColumn; + if (column == parent) + { + cells[1] = Convert.ToInt32(cells[1]) + plusCount; + + PlusColspan(level - 1, cells[3] as GridColumn, plusCount); + } + } + } + + } + #endregion #endregion } } \ No newline at end of file diff --git a/SGGL/Model/APIItem/HSSE/RecityNoticesItem.cs b/SGGL/Model/APIItem/HSSE/RecityNoticesItem.cs new file mode 100644 index 00000000..6c62e43d --- /dev/null +++ b/SGGL/Model/APIItem/HSSE/RecityNoticesItem.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Model +{ + /// + /// 隐患整改单统计 + /// + public class RecityNoticesItem + { + /// + /// ID + /// + public string DataId + { + get; + set; + } + /// + /// 类型 + /// + public string Type + { + get; + set; + } + /// + /// 名称 + /// + public string DataName + { + get; + set; + } + + /// + /// 项目名称 + /// + public string DataAllName + { + get; + set; + } + + /// + /// 安全巡检隐患总数 + /// + public int DataSumCount1 + { + get; + set; + } + + /// + /// 安全巡检隐患待整改数 + /// + public int DataSumCountDzg1 + { + get; + set; + } + + /// + /// 安全巡检隐患已整改数 + /// + public int DataSumCountYzg1 + { + get; + set; + } + + /// + /// 常规巡检隐患总数 + /// + public int DataSumCount2 + { + get; + set; + } + + /// + /// 常规巡检隐患待整改数 + /// + public int DataSumCountDzg2 + { + get; + set; + } + + /// + /// 常规巡检隐患已整改数 + /// + public int DataSumCountYzg2 + { + get; + set; + } + + /// + /// 专项检查隐患总数 + /// + public int DataSumCount3 + { + get; + set; + } + + /// + /// 专项检查隐患待整改数 + /// + public int DataSumCountDzg3 + { + get; + set; + } + + /// + /// 专项检查隐患已整改数 + /// + public int DataSumCountYzg3 + { + get; + set; + } + + /// + /// 综合检查隐患总数 + /// + public int DataSumCount4 + { + get; + set; + } + + /// + /// 综合检查隐患待整改数 + /// + public int DataSumCountDzg4 + { + get; + set; + } + + /// + /// 综合检查隐患已整改数 + /// + public int DataSumCountYzg4 + { + get; + set; + } + + } +} diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 2f22becb..021d6974 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -105,6 +105,7 @@ +