diff --git a/SUBQHSE/BLL/Common/WordHelp.cs b/SUBQHSE/BLL/Common/WordHelp.cs index a5c67b9..fe39872 100644 --- a/SUBQHSE/BLL/Common/WordHelp.cs +++ b/SUBQHSE/BLL/Common/WordHelp.cs @@ -32,6 +32,14 @@ namespace BLL wordDoc = new Document(path); } + public Document Document + { + get + { + return wordDoc; + } + } + /// /// 添加图片 /// diff --git a/SUBQHSE/FineUIPro.Web/File/Word/HSSE/安全质量环保检查记录(模板)建投隐患整改通知单.doc b/SUBQHSE/FineUIPro.Web/File/Word/HSSE/安全质量环保检查记录(模板)建投隐患整改通知单.doc new file mode 100644 index 0000000..b14dc55 --- /dev/null +++ b/SUBQHSE/FineUIPro.Web/File/Word/HSSE/安全质量环保检查记录(模板)建投隐患整改通知单.doc @@ -0,0 +1,31 @@ + + + + 安全质量环保检查记录 + + 编号:20250105 +|项目名称|«projectName» | +|项 | «remark» | +|目 | | +|概 | | +|况 | | +|工程名称|«projectName» | +|检 |为深入贯彻《关于做好今冬明春重大事故隐患排杏整治的通知》、《关 | +|查 |于开展建筑施工安全生产“自查自纠”活动的通知》、《关于开展我市建| +|发 |筑施工安全“强执法 | +|现 |补短板”专项行动的通知》等文件要求,加强项目危大工程安全管控,| +|的 |2025年1月5日,由项目经理带队,项目领导班子副职以及项目安质部| +|问 |、工程部、物设部、工经部、办公室等部门、分包单位相关人员参加| +|题 |,对本项目在建工程进行了专项检查暨安全质量环保周常检查记录 | +| |,现将具体检查问题记录如下: | +| |现场问题: | +| | | +| | | +|被检查单| | +|位负责人|年 月 日 | +|检查单位|中化学建设投资集团安徽工程有限公司«projectName» | +|检查人员| | +| |年 月 日 | + + + 注:本表一式2份,整改单位、检查单位各1份,验证存档。 diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx index 8abc6b2..fa1b2b7 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx @@ -25,7 +25,7 @@ - + @@ -67,7 +67,7 @@ - @@ -116,6 +116,9 @@ + + + @@ -165,6 +168,22 @@ Target="Parent" EnableResize="false" runat="server" IsModal="true" Width="700px" Height="500px"> + + + + + + + diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.cs index feb987f..624f36c 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.cs @@ -5,7 +5,11 @@ using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; +using System.IO; using System.Linq; +using Aspose.Words; +using Aspose.Words.Drawing; +using Aspose.Words.Tables; namespace FineUIPro.Web.HSSE.Check { @@ -417,5 +421,188 @@ namespace FineUIPro.Web.HSSE.Check //} + /// + /// 导出 + /// + /// + /// + protected void btnPrinter_Click(object sender, EventArgs e) + { + //获取所有列表导出 + if (!string.IsNullOrEmpty(this.RectifyNoticesId)) + { + var rectifyNotices = RectifyNoticesService.GetRectifyNoticesById(RectifyNoticesId); + string CheckManIds = rectifyNotices.CheckManIds; + string CheckManNames = string.Empty; + if (CheckManIds != null) + { + string[] Ids = CheckManIds.ToString().Split(','); + foreach (string t in Ids) + { + var Name = BLL.UserService.GetUserNameByUserId(t); + if (Name != null) + { + CheckManNames += Name + ","; + } + } + } + + string DutyPersonId = rectifyNotices.DutyPersonId; + string DutyPersonName = UserService.GetUserNameByUserId(DutyPersonId); + + var dataList = (from item in Funs.DB.Check_RectifyNoticesItem + join rectify in Funs.DB.Technique_Rectify + on item.RectifyId equals rectify.RectifyId into rectifyGroup + from rectify in rectifyGroup.DefaultIfEmpty() + where item.RectifyNoticesId == RectifyNoticesId + select new + { + RectifyNoticesItemId = item.RectifyNoticesItemId, + RectifyId = rectify.RectifyName, + RectifyNoticesId = item.RectifyNoticesId, + WrongContent = item.WrongContent, + Requirement = item.Requirement, + LimitTime = item.LimitTime, + RectifyResults = item.RectifyResults, + IsRectify = item.IsRectify + }).ToList(); + + string rootPath = Server.MapPath("~/"); + string initTemplatePath = string.Empty; + string uploadfilepath = string.Empty; + string newUrl = string.Empty; + + initTemplatePath = "File\\Word\\HSSE\\安全质量环保检查记录(模板)建投隐患整改通知单.doc"; + uploadfilepath = rootPath + initTemplatePath; + newUrl = uploadfilepath.Replace(".doc", RectifyNoticesId + ".doc"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + + File.Copy(uploadfilepath, newUrl); + AsposeWordHelper helper = new AsposeWordHelper(); + helper.OpenTempelte(newUrl); //打开模板文件 + + + var project = + (from x in Funs.DB.Base_Project where x.ProjectId == this.CurrUser.LoginProjectId select x) + .FirstOrDefault(); + string projectName = project.ProjectName; + string remark = project.Remark; + + string[] fieldNames = + { + "projectName", "remark" + }; + + object[] fieldValues = + { + projectName, remark + }; + helper.Executefield(fieldNames, fieldValues); //域赋值 + + if (dataList.Count > 0) + { + Document doc = helper.Document; + DocumentBuilder builder = new DocumentBuilder(doc); + Table table = (Table)doc.GetChild(NodeType.Table, 1, true); // 定位第一个表格 + + int number = 1; + foreach (var item in dataList) + { + string WrongContent = item.WrongContent; + string Requirement = item.Requirement; + string LimitTime = item.LimitTime.HasValue + ? $" {item.LimitTime.Value.Year} 年 {item.LimitTime.Value.Month:D2} 月 {item.LimitTime.Value.Day:D2} 日" + : ""; + List Paths = new List(); + + var res = AttachFileService.getFileUrl(item.RectifyNoticesItemId + "#1"); + if (!string.IsNullOrEmpty(res)) + { + string[] arr = res.Split(','); + for (int i = 0; i < arr.Length; i++) + { + Paths.Add(rootPath + arr[i]); + } + } + + // 克隆模板占位行 + Row newRow = (Row)table.LastRow.Clone(true); + table.AppendChild(newRow); + + // 定位到单元格 + Cell cell = newRow.FirstCell; + + // 清空单元格所有段落 + cell.RemoveAllChildren(); + Paragraph para = new Paragraph(doc); // 显式创建段落 + cell.AppendChild(para); + builder.MoveTo(para); // 定位到段落 + + // 插入文本 + builder.Write(" 存在问题" + number.ToString() + ":" + WrongContent); + builder.Writeln(); // 换行 + builder.Write(" 整改要求:" + Requirement); + builder.Writeln(); // 换行 + builder.Write(" 整改时间:" + LimitTime + " 整改责任人:" + DutyPersonName + " 监督人:" + + CheckManNames); + builder.Writeln(); // 换行 + + // 插入多张图片(横向排列) + if (Paths.Count > 0) + { + foreach (string imgPath in Paths) + { + // 计算每张图片宽度(总宽度按单元格宽度平分) + double cellWidth = cell.CellFormat.Width; + double imgWidth = (cellWidth - 10 * (Paths.Count - 1)) / Paths.Count - 10; + + // 插入图片并调整尺寸 + Shape image = builder.InsertImage(imgPath); + image.Width = Paths.Count == 1 ? imgWidth / 2 : imgWidth; + // image.Height = image.ImageData.ImageSize.HeightPixels * (imgWidth / image.ImageData.ImageSize.WidthPixels); + image.Height = 120; + + // 图片间留间距(横向排列) + if (imgPath != Paths.Last()) + { + builder.MoveTo(cell.LastParagraph.AppendChild(new Run(doc))); + builder.Write(" "); // 插入空格分隔 + } + } + } + number++; + } + + // 删除模板中的原始占位行 + table.Rows.RemoveAt(0); + } + + + helper.SaveDoc(newUrl); //文件保存,保存为doc + + // 验证文件是否存在 + if (!File.Exists(newUrl)) + { + throw new Exception("文件不存在: " + newUrl); + } + + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", + "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); + } + } + } } \ No newline at end of file diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.designer.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.designer.cs index cb3dcd2..b4fa823 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.designer.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAdd.aspx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace FineUIPro.Web.HSSE.Check { - - - public partial class RectifyNoticesAdd { - +namespace FineUIPro.Web.HSSE.Check +{ + + + public partial class RectifyNoticesAdd + { + /// /// form1 控件。 /// @@ -20,7 +22,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; - + /// /// PageManager1 控件。 /// @@ -29,7 +31,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.PageManager PageManager1; - + /// /// Panel4 控件。 /// @@ -38,7 +40,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel Panel4; - + /// /// SimpleForm1 控件。 /// @@ -47,7 +49,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Form SimpleForm1; - + /// /// Toolbar1 控件。 /// @@ -56,7 +58,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar Toolbar1; - + /// /// hdRectifyNoticesId 控件。 /// @@ -65,7 +67,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.HiddenField hdRectifyNoticesId; - + /// /// btnSave 控件。 /// @@ -74,7 +76,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button btnSave; - + /// /// btnSubmit 控件。 /// @@ -83,7 +85,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button btnSubmit; - + /// /// txtRectifyNoticesCode 控件。 /// @@ -92,7 +94,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtRectifyNoticesCode; - + /// /// drpUnitId 控件。 /// @@ -101,7 +103,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpUnitId; - + /// /// drpWorkAreaId 控件。 /// @@ -110,7 +112,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpWorkAreaId; - + /// /// drpCheckMan 控件。 /// @@ -119,7 +121,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpCheckMan; - + /// /// txtCheckPerson 控件。 /// @@ -128,7 +130,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtCheckPerson; - + /// /// txtCheckedDate 控件。 /// @@ -137,7 +139,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DatePicker txtCheckedDate; - + /// /// drpHiddenHazardType 控件。 /// @@ -146,7 +148,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpHiddenHazardType; - + /// /// Grid1 控件。 /// @@ -155,7 +157,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid Grid1; - + /// /// toolAdd 控件。 /// @@ -164,7 +166,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Toolbar toolAdd; - + /// /// btnAdd 控件。 /// @@ -173,7 +175,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Button btnAdd; - + /// /// drpRectifyId 控件。 /// @@ -182,7 +184,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpRectifyId; - + /// /// tWrongContent 控件。 /// @@ -191,7 +193,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox tWrongContent; - + /// /// tRequirement 控件。 /// @@ -200,7 +202,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox tRequirement; - + /// /// txtLimitTimes 控件。 /// @@ -209,7 +211,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DatePicker txtLimitTimes; - + /// /// del 控件。 /// @@ -218,7 +220,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.LinkButtonField del; - + /// /// drpSignPerson 控件。 /// @@ -227,7 +229,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.DropDownList drpSignPerson; - + /// /// gvFlowOperate 控件。 /// @@ -236,7 +238,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid gvFlowOperate; - + /// /// lblPageIndex 控件。 /// @@ -245,7 +247,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label lblPageIndex; - + /// /// WindowAtt 控件。 /// @@ -254,5 +256,23 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window WindowAtt; + + /// + /// Menu1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Menu Menu1; + + /// + /// btnPrinter 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.MenuButton btnPrinter; } } diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx index d533cf3..435d645 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx @@ -57,7 +57,7 @@ - @@ -92,6 +92,9 @@ HeaderText="合格" HeaderTextAlign="Center" TextAlign="Center"> + + + @@ -167,6 +170,22 @@ Target="Parent" EnableResize="false" runat="server" IsModal="true" Width="700px" Height="500px"> - + + + + + + + + diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.cs index 0444c71..5bd2b3b 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.cs @@ -6,6 +6,10 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; +using System.IO; +using Aspose.Words; +using Aspose.Words.Drawing; +using Aspose.Words.Tables; namespace FineUIPro.Web.HSSE.Check { @@ -315,5 +319,189 @@ namespace FineUIPro.Web.HSSE.Check } } } + + /// + /// 导出 + /// + /// + /// + protected void btnPrinter_Click(object sender, EventArgs e) + { + //获取所有列表导出 + if (!string.IsNullOrEmpty(this.RectifyNoticesId)) + { + var rectifyNotices = RectifyNoticesService.GetRectifyNoticesById(RectifyNoticesId); + string CheckManIds = rectifyNotices.CheckManIds; + string CheckManNames = string.Empty; + if (CheckManIds != null) + { + string[] Ids = CheckManIds.ToString().Split(','); + foreach (string t in Ids) + { + var Name = BLL.UserService.GetUserNameByUserId(t); + if (Name != null) + { + CheckManNames += Name + ","; + } + } + } + + string DutyPersonId = rectifyNotices.DutyPersonId; + string DutyPersonName = UserService.GetUserNameByUserId(DutyPersonId); + + var dataList = (from item in Funs.DB.Check_RectifyNoticesItem + join rectify in Funs.DB.Technique_Rectify + on item.RectifyId equals rectify.RectifyId into rectifyGroup + from rectify in rectifyGroup.DefaultIfEmpty() + where item.RectifyNoticesId == RectifyNoticesId + select new + { + RectifyNoticesItemId = item.RectifyNoticesItemId, + RectifyId = rectify.RectifyName, + RectifyNoticesId = item.RectifyNoticesId, + WrongContent = item.WrongContent, + Requirement = item.Requirement, + LimitTime = item.LimitTime, + RectifyResults = item.RectifyResults, + IsRectify = item.IsRectify + }).ToList(); + + string rootPath = Server.MapPath("~/"); + string initTemplatePath = string.Empty; + string uploadfilepath = string.Empty; + string newUrl = string.Empty; + + initTemplatePath = "File\\Word\\HSSE\\安全质量环保检查记录(模板)建投隐患整改通知单.doc"; + uploadfilepath = rootPath + initTemplatePath; + newUrl = uploadfilepath.Replace(".doc", RectifyNoticesId + ".doc"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + + File.Copy(uploadfilepath, newUrl); + AsposeWordHelper helper = new AsposeWordHelper(); + helper.OpenTempelte(newUrl); //打开模板文件 + + + var project = + (from x in Funs.DB.Base_Project where x.ProjectId == this.CurrUser.LoginProjectId select x) + .FirstOrDefault(); + string projectName = project.ProjectName; + string remark = project.Remark; + + string[] fieldNames = + { + "projectName", "remark" + }; + + object[] fieldValues = + { + projectName, remark + }; + helper.Executefield(fieldNames, fieldValues); //域赋值 + + if (dataList.Count > 0) + { + Document doc = helper.Document; + DocumentBuilder builder = new DocumentBuilder(doc); + Table table = (Table)doc.GetChild(NodeType.Table, 1, true); // 定位第一个表格 + + int number = 1; + foreach (var item in dataList) + { + string WrongContent = item.WrongContent; + string Requirement = item.Requirement; + string LimitTime = item.LimitTime.HasValue + ? $" {item.LimitTime.Value.Year} 年 {item.LimitTime.Value.Month:D2} 月 {item.LimitTime.Value.Day:D2} 日" + : ""; + List Paths = new List(); + + var res = AttachFileService.getFileUrl(item.RectifyNoticesItemId + "#1"); + if (!string.IsNullOrEmpty(res)) + { + string[] arr = res.Split(','); + for (int i = 0; i < arr.Length; i++) + { + Paths.Add(rootPath + arr[i]); + } + } + + // 克隆模板占位行 + Row newRow = (Row)table.LastRow.Clone(true); + table.AppendChild(newRow); + + // 定位到单元格 + Cell cell = newRow.FirstCell; + + // 清空单元格所有段落 + cell.RemoveAllChildren(); + Paragraph para = new Paragraph(doc); // 显式创建段落 + cell.AppendChild(para); + builder.MoveTo(para); // 定位到段落 + + // 插入文本 + builder.Write(" 存在问题" + number.ToString() + ":" + WrongContent); + builder.Writeln(); // 换行 + builder.Write(" 整改要求:" + Requirement); + builder.Writeln(); // 换行 + builder.Write(" 整改时间:" + LimitTime + " 整改责任人:" + DutyPersonName + " 监督人:" + + CheckManNames); + builder.Writeln(); // 换行 + + // 插入多张图片(横向排列) + if (Paths.Count > 0) + { + foreach (string imgPath in Paths) + { + // 计算每张图片宽度(总宽度按单元格宽度平分) + double cellWidth = cell.CellFormat.Width; + double imgWidth = (cellWidth - 10 * (Paths.Count - 1)) / Paths.Count - 10; + + // 插入图片并调整尺寸 + Shape image = builder.InsertImage(imgPath); + image.Width = Paths.Count == 1 ? imgWidth / 2 : imgWidth; + // image.Height = image.ImageData.ImageSize.HeightPixels * (imgWidth / image.ImageData.ImageSize.WidthPixels); + image.Height = 120; + + // 图片间留间距(横向排列) + if (imgPath != Paths.Last()) + { + builder.MoveTo(cell.LastParagraph.AppendChild(new Run(doc))); + builder.Write(" "); // 插入空格分隔 + } + } + } + number++; + } + + // 删除模板中的原始占位行 + table.Rows.RemoveAt(0); + } + + + helper.SaveDoc(newUrl); //文件保存,保存为doc + + // 验证文件是否存在 + if (!File.Exists(newUrl)) + { + throw new Exception("文件不存在: " + newUrl); + } + + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", + "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); + } + } + } } \ No newline at end of file diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.designer.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.designer.cs index d1eaead..b695e14 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.designer.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesAudit.aspx.designer.cs @@ -265,5 +265,23 @@ namespace FineUIPro.Web.HSSE.Check /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window WindowAtt; + + /// + /// Menu1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Menu Menu1; + + /// + /// btnPrinter 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.MenuButton btnPrinter; } } diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx index c051836..7b898da 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx @@ -58,7 +58,7 @@ @@ -176,6 +176,13 @@ + + + + + + diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.cs index 2e6d2a9..c005a81 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.cs @@ -6,7 +6,11 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; - +using System.IO; +using System.Linq; +using Aspose.Words; +using Aspose.Words.Drawing; +using Aspose.Words.Tables; namespace FineUIPro.Web.HSSE.Check { public partial class RectifyNoticesRecheck : PageBase @@ -334,5 +338,189 @@ namespace FineUIPro.Web.HSSE.Check } this.lbCom.Hidden = !this.lbDutyPerson.Hidden; } + + + /// + /// 导出 + /// + /// + /// + protected void btnPrinter_Click(object sender, EventArgs e) + { + //获取所有列表导出 + if (!string.IsNullOrEmpty(this.RectifyNoticesId)) + { + var rectifyNotices = RectifyNoticesService.GetRectifyNoticesById(RectifyNoticesId); + string CheckManIds = rectifyNotices.CheckManIds; + string CheckManNames = string.Empty; + if (CheckManIds != null) + { + string[] Ids = CheckManIds.ToString().Split(','); + foreach (string t in Ids) + { + var Name = BLL.UserService.GetUserNameByUserId(t); + if (Name != null) + { + CheckManNames += Name + ","; + } + } + } + + string DutyPersonId = rectifyNotices.DutyPersonId; + string DutyPersonName = UserService.GetUserNameByUserId(DutyPersonId); + + var dataList = (from item in Funs.DB.Check_RectifyNoticesItem + join rectify in Funs.DB.Technique_Rectify + on item.RectifyId equals rectify.RectifyId into rectifyGroup + from rectify in rectifyGroup.DefaultIfEmpty() + where item.RectifyNoticesId == RectifyNoticesId + select new + { + RectifyNoticesItemId = item.RectifyNoticesItemId, + RectifyId = rectify.RectifyName, + RectifyNoticesId = item.RectifyNoticesId, + WrongContent = item.WrongContent, + Requirement = item.Requirement, + LimitTime = item.LimitTime, + RectifyResults = item.RectifyResults, + IsRectify = item.IsRectify + }).ToList(); + + string rootPath = Server.MapPath("~/"); + string initTemplatePath = string.Empty; + string uploadfilepath = string.Empty; + string newUrl = string.Empty; + + initTemplatePath = "File\\Word\\HSSE\\安全质量环保检查记录(模板)建投隐患整改通知单.doc"; + uploadfilepath = rootPath + initTemplatePath; + newUrl = uploadfilepath.Replace(".doc", RectifyNoticesId + ".doc"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + + File.Copy(uploadfilepath, newUrl); + AsposeWordHelper helper = new AsposeWordHelper(); + helper.OpenTempelte(newUrl); //打开模板文件 + + + var project = + (from x in Funs.DB.Base_Project where x.ProjectId == this.CurrUser.LoginProjectId select x) + .FirstOrDefault(); + string projectName = project.ProjectName; + string remark = project.Remark; + + string[] fieldNames = + { + "projectName", "remark" + }; + + object[] fieldValues = + { + projectName, remark + }; + helper.Executefield(fieldNames, fieldValues); //域赋值 + + if (dataList.Count > 0) + { + Document doc = helper.Document; + DocumentBuilder builder = new DocumentBuilder(doc); + Table table = (Table)doc.GetChild(NodeType.Table, 1, true); // 定位第一个表格 + + int number = 1; + foreach (var item in dataList) + { + string WrongContent = item.WrongContent; + string Requirement = item.Requirement; + string LimitTime = item.LimitTime.HasValue + ? $" {item.LimitTime.Value.Year} 年 {item.LimitTime.Value.Month:D2} 月 {item.LimitTime.Value.Day:D2} 日" + : ""; + List Paths = new List(); + + var res = AttachFileService.getFileUrl(item.RectifyNoticesItemId + "#1"); + if (!string.IsNullOrEmpty(res)) + { + string[] arr = res.Split(','); + for (int i = 0; i < arr.Length; i++) + { + Paths.Add(rootPath + arr[i]); + } + } + + // 克隆模板占位行 + Row newRow = (Row)table.LastRow.Clone(true); + table.AppendChild(newRow); + + // 定位到单元格 + Cell cell = newRow.FirstCell; + + // 清空单元格所有段落 + cell.RemoveAllChildren(); + Paragraph para = new Paragraph(doc); // 显式创建段落 + cell.AppendChild(para); + builder.MoveTo(para); // 定位到段落 + + // 插入文本 + builder.Write(" 存在问题" + number.ToString() + ":" + WrongContent); + builder.Writeln(); // 换行 + builder.Write(" 整改要求:" + Requirement); + builder.Writeln(); // 换行 + builder.Write(" 整改时间:" + LimitTime + " 整改责任人:" + DutyPersonName + " 监督人:" + + CheckManNames); + builder.Writeln(); // 换行 + + // 插入多张图片(横向排列) + if (Paths.Count > 0) + { + foreach (string imgPath in Paths) + { + // 计算每张图片宽度(总宽度按单元格宽度平分) + double cellWidth = cell.CellFormat.Width; + double imgWidth = (cellWidth - 10 * (Paths.Count - 1)) / Paths.Count - 10; + + // 插入图片并调整尺寸 + Shape image = builder.InsertImage(imgPath); + image.Width = Paths.Count == 1 ? imgWidth / 2 : imgWidth; + // image.Height = image.ImageData.ImageSize.HeightPixels * (imgWidth / image.ImageData.ImageSize.WidthPixels); + image.Height = 120; + + // 图片间留间距(横向排列) + if (imgPath != Paths.Last()) + { + builder.MoveTo(cell.LastParagraph.AppendChild(new Run(doc))); + builder.Write(" "); // 插入空格分隔 + } + } + } + number++; + } + + // 删除模板中的原始占位行 + table.Rows.RemoveAt(0); + } + + + helper.SaveDoc(newUrl); //文件保存,保存为doc + + // 验证文件是否存在 + if (!File.Exists(newUrl)) + { + throw new Exception("文件不存在: " + newUrl); + } + + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", + "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); + } + } } } \ No newline at end of file diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.designer.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.designer.cs index 16142db..087d7f4 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.designer.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRecheck.aspx.designer.cs @@ -283,5 +283,23 @@ namespace FineUIPro.Web.HSSE.Check /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label lblPageIndex; + + /// + /// Menu1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Menu Menu1; + + /// + /// btnPrinter 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.MenuButton btnPrinter; } } diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx index 2bf3850..79092ce 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx @@ -59,7 +59,7 @@ @@ -100,6 +100,9 @@ + + + @@ -149,6 +152,22 @@ Target="Parent" EnableResize="false" runat="server" IsModal="true" Width="700px" Height="500px"> - + + + + + + + + diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.cs index a6d2d3d..e0678b4 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.cs @@ -6,7 +6,11 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; - +using System.IO; +using System.Linq; +using Aspose.Words; +using Aspose.Words.Drawing; +using Aspose.Words.Tables; namespace FineUIPro.Web.HSSE.Check { public partial class RectifyNoticesRectify : PageBase @@ -273,5 +277,188 @@ namespace FineUIPro.Web.HSSE.Check } } #endregion + + /// + /// 导出 + /// + /// + /// + protected void btnPrinter_Click(object sender, EventArgs e) + { + //获取所有列表导出 + if (!string.IsNullOrEmpty(this.RectifyNoticesId)) + { + var rectifyNotices = RectifyNoticesService.GetRectifyNoticesById(RectifyNoticesId); + string CheckManIds = rectifyNotices.CheckManIds; + string CheckManNames = string.Empty; + if (CheckManIds != null) + { + string[] Ids = CheckManIds.ToString().Split(','); + foreach (string t in Ids) + { + var Name = BLL.UserService.GetUserNameByUserId(t); + if (Name != null) + { + CheckManNames += Name + ","; + } + } + } + + string DutyPersonId = rectifyNotices.DutyPersonId; + string DutyPersonName = UserService.GetUserNameByUserId(DutyPersonId); + + var dataList = (from item in Funs.DB.Check_RectifyNoticesItem + join rectify in Funs.DB.Technique_Rectify + on item.RectifyId equals rectify.RectifyId into rectifyGroup + from rectify in rectifyGroup.DefaultIfEmpty() + where item.RectifyNoticesId == RectifyNoticesId + select new + { + RectifyNoticesItemId = item.RectifyNoticesItemId, + RectifyId = rectify.RectifyName, + RectifyNoticesId = item.RectifyNoticesId, + WrongContent = item.WrongContent, + Requirement = item.Requirement, + LimitTime = item.LimitTime, + RectifyResults = item.RectifyResults, + IsRectify = item.IsRectify + }).ToList(); + + string rootPath = Server.MapPath("~/"); + string initTemplatePath = string.Empty; + string uploadfilepath = string.Empty; + string newUrl = string.Empty; + + initTemplatePath = "File\\Word\\HSSE\\安全质量环保检查记录(模板)建投隐患整改通知单.doc"; + uploadfilepath = rootPath + initTemplatePath; + newUrl = uploadfilepath.Replace(".doc", RectifyNoticesId + ".doc"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + + File.Copy(uploadfilepath, newUrl); + AsposeWordHelper helper = new AsposeWordHelper(); + helper.OpenTempelte(newUrl); //打开模板文件 + + + var project = + (from x in Funs.DB.Base_Project where x.ProjectId == this.CurrUser.LoginProjectId select x) + .FirstOrDefault(); + string projectName = project.ProjectName; + string remark = project.Remark; + + string[] fieldNames = + { + "projectName", "remark" + }; + + object[] fieldValues = + { + projectName, remark + }; + helper.Executefield(fieldNames, fieldValues); //域赋值 + + if (dataList.Count > 0) + { + Document doc = helper.Document; + DocumentBuilder builder = new DocumentBuilder(doc); + Table table = (Table)doc.GetChild(NodeType.Table, 1, true); // 定位第一个表格 + + int number = 1; + foreach (var item in dataList) + { + string WrongContent = item.WrongContent; + string Requirement = item.Requirement; + string LimitTime = item.LimitTime.HasValue + ? $" {item.LimitTime.Value.Year} 年 {item.LimitTime.Value.Month:D2} 月 {item.LimitTime.Value.Day:D2} 日" + : ""; + List Paths = new List(); + + var res = AttachFileService.getFileUrl(item.RectifyNoticesItemId + "#1"); + if (!string.IsNullOrEmpty(res)) + { + string[] arr = res.Split(','); + for (int i = 0; i < arr.Length; i++) + { + Paths.Add(rootPath + arr[i]); + } + } + + // 克隆模板占位行 + Row newRow = (Row)table.LastRow.Clone(true); + table.AppendChild(newRow); + + // 定位到单元格 + Cell cell = newRow.FirstCell; + + // 清空单元格所有段落 + cell.RemoveAllChildren(); + Paragraph para = new Paragraph(doc); // 显式创建段落 + cell.AppendChild(para); + builder.MoveTo(para); // 定位到段落 + + // 插入文本 + builder.Write(" 存在问题" + number.ToString() + ":" + WrongContent); + builder.Writeln(); // 换行 + builder.Write(" 整改要求:" + Requirement); + builder.Writeln(); // 换行 + builder.Write(" 整改时间:" + LimitTime + " 整改责任人:" + DutyPersonName + " 监督人:" + + CheckManNames); + builder.Writeln(); // 换行 + + // 插入多张图片(横向排列) + if (Paths.Count > 0) + { + foreach (string imgPath in Paths) + { + // 计算每张图片宽度(总宽度按单元格宽度平分) + double cellWidth = cell.CellFormat.Width; + double imgWidth = (cellWidth - 10 * (Paths.Count - 1)) / Paths.Count - 10; + + // 插入图片并调整尺寸 + Shape image = builder.InsertImage(imgPath); + image.Width = Paths.Count == 1 ? imgWidth / 2 : imgWidth; + // image.Height = image.ImageData.ImageSize.HeightPixels * (imgWidth / image.ImageData.ImageSize.WidthPixels); + image.Height = 120; + + // 图片间留间距(横向排列) + if (imgPath != Paths.Last()) + { + builder.MoveTo(cell.LastParagraph.AppendChild(new Run(doc))); + builder.Write(" "); // 插入空格分隔 + } + } + } + number++; + } + + // 删除模板中的原始占位行 + table.Rows.RemoveAt(0); + } + + + helper.SaveDoc(newUrl); //文件保存,保存为doc + + // 验证文件是否存在 + if (!File.Exists(newUrl)) + { + throw new Exception("文件不存在: " + newUrl); + } + + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", + "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); + } + } } } \ No newline at end of file diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.designer.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.designer.cs index 4f9d498..044507e 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.designer.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesRectify.aspx.designer.cs @@ -211,5 +211,23 @@ namespace FineUIPro.Web.HSSE.Check /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window WindowAtt; + + /// + /// Menu1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Menu Menu1; + + /// + /// btnPrinter 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.MenuButton btnPrinter; } } diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx index a89a3ed..2084a9e 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx @@ -94,6 +94,9 @@ HeaderText="合格" HeaderTextAlign="Center" TextAlign="Center"> + + + @@ -135,6 +138,22 @@ Target="Parent" EnableResize="false" runat="server" IsModal="true" Width="700px" Height="500px"> + + + + + + + diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.cs index 1ece950..5fe685d 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.cs @@ -3,7 +3,11 @@ using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; - +using System.IO; +using System.Linq; +using Aspose.Words; +using Aspose.Words.Drawing; +using Aspose.Words.Tables; namespace FineUIPro.Web.HSSE.Check { public partial class RectifyNoticesView1 : PageBase @@ -120,5 +124,189 @@ namespace FineUIPro.Web.HSSE.Check } return url; } + + + /// + /// 导出 + /// + /// + /// + protected void btnPrinter_Click(object sender, EventArgs e) + { + //获取所有列表导出 + if (!string.IsNullOrEmpty(this.RectifyNoticesId)) + { + var rectifyNotices = RectifyNoticesService.GetRectifyNoticesById(RectifyNoticesId); + string CheckManIds = rectifyNotices.CheckManIds; + string CheckManNames = string.Empty; + if (CheckManIds != null) + { + string[] Ids = CheckManIds.ToString().Split(','); + foreach (string t in Ids) + { + var Name = BLL.UserService.GetUserNameByUserId(t); + if (Name != null) + { + CheckManNames += Name + ","; + } + } + } + + string DutyPersonId = rectifyNotices.DutyPersonId; + string DutyPersonName = UserService.GetUserNameByUserId(DutyPersonId); + + var dataList = (from item in Funs.DB.Check_RectifyNoticesItem + join rectify in Funs.DB.Technique_Rectify + on item.RectifyId equals rectify.RectifyId into rectifyGroup + from rectify in rectifyGroup.DefaultIfEmpty() + where item.RectifyNoticesId == RectifyNoticesId + select new + { + RectifyNoticesItemId = item.RectifyNoticesItemId, + RectifyId = rectify.RectifyName, + RectifyNoticesId = item.RectifyNoticesId, + WrongContent = item.WrongContent, + Requirement = item.Requirement, + LimitTime = item.LimitTime, + RectifyResults = item.RectifyResults, + IsRectify = item.IsRectify + }).ToList(); + + string rootPath = Server.MapPath("~/"); + string initTemplatePath = string.Empty; + string uploadfilepath = string.Empty; + string newUrl = string.Empty; + + initTemplatePath = "File\\Word\\HSSE\\安全质量环保检查记录(模板)建投隐患整改通知单.doc"; + uploadfilepath = rootPath + initTemplatePath; + newUrl = uploadfilepath.Replace(".doc", RectifyNoticesId + ".doc"); + if (File.Exists(newUrl)) + { + File.Delete(newUrl); + } + + File.Copy(uploadfilepath, newUrl); + AsposeWordHelper helper = new AsposeWordHelper(); + helper.OpenTempelte(newUrl); //打开模板文件 + + + var project = + (from x in Funs.DB.Base_Project where x.ProjectId == this.CurrUser.LoginProjectId select x) + .FirstOrDefault(); + string projectName = project.ProjectName; + string remark = project.Remark; + + string[] fieldNames = + { + "projectName", "remark" + }; + + object[] fieldValues = + { + projectName, remark + }; + helper.Executefield(fieldNames, fieldValues); //域赋值 + + if (dataList.Count > 0) + { + Document doc = helper.Document; + DocumentBuilder builder = new DocumentBuilder(doc); + Table table = (Table)doc.GetChild(NodeType.Table, 1, true); // 定位第一个表格 + + int number = 1; + foreach (var item in dataList) + { + string WrongContent = item.WrongContent; + string Requirement = item.Requirement; + string LimitTime = item.LimitTime.HasValue + ? $" {item.LimitTime.Value.Year} 年 {item.LimitTime.Value.Month:D2} 月 {item.LimitTime.Value.Day:D2} 日" + : ""; + List Paths = new List(); + + var res = AttachFileService.getFileUrl(item.RectifyNoticesItemId + "#1"); + if (!string.IsNullOrEmpty(res)) + { + string[] arr = res.Split(','); + for (int i = 0; i < arr.Length; i++) + { + Paths.Add(rootPath + arr[i]); + } + } + + // 克隆模板占位行 + Row newRow = (Row)table.LastRow.Clone(true); + table.AppendChild(newRow); + + // 定位到单元格 + Cell cell = newRow.FirstCell; + + // 清空单元格所有段落 + cell.RemoveAllChildren(); + Paragraph para = new Paragraph(doc); // 显式创建段落 + cell.AppendChild(para); + builder.MoveTo(para); // 定位到段落 + + // 插入文本 + builder.Write(" 存在问题" + number.ToString() + ":" + WrongContent); + builder.Writeln(); // 换行 + builder.Write(" 整改要求:" + Requirement); + builder.Writeln(); // 换行 + builder.Write(" 整改时间:" + LimitTime + " 整改责任人:" + DutyPersonName + " 监督人:" + + CheckManNames); + builder.Writeln(); // 换行 + + // 插入多张图片(横向排列) + if (Paths.Count > 0) + { + foreach (string imgPath in Paths) + { + // 计算每张图片宽度(总宽度按单元格宽度平分) + double cellWidth = cell.CellFormat.Width; + double imgWidth = (cellWidth - 10 * (Paths.Count - 1)) / Paths.Count - 10; + + // 插入图片并调整尺寸 + Shape image = builder.InsertImage(imgPath); + image.Width = Paths.Count == 1 ? imgWidth / 2 : imgWidth; + // image.Height = image.ImageData.ImageSize.HeightPixels * (imgWidth / image.ImageData.ImageSize.WidthPixels); + image.Height = 120; + + // 图片间留间距(横向排列) + if (imgPath != Paths.Last()) + { + builder.MoveTo(cell.LastParagraph.AppendChild(new Run(doc))); + builder.Write(" "); // 插入空格分隔 + } + } + } + number++; + } + + // 删除模板中的原始占位行 + table.Rows.RemoveAt(0); + } + + + helper.SaveDoc(newUrl); //文件保存,保存为doc + + // 验证文件是否存在 + if (!File.Exists(newUrl)) + { + throw new Exception("文件不存在: " + newUrl); + } + + string fileName = Path.GetFileName(newUrl); + FileInfo info = new FileInfo(newUrl); + long fileSize = info.Length; + Response.Clear(); + Response.ContentType = "application/x-zip-compressed"; + Response.AddHeader("Content-Disposition", + "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8)); + Response.AddHeader("Content-Length", fileSize.ToString()); + Response.TransmitFile(newUrl, 0, fileSize); + Response.Flush(); + Response.Close(); + File.Delete(newUrl); + } + } } } \ No newline at end of file diff --git a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.designer.cs b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.designer.cs index 25f3236..3c88829 100644 --- a/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.designer.cs +++ b/SUBQHSE/FineUIPro.Web/HSSE/Check/RectifyNoticesView.aspx.designer.cs @@ -7,11 +7,13 @@ // //------------------------------------------------------------------------------ -namespace FineUIPro.Web.HSSE.Check { - - - public partial class RectifyNoticesView1 { - +namespace FineUIPro.Web.HSSE.Check +{ + + + public partial class RectifyNoticesView1 + { + /// /// form1 控件。 /// @@ -20,7 +22,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.HtmlControls.HtmlForm form1; - + /// /// PageManager1 控件。 /// @@ -29,7 +31,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.PageManager PageManager1; - + /// /// Panel4 控件。 /// @@ -38,7 +40,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Panel Panel4; - + /// /// SimpleForm1 控件。 /// @@ -47,7 +49,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Form SimpleForm1; - + /// /// txtProjectName 控件。 /// @@ -56,7 +58,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtProjectName; - + /// /// txtRectifyNoticesCode 控件。 /// @@ -65,7 +67,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtRectifyNoticesCode; - + /// /// txtUnitId 控件。 /// @@ -74,7 +76,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtUnitId; - + /// /// txtWorkAreaId 控件。 /// @@ -83,7 +85,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtWorkAreaId; - + /// /// txtCheckPersonId 控件。 /// @@ -92,7 +94,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtCheckPersonId; - + /// /// txtCheckPerson 控件。 /// @@ -101,7 +103,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtCheckPerson; - + /// /// txtCheckedDate 控件。 /// @@ -110,7 +112,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox txtCheckedDate; - + /// /// drpHiddenHazardType 控件。 /// @@ -119,7 +121,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.TextBox drpHiddenHazardType; - + /// /// Grid1 控件。 /// @@ -128,7 +130,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid Grid1; - + /// /// Label1 控件。 /// @@ -137,7 +139,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label Label1; - + /// /// lbImageUrl 控件。 /// @@ -146,7 +148,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label lbImageUrl; - + /// /// Label2 控件。 /// @@ -155,7 +157,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label Label2; - + /// /// gvFlowOperate 控件。 /// @@ -164,7 +166,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Grid gvFlowOperate; - + /// /// lblPageIndex 控件。 /// @@ -173,7 +175,7 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::System.Web.UI.WebControls.Label lblPageIndex; - + /// /// WindowAtt 控件。 /// @@ -182,5 +184,23 @@ namespace FineUIPro.Web.HSSE.Check { /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 /// protected global::FineUIPro.Window WindowAtt; + + /// + /// Menu1 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.Menu Menu1; + + /// + /// btnPrinter 控件。 + /// + /// + /// 自动生成的字段。 + /// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。 + /// + protected global::FineUIPro.MenuButton btnPrinter; } } diff --git a/SUBQHSE/WebAPI/Controllers/HSSE/InformedConsentFormController.cs b/SUBQHSE/WebAPI/Controllers/HSSE/InformedConsentFormController.cs index ef2f606..3f1db27 100644 --- a/SUBQHSE/WebAPI/Controllers/HSSE/InformedConsentFormController.cs +++ b/SUBQHSE/WebAPI/Controllers/HSSE/InformedConsentFormController.cs @@ -71,7 +71,7 @@ namespace WebAPI.Controllers.HSSE /// /// [HttpPost] - public Model.ResponeData updateSignTime(string PersonId, DateTime? newSignTime = null) + public Model.ResponeData updateSignTime([FromBody] Item item) { using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString)) { @@ -79,11 +79,44 @@ namespace WebAPI.Controllers.HSSE try { // 查找要修改的记录 - var person = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == PersonId); + var person = db.SitePerson_Person.FirstOrDefault(x => x.PersonId == item.PersonId); if (person != null) { - person.SignTime = newSignTime.HasValue ? newSignTime.Value : DateTime.Now; // 更新签字时间 + person.SignTime = item.newSignTime.HasValue ? item.newSignTime.Value : DateTime.Now; // 更新签字时间 db.SubmitChanges(); + + Model.ToDoItem toDoItem = new Model.ToDoItem + { + MenuId = Const.PersonListMenuId, + DataId = item.PersonId + "_1", + UrlStr = item.AttachUrl1, + }; + if (!string.IsNullOrEmpty(item.AttachUrl1)) + { + APIUpLoadFileService.SaveAttachUrl(toDoItem); + } + + toDoItem.DataId = item.PersonId + "_2"; + toDoItem.UrlStr = item.AttachUrl2; + if (!string.IsNullOrEmpty(item.AttachUrl2)) + { + APIUpLoadFileService.SaveAttachUrl(toDoItem); + } + + toDoItem.DataId = item.PersonId + "_3"; + toDoItem.UrlStr = item.AttachUrl3; + if (!string.IsNullOrEmpty(item.AttachUrl3)) + { + APIUpLoadFileService.SaveAttachUrl(toDoItem); + } + + toDoItem.DataId = item.PersonId + "_4"; + toDoItem.UrlStr = item.AttachUrl4; + if (!string.IsNullOrEmpty(item.AttachUrl4)) + { + APIUpLoadFileService.SaveAttachUrl(toDoItem); + } + responeData.code = 1; responeData.message = "保存成功。"; } @@ -100,4 +133,14 @@ namespace WebAPI.Controllers.HSSE #endregion } + + public class Item + { + public string PersonId { get; set; } + public string AttachUrl1 { get; set; } + public string AttachUrl2 { get; set; } + public string AttachUrl3 { get; set; } + public string AttachUrl4 { get; set; } + public DateTime? newSignTime { get; set; } + } } \ No newline at end of file