192824ea90
- 安全巡检表新增编码字段(Code,全局唯一 XJ-序号),WebAPI/桌面端新增时自动生成,不可重复 - 修复危大超危工程公示牌二维码不显示:urlName 含非法字符?导致 image.Save 抛异常,改用主键+内容哈希安全文件名 - 安全问题统计(mainProject/main3)排除作废数据(States=4),图表口径与顶部计数一致 - Word 导出文件名改为 监督巡视部位+编号 - Model.cs 由 SqlMetal 重新生成,补齐巡检人ID/签收人ID/发现问题/处理要求等字段;新增 HSSE_SafetyPatrol.Code.cs 补充 Code 列 - 新增安全巡检完整建表脚本(SGGLDB_V2026-08-25-001);删除已过时的接口文档 SafetyPatrol_API.md
346 lines
13 KiB
C#
346 lines
13 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using NPOI.SS.UserModel;
|
|
|
|
namespace FineUIPro.Web.HSSE.HazardousMG
|
|
{
|
|
/// <summary>
|
|
/// 危大、超危工程清单页面
|
|
/// </summary>
|
|
public partial class HazardProject : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增按钮事件
|
|
/// </summary>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
Alert.ShowInTop("请先选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference("HazardProjectEdit.aspx"));
|
|
}
|
|
#endregion
|
|
|
|
#region 数据绑定
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
Alert.ShowInTop("请先登录或选择项目!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
List<Model.HSSE_HazardProject> list = this.GetFilteredList();
|
|
Grid1.RecordCount = list.Count;
|
|
var table = this.GetPagedDataTable(Grid1, list);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取按查询条件过滤后的清单列表
|
|
/// </summary>
|
|
private List<Model.HSSE_HazardProject> GetFilteredList()
|
|
{
|
|
List<Model.HSSE_HazardProject> list = BLL.HazardProjectService.GetList(this.CurrUser.LoginProjectId);
|
|
////查询条件过滤
|
|
string name = this.txtProjectName.Text.Trim();
|
|
if (!string.IsNullOrEmpty(name))
|
|
{
|
|
list = list.Where(x => x.ProjectName.Contains(name)).ToList();
|
|
}
|
|
if (!string.IsNullOrEmpty(this.ddlRiskLevel.SelectedValue))
|
|
{
|
|
list = list.Where(x => x.RiskLevel == this.ddlRiskLevel.SelectedValue).ToList();
|
|
}
|
|
////开工时间范围过滤
|
|
if (this.dpStartDateFrom.SelectedDate.HasValue)
|
|
{
|
|
DateTime startFrom = this.dpStartDateFrom.SelectedDate.Value;
|
|
list = list.Where(x => x.StartDate.HasValue && x.StartDate.Value >= startFrom).ToList();
|
|
}
|
|
if (this.dpStartDateTo.SelectedDate.HasValue)
|
|
{
|
|
DateTime startTo = this.dpStartDateTo.SelectedDate.Value;
|
|
list = list.Where(x => x.StartDate.HasValue && x.StartDate.Value <= startTo).ToList();
|
|
}
|
|
////结束时间范围过滤
|
|
if (this.dpEndDateFrom.SelectedDate.HasValue)
|
|
{
|
|
DateTime endFrom = this.dpEndDateFrom.SelectedDate.Value;
|
|
list = list.Where(x => x.EndDate.HasValue && x.EndDate.Value >= endFrom).ToList();
|
|
}
|
|
if (this.dpEndDateTo.SelectedDate.HasValue)
|
|
{
|
|
DateTime endTo = this.dpEndDateTo.SelectedDate.Value;
|
|
list = list.Where(x => x.EndDate.HasValue && x.EndDate.Value <= endTo).ToList();
|
|
}
|
|
return list;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页事件
|
|
/// </summary>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 每页记录数下拉事件
|
|
/// </summary>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
this.BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序事件
|
|
/// </summary>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 导入导出
|
|
/// <summary>
|
|
/// 导出
|
|
/// </summary>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
List<Model.HSSE_HazardProject> list = this.GetFilteredList();
|
|
|
|
string[] cols = { "序号", "分部分项工程", "施工内容", "风险等级", "开工时间", "结束时间", "现场负责人", "备注" };
|
|
short[] widths = { 8, 30, 40, 16, 16, 16, 16, 30 };
|
|
|
|
string rootPath = Server.MapPath("~/");
|
|
string fullPath = rootPath + BLL.Const.ExcelUrl;
|
|
if (!Directory.Exists(fullPath))
|
|
{
|
|
Directory.CreateDirectory(fullPath);
|
|
}
|
|
string fileName = "危大超危工程清单" + BLL.Funs.GetNewFileName() + ".xls";
|
|
string filePath = fullPath + fileName;
|
|
|
|
BLL.Common.NPOIExcel excel = new BLL.Common.NPOIExcel();
|
|
|
|
////表头样式:白字加粗、蓝底、带边框
|
|
IFont headerFont = excel.CreateFont();
|
|
headerFont.Boldweight = 700;
|
|
headerFont.Color = BLL.Common.NPOIColor.WHITE;
|
|
ICellStyle headerStyle = excel.CreateCellStyle();
|
|
headerStyle.SetFont(headerFont);
|
|
headerStyle.FillForegroundColor = BLL.Common.NPOIColor.ROYAL_BLUE;
|
|
headerStyle.FillPattern = FillPattern.SolidForeground;
|
|
headerStyle.BorderTop = BorderStyle.Thin;
|
|
headerStyle.BorderBottom = BorderStyle.Thin;
|
|
headerStyle.BorderLeft = BorderStyle.Thin;
|
|
headerStyle.BorderRight = BorderStyle.Thin;
|
|
|
|
////数据样式:带边框
|
|
ICellStyle dataStyle = excel.CreateCellStyle();
|
|
dataStyle.BorderTop = BorderStyle.Thin;
|
|
dataStyle.BorderBottom = BorderStyle.Thin;
|
|
dataStyle.BorderLeft = BorderStyle.Thin;
|
|
dataStyle.BorderRight = BorderStyle.Thin;
|
|
|
|
for (int i = 0; i < cols.Length; i++)
|
|
{
|
|
excel.SetValue(0, i, cols[i]);
|
|
excel.SetStyle(0, i, headerStyle);
|
|
excel.SetColumnWidth(i, widths[i]);
|
|
}
|
|
|
|
int rowIndex = 1;
|
|
foreach (Model.HSSE_HazardProject item in list)
|
|
{
|
|
excel.SetValue(rowIndex, 0, rowIndex.ToString());
|
|
excel.SetValue(rowIndex, 1, item.ProjectName ?? string.Empty);
|
|
excel.SetValue(rowIndex, 2, item.WorkContent ?? string.Empty);
|
|
excel.SetValue(rowIndex, 3, item.RiskLevel ?? string.Empty);
|
|
excel.SetValue(rowIndex, 4, item.StartDate.HasValue ? item.StartDate.Value.ToString("yyyy-MM-dd") : string.Empty);
|
|
excel.SetValue(rowIndex, 5, item.EndDate.HasValue ? item.EndDate.Value.ToString("yyyy-MM-dd") : string.Empty);
|
|
excel.SetValue(rowIndex, 6, item.ManagerMan ?? string.Empty);
|
|
excel.SetValue(rowIndex, 7, item.Remark ?? string.Empty);
|
|
for (int i = 0; i < cols.Length; i++)
|
|
{
|
|
excel.SetStyle(rowIndex, i, dataStyle);
|
|
}
|
|
rowIndex++;
|
|
}
|
|
|
|
excel.Save(filePath);
|
|
|
|
FileInfo info = new FileInfo(filePath);
|
|
long fileSize = info.Length;
|
|
Response.Clear();
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
|
Response.AddHeader("Content-Length", fileSize.ToString());
|
|
Response.TransmitFile(filePath, 0, fileSize);
|
|
Response.Flush();
|
|
Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导入
|
|
/// </summary>
|
|
protected void btnImport_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window2.GetShowReference("HazardProjectDataIn.aspx"));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导入窗口关闭事件
|
|
/// </summary>
|
|
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击行编辑事件
|
|
/// </summary>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键菜单编辑事件
|
|
/// </summary>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HazardProjectEdit.aspx?HazardProjectId={0}", id)));
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键菜单删除事件
|
|
/// </summary>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
BLL.HazardProjectService.Delete(rowID);
|
|
}
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 关联数据查看
|
|
/// <summary>
|
|
/// 右键菜单查看该危大、超危工程关联的安全巡检记录
|
|
/// </summary>
|
|
protected void btnMenuSafetyPatrol_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(String.Format("window.open('SafetyPatrol.aspx?HazardProjectId={0}', '_blank');", id));
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键菜单查看该危大、超危工程关联的安全防护验收记录
|
|
/// </summary>
|
|
protected void btnMenuSafetyAcceptance_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
PageContext.RegisterStartupScript(String.Format("window.open('SafetyAcceptance.aspx?HazardProjectId={0}', '_blank');", id));
|
|
}
|
|
#endregion
|
|
|
|
#region 公示牌二维码
|
|
/// <summary>
|
|
/// 生成现场公示牌二维码(安全员扫码后进入巡检)
|
|
/// </summary>
|
|
protected void btnQR_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
Model.HSSE_HazardProject info = BLL.HazardProjectService.GetById(id);
|
|
if (info != null)
|
|
{
|
|
////二维码内容:危大工程标识(编号),接入数据库后替换为巡检页面URL
|
|
string strValue = "hazard$hid=" + info.HazardProjectId + "&hname=" + info.ProjectName + "&projectId=" + info.ProjectId;
|
|
////urlName 仅作生成的二维码图片文件名,用「主键+内容哈希」保证文件名安全(不含 ? / = 等非法字符)且内容变化时不复用旧图
|
|
string urlName = info.HazardProjectId + "_" + ((uint)strValue.GetHashCode()).ToString("X");
|
|
string title = "危大工程公示牌:" + info.ProjectName;
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("~/Controls/ShowQRImage.aspx?strValue={0}&urlName={1}&title={2}",
|
|
System.Web.HttpUtility.UrlEncode(strValue),
|
|
System.Web.HttpUtility.UrlEncode(urlName),
|
|
System.Web.HttpUtility.UrlEncode(title)), "公示牌二维码", 340, 400));
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|