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)