This commit is contained in:
2025-03-09 22:20:21 +08:00
parent 47631bb84d
commit 23f7bfbb1d
3 changed files with 199 additions and 23 deletions
@@ -11,6 +11,7 @@ using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.InfoQuery
@@ -287,24 +288,33 @@ namespace FineUIPro.Web.HJGL.InfoQuery
{
Model.View_HJGL_WeldJoint model = new Model.View_HJGL_WeldJoint();
model.ProjectId = this.CurrUser.LoginProjectId;
model.WeldJointCode = this.txtWeldJointCode.Text;
if (this.tvControlItem.SelectedNode.CommandName.Split('|').Count() == 2)
{
model.UnitWorkId = this.tvControlItem.SelectedNodeID;
model.WeldJointCode = this.txtWeldJointCode.Text;
var list = BLL.WeldJointService.GetDataBymodel(model, Grid1.PageIndex, Grid1.PageSize);
Grid1.RecordCount = list.Total;
Grid1.DataSource = list.Data;
Grid1.DataBind();
}
else if (this.tvControlItem.SelectedNode.CommandName == "管线")
{
model.PipelineId = this.tvControlItem.SelectedNodeID;
var list = BLL.WeldJointService.GetViewWeldJointsBymodel(model);
View_HJGL_WeldJoint = list;
Grid1.RecordCount = list.Count;
var table = list.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize).ToList();
Grid1.DataSource = table;
Grid1.DataBind();
}
model.WeldJointCode = this.txtWeldJointCode.Text;
var list = BLL.WeldJointService.GetViewWeldJointsBymodel(model);
View_HJGL_WeldJoint = list;
Grid1.RecordCount = list.Count;
// var table = this.GetPagedDataTable(Grid1, list);
var table = list.Skip(Grid1.PageSize * (Grid1.PageIndex)).Take(Grid1.PageSize).ToList();
Grid1.DataSource = table;
Grid1.DataBind();
}
@@ -477,14 +487,15 @@ namespace FineUIPro.Web.HJGL.InfoQuery
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
if (this.tvControlItem.SelectedNode.CommandName.Split('|').Count() == 2)
if (this.tvControlItem.SelectedNode.CommandName.Split('|').Count() == 2) //单位工程
{
Model.View_HJGL_WeldJoint model = new Model.View_HJGL_WeldJoint();
model.ProjectId = this.CurrUser.LoginProjectId;
model.UnitWorkId = this.tvControlItem.SelectedNodeID;
var list = BLL.WeldJointService.GetViewWeldJointsBymodel(model);
View_HJGL_WeldJoint = list;
}
/* PrintByUnitWork(this.tvControlItem.SelectedNodeID);
return;*/
}
string path = Funs.RootPath + @"File\Excel\Temp\JointQuery.xlsx";
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
@@ -546,6 +557,89 @@ namespace FineUIPro.Web.HJGL.InfoQuery
//Response.Write(GetGridTableHtml(Grid1));
//Response.End();
}
protected void PrintByUnitWork(string unitWorkId)
{
const int pageSize = 10000;
int pageIndex = 0;
bool isFirstPage = true;
var model = new Model.View_HJGL_WeldJoint
{
ProjectId = this.CurrUser.LoginProjectId,
UnitWorkId = unitWorkId
};
// 生成唯一文件路径(带GUID哈希值)
string path = $@"{Funs.RootPath}File\Excel\Temp\JointQuery_{Guid.NewGuid().GetHashCode():x}.xlsx";
var AllData = new List<object>();
using (var excelStream = new FileStream(path, FileMode.Create))
{
while (true)
{
// 分页获取数据
var pageData = BLL.WeldJointService.GetDataBymodel(model, pageIndex, pageSize);
if (!pageData.Data.Any()) break;
// 动态转换查询结果
var currentChunk = pageData.Data.Select(x => new
{
焊口号 = x.WeldJointCode,
完成状态 = x.IsWeldOK,
单位名称 = x.UnitName,
流水段 = x.FlowingSection,
材质1 = x.Material1Code,
材质2 = x.Material2Code,
达因 = x.Size,
外径 = x.Dia,
壁厚 = x.Thickness,
规格 = x.Specification,
焊缝类型 = x.WeldTypeCode,
焊接方法 = x.WeldingMethodCode,
WPS编号 = x.WPQCode,
坡口类型 = x.GrooveTypeCode,
焊条 = x.WeldingRodCode,
焊丝 = x.WeldingWireCode,
预热温度 = x.PreTemperature,
焊口属性 = x.JointAttribute,
焊接日期 = x.WeldingDate,
打底焊工号 = x.BackingWelderCode,
打底焊工班组 = x.BackingWelderTeamGroupName,
盖面焊工号 = x.CoverWelderCode,
盖面焊工班组 = x.CoverWelderTeamGroupName,
热处理报告编号 = x.HotProessReportNo,
热处理检测结果 = x.HotProessResult,
硬度报告编号 = x.HardReportNo,
硬度检测结果 = x.HardResult,
委托单编号 = x.TrustBatchCode,
检测单编号 = x.NDECode,
探伤类型 = x.DetectionTypeCode,
探伤比例 = x.DetectionRateCode
}).ToList();
AllData.AddRange(currentChunk);
// 内存清理 & 翻页操作
currentChunk = null;
pageIndex++;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Optimized, blocking: true);
}
MiniExcel.SaveAs(path, AllData );
}
string fileName = "焊口信息总览.xlsx";
FileInfo info = new FileInfo(path);
long fileSize = info.Length;
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();
File.Delete(path); // 多保险清理机制
}
protected void btnOutNOComPipeline_Click(object sender, EventArgs e)
{
if (this.tvControlItem.SelectedNode.CommandName.Split('|').Count() == 2)