1
This commit is contained in:
@@ -0,0 +1,266 @@
|
||||
using Aspose.Words;
|
||||
using BLL;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.Customization.CNCCG.ZHGL.Problem
|
||||
{
|
||||
public partial class ProblemManager : PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
||||
{
|
||||
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
||||
}
|
||||
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 改变索引事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
Grid1.PageIndex = e.NewPageIndex;
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
#region 加载数据
|
||||
protected void BindGrid()
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtMonth.Text.Trim()))
|
||||
{
|
||||
Alert.ShowInTop("请选择月份!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var month = Convert.ToDateTime(txtMonth.Text.Trim());
|
||||
|
||||
var query = from F in Funs.DB.Problem_Notice_C
|
||||
join b in Funs.DB.Problem_Notice on F.ProNoticeId equals b.ProNoticeId
|
||||
join a in Funs.DB.Base_Project on b.ProjectId equals a.ProjectId into projJoin
|
||||
from a in projJoin.DefaultIfEmpty()
|
||||
join d in Funs.DB.Base_Unit on b.ProjectId equals d.UnitId into unitJoin
|
||||
from d in unitJoin.DefaultIfEmpty()
|
||||
where b.CheckStartTime.Value.Year == month.Year && b.CheckStartTime.Value.Month == month.Month
|
||||
orderby b.CheckStartTime descending
|
||||
select new
|
||||
{
|
||||
b.ProType,
|
||||
ProjectName = b.ProType == "1" ? a.ProjectName : d.UnitName,
|
||||
F.QueDescribe,
|
||||
F.ProNoticeCId,
|
||||
F.QueType,
|
||||
F.RiskLevel,
|
||||
b.CheckStartTime,
|
||||
b.CheckEndTime,
|
||||
F.Requirements,
|
||||
F.ReDay,
|
||||
F.ReSituation,
|
||||
b.CheckMans,
|
||||
b.SupervisionMan,
|
||||
b.ProNoticeId
|
||||
};
|
||||
|
||||
var result = query.ToList();
|
||||
|
||||
Grid1.RecordCount = result.Count;
|
||||
Grid1.DataSource = result;
|
||||
Grid1.DataBind();
|
||||
|
||||
var queTypeCounts = result.GroupBy(r => r.QueType)
|
||||
.Select(g => new { QueType = g.Key, Count = g.Count() })
|
||||
.ToList();
|
||||
|
||||
string text = $"周期内隐患检查情况说明:{month}至今已完成检查{result.Select(x => x.ProNoticeId).Distinct().Count()}次,隐患总数{result.Count},其中";
|
||||
foreach (var item in queTypeCounts)
|
||||
{
|
||||
text += $"{item.QueType}隐患{item.Count}条、";
|
||||
}
|
||||
text = text.TrimEnd('、');
|
||||
|
||||
// 显示文本说明
|
||||
lbRemark.Text = text;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 格式化问题照片
|
||||
/// <summary>
|
||||
/// 问题照片
|
||||
/// </summary>
|
||||
/// <param name="ProNoticeCId"></param>
|
||||
/// <returns></returns>
|
||||
protected string ConvertImageUrlByImage(object ProNoticeCId) {
|
||||
string url = string.Empty;
|
||||
string httpUrl = string.Empty;
|
||||
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
||||
if (sysSet6 != null)
|
||||
{
|
||||
httpUrl = sysSet6.SetValue;
|
||||
}
|
||||
if (ProNoticeCId != null)
|
||||
{
|
||||
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(ProNoticeCId.ToString(), BLL.Const.ProblemNoticeManagerMenuId);
|
||||
|
||||
if (sourlist != null && sourlist.Count > 0)
|
||||
{
|
||||
string AttachUrl = "";
|
||||
foreach (var item in sourlist)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
||||
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
||||
}
|
||||
url = BLL.UploadAttachmentService.ShowImage(httpUrl, AttachUrl.TrimEnd(','));
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 整改后照片
|
||||
/// </summary>
|
||||
/// <param name="ProNoticeCId"></param>
|
||||
/// <returns></returns>
|
||||
protected string ConvertImageUrlByImageZgh(object ProNoticeCId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
string httpUrl = string.Empty;
|
||||
var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
||||
if (sysSet6 != null)
|
||||
{
|
||||
httpUrl = sysSet6.SetValue;
|
||||
}
|
||||
if (ProNoticeCId != null)
|
||||
{
|
||||
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(ProNoticeCId.ToString()+"ZGH", BLL.Const.ProblemNoticeManagerMenuId);
|
||||
|
||||
if (sourlist != null && sourlist.Count > 0)
|
||||
{
|
||||
string AttachUrl = "";
|
||||
foreach (var item in sourlist)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
||||
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
||||
}
|
||||
url = BLL.UploadAttachmentService.ShowImage(httpUrl, AttachUrl.TrimEnd(','));
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 格式化检查时间
|
||||
protected string ConvertCheckTime(object startTime, object endTime) {
|
||||
if (startTime != null && endTime != null)
|
||||
{
|
||||
var sTime = Convert.ToDateTime(startTime);
|
||||
var eTime = Convert.ToDateTime(endTime);
|
||||
|
||||
return sTime.Year.ToString() + "." + sTime.Month.ToString() + "." + sTime.Day.ToString() + "-" + eTime.Day.ToString();
|
||||
}
|
||||
else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导出
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtMonth.Text.Trim()))
|
||||
{
|
||||
Alert.ShowInTop("请选择月份!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
Response.ClearContent();
|
||||
string filename = Funs.GetNewFileName();
|
||||
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("问题排查与治理汇总表"+ txtMonth.Text.Trim() + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
Response.ContentType = "application/excel";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
this.Grid1.PageSize = 100000;
|
||||
this.BindGrid();
|
||||
Response.Write(GetGridTableHtml(Grid1));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
public static string GetGridTableHtml(Grid grid)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
||||
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
||||
sb.Append("<tr>");
|
||||
|
||||
foreach (GridColumn column in grid.Columns)
|
||||
{
|
||||
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
||||
}
|
||||
sb.Append("</tr>");
|
||||
foreach (GridRow row in grid.Rows)
|
||||
{
|
||||
sb.Append("<tr>");
|
||||
foreach (GridColumn column in grid.Columns)
|
||||
{
|
||||
string html = row.Values[column.ColumnIndex].ToString();
|
||||
if (column.ColumnID == "tfNumber" && (row.FindControl("lblNumber") as AspNet.Label) != null)
|
||||
{
|
||||
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
||||
}
|
||||
if (column.ColumnID == "CheckStartTime" && (row.FindControl("Label1") as AspNet.Label) != null)
|
||||
{
|
||||
html = (row.FindControl("Label1") as AspNet.Label).Text;
|
||||
}
|
||||
|
||||
|
||||
if (column.ColumnID == "tfImageUrl1" && (row.FindControl("lbImageUrl1") as AspNet.Label) != null)
|
||||
{
|
||||
html = (row.FindControl("lbImageUrl1") as AspNet.Label).Text;
|
||||
}
|
||||
if (column.ColumnID == "tfImageUrl2" && (row.FindControl("lbImageUrl2") as AspNet.Label) != null)
|
||||
{
|
||||
html = (row.FindControl("lbImageUrl2") as AspNet.Label).Text;
|
||||
}
|
||||
sb.AppendFormat("<td style='vnd.ms-excel.numberformat:@;width:140px;'>{0}</td>", html);
|
||||
// sb.AppendFormat("<td>{0}</td>", html);
|
||||
}
|
||||
|
||||
sb.Append("</tr>");
|
||||
}
|
||||
|
||||
sb.Append("</table>");
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user