质量月报导出问题处理

This commit is contained in:
夏菊 2025-04-24 20:01:19 +08:00
parent 9df2becf42
commit 6bebbe15ef
1 changed files with 52 additions and 61 deletions

View File

@ -152,7 +152,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
* @param doc Document对象 * @param doc Document对象
* @return * @return
*/ */
public static Cell CreateCell(String value, Document doc, double cellWidth, string cellMerge = "",string CenterPage="",string cellUnitLeft="") public static Cell CreateCell(String value, Document doc, double cellWidth, string cellMerge = "", string CenterPage = "", string cellUnitLeft = "")
{ {
Cell cell = new Cell(doc); Cell cell = new Cell(doc);
Paragraph p = new Paragraph(doc); Paragraph p = new Paragraph(doc);
@ -227,10 +227,10 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
var endDate = Convert.ToDateTime(weekModel.EndDate); var endDate = Convert.ToDateTime(weekModel.EndDate);
//获取project //获取project
var pModel = db.Base_Project.FirstOrDefault(x => x.ProjectId == weekModel.ProjectId); var pModel = db.Base_Project.FirstOrDefault(x => x.ProjectId == weekModel.ProjectId);
var urlHz = startDate.ToString("yyyyMMdd")+"-" var urlHz = startDate.ToString("yyyyMMdd") + "-"
+ endDate.ToString("yyyyMMdd"); + endDate.ToString("yyyyMMdd");
newUrl = uploadfilepath.Replace("项目质量月报", pModel.ShortName + "项目质量月报(第"+ weekModel.SortId + "期)"+ urlHz); newUrl = uploadfilepath.Replace("项目质量月报", pModel.ShortName + "项目质量月报(第" + weekModel.SortId + "期)" + urlHz);
if (File.Exists(newUrl)) if (File.Exists(newUrl))
{ {
@ -250,8 +250,9 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
orderby x.UnitName orderby x.UnitName
select x).FirstOrDefault(); select x).FirstOrDefault();
Bookmark bkmark = doc.Range.Bookmarks["username"]; Bookmark bkmark = doc.Range.Bookmarks["username"];
if (bkmark != null) { if (bkmark != null)
{
if (unitsYz != null) if (unitsYz != null)
{ {
@ -264,14 +265,14 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
//} //}
} }
bkmark= doc.Range.Bookmarks["projectNo"]; bkmark = doc.Range.Bookmarks["projectNo"];
if (bkmark!=null) if (bkmark != null)
{ {
bkmark.Text = pModel.ProjectCode; bkmark.Text = pModel.ProjectCode;
} }
bkmark = doc.Range.Bookmarks["createdate"]; bkmark = doc.Range.Bookmarks["createdate"];
if (bkmark!=null) if (bkmark != null)
{ {
bkmark.Text = weekModel.CreateDate.ToString().Split(' ')[0].Replace('/', '.'); bkmark.Text = weekModel.CreateDate.ToString().Split(' ')[0].Replace('/', '.');
} }
@ -283,7 +284,8 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
} }
bkmark = doc.Range.Bookmarks["quamanagername"]; bkmark = doc.Range.Bookmarks["quamanagername"];
if (bkmark != null) { if (bkmark != null)
{
//var zlName = ""; //var zlName = "";
////根据项目获取质量经理 ////根据项目获取质量经理
//var puserList = db.Project_ProjectUser.Where(x => x.ProjectId == weekModel.ProjectId && x.RoleId.Contains(BLL.Const.QAManager)).ToList(); //var puserList = db.Project_ProjectUser.Where(x => x.ProjectId == weekModel.ProjectId && x.RoleId.Contains(BLL.Const.QAManager)).ToList();
@ -307,19 +309,19 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
{ {
var sdate = Convert.ToDateTime(weekModel.StartDate); var sdate = Convert.ToDateTime(weekModel.StartDate);
var edate = Convert.ToDateTime(weekModel.EndDate); var edate = Convert.ToDateTime(weekModel.EndDate);
bkmark.Text = sdate.Year+"年"+ sdate.Month +"月"+ sdate.Day+"日至"+ bkmark.Text = sdate.Year + "年" + sdate.Month + "月" + sdate.Day + "日至" +
edate.Year + "年" + edate.Month + "月" + edate.Day + "日"; edate.Year + "年" + edate.Month + "月" + edate.Day + "日";
} }
bkmark = doc.Range.Bookmarks["reportindex"]; bkmark = doc.Range.Bookmarks["reportindex"];
if (bkmark!=null) if (bkmark != null)
{ {
bkmark.Text = weekModel.SortId; bkmark.Text = weekModel.SortId;
} }
bkmark = doc.Range.Bookmarks["fromcode"]; bkmark = doc.Range.Bookmarks["fromcode"];
//fromcode,项目号-RM-PQM-顺序号 //fromcode,项目号-RM-PQM-顺序号
if (bkmark!=null) if (bkmark != null)
{ {
bkmark.Text = pModel.ProjectCode + "-RM-PQM-" + weekModel.SortId; bkmark.Text = pModel.ProjectCode + "-RM-PQM-" + weekModel.SortId;
} }
@ -333,12 +335,13 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
//跳过页眉的表头 //跳过页眉的表头
while (isYm) while (isYm)
{ {
if (table.Range.Text.Substring(0, 2)!="序号") if (table.Range.Text.Substring(0, 2) != "序号")
{ {
whileIndex += 1; whileIndex += 1;
table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true); table = (Aspose.Words.Tables.Table)doc.GetChild(NodeType.Table, whileIndex, true);
} }
else{ else
{
isYm = false; isYm = false;
} }
} }
@ -348,8 +351,8 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
{ {
//创建行 //创建行
Row row = new Row(doc); Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width,"","1")); row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.ProStage, doc, table.FirstRow.Cells[1].CellFormat.Width,"","", "unit")); row.Cells.Add(CreateCell(item.ProStage, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.ProDescribe, doc, table.FirstRow.Cells[2].CellFormat.Width, "", "", "unit")); row.Cells.Add(CreateCell(item.ProDescribe, doc, table.FirstRow.Cells[2].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.TargetValue, doc, table.FirstRow.Cells[3].CellFormat.Width)); row.Cells.Add(CreateCell(item.TargetValue, doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthPer, doc, table.FirstRow.Cells[4].CellFormat.Width)); row.Cells.Add(CreateCell(item.MonthPer, doc, table.FirstRow.Cells[4].CellFormat.Width));
@ -368,7 +371,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
bkmark = doc.Range.Bookmarks["Content1"]; bkmark = doc.Range.Bookmarks["Content1"];
if (bkmark != null) if (bkmark != null)
{ {
bkmark.Text= txtReportList.FirstOrDefault(x => x.ContentType == "0").ContentText; bkmark.Text = txtReportList.FirstOrDefault(x => x.ContentType == "0").ContentText;
} }
bkmark = doc.Range.Bookmarks["Content2"]; bkmark = doc.Range.Bookmarks["Content2"];
@ -391,7 +394,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
#endregion #endregion
var ContuructionAllList = db.Report_Construction_Plan.Where(x => x.ReportId == Id).OrderBy(x=>x.UnitOrMajor).ToList(); var ContuructionAllList = db.Report_Construction_Plan.Where(x => x.ReportId == Id).OrderBy(x => x.UnitOrMajor).ToList();
#region 3. #region 3.
@ -422,7 +425,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
//创建行 //创建行
Row row = new Row(doc); Row row = new Row(doc);
row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1")); row.Cells.Add(CreateCell(numberIndex.ToString(), doc, table.FirstRow.Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width,"","","unit")); row.Cells.Add(CreateCell(item.UnitOrMajor, doc, table.FirstRow.Cells[1].CellFormat.Width, "", "", "unit"));
row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width)); row.Cells.Add(CreateCell(item.Quantity1.ToString(), doc, table.FirstRow.Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width)); row.Cells.Add(CreateCell(item.Quantity2.ToString(), doc, table.FirstRow.Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width, "", "", "unit")); row.Cells.Add(CreateCell(item.Remarks, doc, table.FirstRow.Cells[4].CellFormat.Width, "", "", "unit"));
@ -468,7 +471,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
} }
} }
numberIndex = 1; numberIndex = 1;
int? num1 = 0, num2 = 0, num3=0; int? num1 = 0, num2 = 0, num3 = 0;
foreach (var item in wdsgfaList) foreach (var item in wdsgfaList)
{ {
//创建行 //创建行
@ -482,7 +485,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
table.Rows.Insert(numberIndex, row); table.Rows.Insert(numberIndex, row);
num1 += item.Quantity1; num1 += item.Quantity1;
num2 += item.Quantity2; num2 += item.Quantity2;
num3+= item.Quantity3; num3 += item.Quantity3;
numberIndex += 1; numberIndex += 1;
} }
//自动设置表格样式 //自动设置表格样式
@ -677,9 +680,11 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
} }
} }
int i = 1; int i = 1;
var cNProfessionals = from x in Funs.DB.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId var cNProfessionals = from x in Funs.DB.Base_CNProfessional
where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId
&& x.CNProfessionalId != BLL.Const.ComprehensiveId && x.CNProfessionalId != BLL.Const.ComprehensiveId
orderby x.SortIndex select x; orderby x.SortIndex
select x;
foreach (var item in cNProfessionals) foreach (var item in cNProfessionals)
{ {
//专业下所有集合 //专业下所有集合
@ -704,7 +709,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
Quantity5Sum += Convert.ToInt32(checkStatisc.OneOKRate); Quantity5Sum += Convert.ToInt32(checkStatisc.OneOKRate);
Quantity6Sum += Convert.ToInt32(checkStatisc.TotalOneOKRate); Quantity6Sum += Convert.ToInt32(checkStatisc.TotalOneOKRate);
} }
if (StatisticsList.Count>0) if (StatisticsList.Count > 0)
{ {
isYm = true; isYm = true;
whileIndex += 1; whileIndex += 1;
@ -728,7 +733,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
{ {
//创建行 //创建行
Row row = new Row(doc); Row row = new Row(doc);
row.Cells.Add(CreateCell((numberIndex-1).ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1")); row.Cells.Add(CreateCell((numberIndex - 1).ToString(), doc, table.Rows[0].Cells[0].CellFormat.Width, "", "1"));
row.Cells.Add(CreateCell(item.WorkName, doc, table.Rows[0].Cells[1].CellFormat.Width)); row.Cells.Add(CreateCell(item.WorkName, doc, table.Rows[0].Cells[1].CellFormat.Width));
row.Cells.Add(CreateCell(item.CheckNum.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width)); row.Cells.Add(CreateCell(item.CheckNum.ToString(), doc, table.Rows[1].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalCheckNum.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width)); row.Cells.Add(CreateCell(item.TotalCheckNum.ToString(), doc, table.Rows[1].Cells[3].CellFormat.Width));
@ -844,7 +849,7 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
Quantity7Sum += passWelderStatisc.OtherMountGuard; Quantity7Sum += passWelderStatisc.OtherMountGuard;
Quantity8Sum += passWelderStatisc.OtherTotal; Quantity8Sum += passWelderStatisc.OtherTotal;
} }
if (PassWelderList.Count>0) if (PassWelderList.Count > 0)
{ {
isYm = true; isYm = true;
whileIndex += 1; whileIndex += 1;
@ -958,7 +963,8 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
//自动设置表格样式 //自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths); table.AutoFit(AutoFitBehavior.FixedColumnWidths);
} }
else { else
{
isYm = true; isYm = true;
numberIndex = 1; numberIndex = 1;
whileIndex += 1; whileIndex += 1;
@ -1003,24 +1009,16 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
int? totalNum0 = 0, totalNum1 = 0;//拍片数量合计 int? totalNum0 = 0, totalNum1 = 0;//拍片数量合计
endDate = endDate.AddDays(1);
foreach (var item in units) foreach (var item in units)
{ {
int? num0 = 0, num1 = 0;//拍片数量小计 int? num0 = 0, num1 = 0;//拍片数量小计
var query = from c in db.ProcessControl_NondestructiveTest_New var query = from c in db.ProcessControl_NondestructiveTest_New
join u in db.Base_Unit on c.UnitId equals u.UnitId join u in db.Base_Unit on c.UnitId equals u.UnitId
where c.ProjectId == this.CurrUser.LoginProjectId && c.UnitId == item.UnitId where c.ProjectId == this.CurrUser.LoginProjectId && c.UnitId == item.UnitId
&& c.CreateDate >= Convert.ToDateTime(startDate) && c.CreateDate <= Convert.ToDateTime(endDate) && c.CreateDate >= Convert.ToDateTime(startDate) && c.CreateDate < Convert.ToDateTime(endDate)
orderby c.CreateDate descending orderby c.CreateDate descending
select new select new
{ {
c.CreateDate, c.CreateDate,
c.ProjectId, c.ProjectId,
@ -1040,7 +1038,6 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
model.Id = Guid.NewGuid().ToString(); model.Id = Guid.NewGuid().ToString();
model.CreateMan = item.UnitName;//用作存储施工单位名称 model.CreateMan = item.UnitName;//用作存储施工单位名称
model.ProfessionalName = "工艺管道"; model.ProfessionalName = "工艺管道";
if (gygdModel != null) if (gygdModel != null)
{ {
model.MonthQuantity = gygdModel.MonthQuantity; model.MonthQuantity = gygdModel.MonthQuantity;
@ -1068,9 +1065,6 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
NondestructiveTestlist.Add(model); NondestructiveTestlist.Add(model);
} }
//地管 //地管
gygdModel = query.FirstOrDefault(x => x.ProfessionalName == "地管"); gygdModel = query.FirstOrDefault(x => x.ProfessionalName == "地管");
model = new Model.ProcessControl_NondestructiveTest_New(); model = new Model.ProcessControl_NondestructiveTest_New();
@ -1175,11 +1169,8 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
int pageCount = 1; int pageCount = 1;
foreach (var item in NondestructiveTestlist) foreach (var item in NondestructiveTestlist)
{ {
//创建行 //创建行
Row row = new Row(doc); Row row = new Row(doc);
//如果是第一列,或者 //如果是第一列,或者
if (numberIndex == 1 || Unitname != item.CreateMan) if (numberIndex == 1 || Unitname != item.CreateMan)
{ {
@ -1199,8 +1190,6 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
Unitname = item.CreateMan; Unitname = item.CreateMan;
} }
row.Cells.Add(CreateCell(item.ProfessionalName.ToString(), doc, table.Rows[0].Cells[2].CellFormat.Width)); row.Cells.Add(CreateCell(item.ProfessionalName.ToString(), doc, table.Rows[0].Cells[2].CellFormat.Width));
row.Cells.Add(CreateCell(item.MonthQuantity.ToString(), doc, table.Rows[0].Cells[3].CellFormat.Width)); row.Cells.Add(CreateCell(item.MonthQuantity.ToString(), doc, table.Rows[0].Cells[3].CellFormat.Width));
row.Cells.Add(CreateCell(item.TotalQuantity.ToString(), doc, table.Rows[0].Cells[4].CellFormat.Width)); row.Cells.Add(CreateCell(item.TotalQuantity.ToString(), doc, table.Rows[0].Cells[4].CellFormat.Width));
@ -1233,7 +1222,8 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
//自动设置表格样式 //自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths); table.AutoFit(AutoFitBehavior.FixedColumnWidths);
} }
else { else
{
isYm = true; isYm = true;
numberIndex = 1; numberIndex = 1;
whileIndex += 1; whileIndex += 1;
@ -1324,7 +1314,8 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
//自动设置表格样式 //自动设置表格样式
table.AutoFit(AutoFitBehavior.FixedColumnWidths); table.AutoFit(AutoFitBehavior.FixedColumnWidths);
} }
else { else
{
isYm = true; isYm = true;
numberIndex = 1; numberIndex = 1;
whileIndex += 1; whileIndex += 1;