修改安全实施计划导出及进度功能

This commit is contained in:
2023-07-25 14:08:48 +08:00
parent df904cd642
commit b8dae5be20
14 changed files with 1512 additions and 174 deletions
@@ -143,4 +143,4 @@
}
</script>
</body>
</html>
</html>
@@ -398,56 +398,53 @@ namespace FineUIPro.Web.ZHGL.Plan
}
projectName = projectName.Replace("/", "_");
newUrl = uploadfilepath.Replace(".doc", projectName + ".doc");
filePath = uploadfilepath.Replace(".doc", projectName + ".pdf");
if (File.Exists(newUrl))
{
File.Delete(newUrl);
}
File.Copy(uploadfilepath, newUrl);
///更新书签
Document doc = new Aspose.Words.Document(newUrl);
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
builder.MoveToBookmark("tab");
builder.StartTable();
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.CellFormat.Borders.Color = System.Drawing.Color.Black;
builder.Bold = false;
builder.RowFormat.Height = 20;
builder.Font.Size = 9;
#region
//工程名称和项目部编制人员
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("工程名称");
//写入第一行
Bookmark bookmarkProjectName = doc.Range.Bookmarks["ProjectName"];
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 130;
builder.Font.Bold = false;
var project = ProjectService.GetProjectByProjectId(actionPlanList.ProjectId);
var ActionPlan_ActionPlanListApproveList = db.ActionPlan_ActionPlanListApprove.Where(x => x.ActionPlanListId == Id && x.ApproveType == "2").ToList();
if (project != null)
{
if (project.ProjectName.Length > 20 && ActionPlan_ActionPlanListApproveList.Count != 0)
{
builder.Write(project.ProjectName.Substring(0, 20) + "\n" +
project.ProjectName.Substring(20));
}
else
{
builder.Write(project.ProjectName);
}
if (bookmarkProjectName != null)
{
if (project != null)
{
if (project.ProjectName.Length > 20 && ActionPlan_ActionPlanListApproveList.Count != 0)
{
bookmarkProjectName.Text = project.ProjectName.Substring(0, 20) + "\n" +
project.ProjectName.Substring(20);
}
else
{
bookmarkProjectName.Text = project.ProjectName;
}
}
}
builder.EndRow();
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
builder.MoveToBookmark("tab");
builder.StartTable();
builder.CellFormat.Borders.LineStyle = LineStyle.Single;
builder.CellFormat.Borders.Color = System.Drawing.Color.Black;
builder.Bold = false;
builder.RowFormat.Height = 20;
builder.Font.Size = 9;
#region
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
@@ -462,7 +459,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 130;
builder.CellFormat.Width = 300;
builder.Font.Bold = false;
var getCompileMan = Person_PersonsService.GetPerson_PersonsById(actionPlanList.CompileMan);
if (!string.IsNullOrEmpty(getCompileMan.SignatureUrl) && File.Exists(rootPath + getCompileMan.SignatureUrl))
@@ -503,7 +500,7 @@ namespace FineUIPro.Web.ZHGL.Plan
//判断是不是最后一个
if (ActionPlan_ActionPlanListApproveList.Count == i + 1)
{
builder.CellFormat.Width = 40;
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(getApproveMan.SignatureUrl) && File.Exists(rootPath + getApproveMan.SignatureUrl))
{
@@ -520,12 +517,12 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 90;
builder.CellFormat.Width = 150;
builder.Write("");
}
else
{
builder.CellFormat.Width = 40;
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(getApproveMan.SignatureUrl) && File.Exists(rootPath + getApproveMan.SignatureUrl))
{
@@ -547,7 +544,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 70;
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("项目部审核人");
@@ -556,7 +553,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 20;
builder.CellFormat.Width = 50;
var getApproveMan2 = Person_PersonsService.GetPerson_PersonsById(ActionPlan_ActionPlanListApproveList[i + 1].ApproveMan);
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(getApproveMan2.SignatureUrl) && File.Exists(rootPath + getApproveMan2.SignatureUrl))
@@ -594,7 +591,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 230;
builder.CellFormat.Width = 400;
builder.Font.Bold = true;
builder.Write("主要评审部门");
builder.EndRow();
@@ -604,7 +601,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 80;
builder.CellFormat.Width = 150;
builder.Font.Bold = true;
builder.Write("评审部门");
@@ -613,7 +610,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 80;
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("评审意见");
@@ -622,7 +619,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 70;
builder.CellFormat.Width = 150;
builder.Font.Bold = true;
builder.Write("评审部门负责人/日期");
builder.EndRow();
@@ -635,7 +632,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 80;
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
builder.Write("施工管理部");
//评审意见
@@ -644,7 +641,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 80;
builder.CellFormat.Width = 100;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(item.ApproveIdea))
{
@@ -662,7 +659,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 70;
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (item.ApproveDate != null)
{
@@ -692,7 +689,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 80;
builder.CellFormat.Width = 150;
var departModel = db.Base_Depart.FirstOrDefault(x => x.DepartId == item.DepartId);
builder.Font.Bold = false;
if (departModel != null)
@@ -705,7 +702,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 80;
builder.CellFormat.Width = 100;
builder.Font.Bold = false;
if (!string.IsNullOrEmpty(item.ApproveIdea))
{
@@ -723,7 +720,7 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;//垂直居中对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 70;
builder.CellFormat.Width = 150;
builder.Font.Bold = false;
if (item.ApproveDate != null)
{
@@ -763,13 +760,13 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Bottom;//底部对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//水平居中对齐
builder.CellFormat.Width = 130;
builder.CellFormat.Width = 300;
builder.Font.Bold = true;
builder.RowFormat.Height = 40;
builder.Write("公司安全总监/部门负责人:");
builder.Write(" 年");
builder.Write(" 年");
builder.Write(" 月");
builder.Write(" 日");
builder.Write(" 日");
builder.EndRow();
builder.InsertCell();
@@ -779,20 +776,20 @@ namespace FineUIPro.Web.ZHGL.Plan
builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;//水平居中对齐
builder.CellFormat.Width = 100;
builder.Font.Bold = true;
builder.Write("审");
builder.Write("审");
//公司安全总监/部门负责人
builder.InsertCell();
builder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;
builder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Bottom;//底部对齐
builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;//水平居中对齐
builder.CellFormat.Width = 130;
builder.CellFormat.Width = 300;
builder.Font.Bold = true;
builder.RowFormat.Height = 40;
builder.Write("公司主管生产/安全领导:");
builder.Write(" 年");
builder.Write(" 年");
builder.Write(" 月");
builder.Write(" 日");
builder.Write(" 日");
builder.EndRow();
builder.Font.Bold = false;
@@ -802,17 +799,24 @@ namespace FineUIPro.Web.ZHGL.Plan
}
doc.Save(newUrl);
string fileName = Path.GetFileName(newUrl);
FileInfo info = new FileInfo(newUrl);
//生成PDF文件
string pdfUrl = newUrl.Replace(".doc", ".pdf");
Document doc1 = new Aspose.Words.Document(newUrl);
//验证参数
if (doc1 == null) { throw new Exception("Word文件无效"); }
doc1.Save(pdfUrl, Aspose.Words.SaveFormat.Pdf);//还可以改成其它格式
string fileName = Path.GetFileName(filePath);
FileInfo info = new FileInfo(pdfUrl);
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.TransmitFile(pdfUrl, 0, fileSize);
Response.Flush();
Response.Close();
File.Delete(newUrl);
File.Delete(pdfUrl);
}
catch (Exception ex)
{