This commit is contained in:
parent
47631bb84d
commit
23f7bfbb1d
|
|
@ -455,17 +455,96 @@ namespace BLL
|
|||
}
|
||||
public static List<Model.View_HJGL_WeldJoint> GetViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model)
|
||||
{
|
||||
var q = (from x in Funs.DB.View_HJGL_WeldJoint
|
||||
where
|
||||
(string.IsNullOrEmpty(model.ProjectId) || x.ProjectId.Contains(model.ProjectId))
|
||||
&& (string.IsNullOrEmpty(model.UnitWorkId) || x.UnitWorkId.Contains(model.UnitWorkId))
|
||||
&& (string.IsNullOrEmpty(model.PipelineId) || x.PipelineId.Contains(model.PipelineId))
|
||||
&& (string.IsNullOrEmpty(model.PipelineCode) || x.PipelineCode.Contains(model.PipelineCode))
|
||||
&& (string.IsNullOrEmpty(model.WeldJointCode) || x.WeldJointCode.Contains(model.WeldJointCode))
|
||||
orderby x.WeldJointCode
|
||||
select x).AsParallel().ToList();
|
||||
return q;
|
||||
var baseQuery = from x in Funs.DB.View_HJGL_WeldJoint select x;
|
||||
if (!string.IsNullOrEmpty(model.ProjectId))
|
||||
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
||||
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
||||
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineId))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineCode))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode));
|
||||
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
||||
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode));
|
||||
|
||||
return baseQuery.ToList();
|
||||
}
|
||||
public static IEnumerable<Model.View_HJGL_WeldJoint> GetIEnumerableViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model)
|
||||
{
|
||||
var baseQuery = from x in Funs.DB.View_HJGL_WeldJoint select x;
|
||||
if (!string.IsNullOrEmpty(model.ProjectId))
|
||||
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
||||
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
||||
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineId))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineCode))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode));
|
||||
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
||||
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode));
|
||||
|
||||
return baseQuery.ToList() ;
|
||||
}
|
||||
public static (List<Model.View_HJGL_WeldJoint> Data, int Total)GetDataBymodel(Model.View_HJGL_WeldJoint model, int pageIndex = 0, int pageSize = 20)
|
||||
{
|
||||
// 阶段一:构建基础查询
|
||||
var baseQuery = Funs.DB.View_HJGL_WeldJoint.AsQueryable();
|
||||
|
||||
// 阶段二:构建动态查询条件
|
||||
if (!string.IsNullOrEmpty(model.ProjectId))
|
||||
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
||||
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
||||
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineId))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineCode))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineCode .Contains(model.PipelineCode));
|
||||
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
||||
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains( model.WeldJointCode));
|
||||
|
||||
// 阶段三:排序与分页控制(索引优化关键)
|
||||
var orderedQuery = baseQuery.OrderBy(x => x.WeldJointCode);
|
||||
|
||||
// 阶段四:分页执行(数据库层面分页)
|
||||
var pagedData = orderedQuery
|
||||
.Skip((pageIndex ) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
// 获取总记录数(延迟计数优化)
|
||||
var totalCount = baseQuery.Count();
|
||||
|
||||
return (pagedData, totalCount);
|
||||
}
|
||||
public static List<Model.View_HJGL_WeldJoint> GetViewWeldJointsBymodel(Model.View_HJGL_WeldJoint model, int pageIndex = 0, int pageSize = 20)
|
||||
{
|
||||
// 阶段一:构建基础查询
|
||||
var baseQuery = Funs.DB.View_HJGL_WeldJoint.AsQueryable();
|
||||
|
||||
// 阶段二:构建动态查询条件
|
||||
if (!string.IsNullOrEmpty(model.ProjectId))
|
||||
baseQuery = baseQuery.Where(x => x.ProjectId == model.ProjectId);
|
||||
if (!string.IsNullOrEmpty(model.UnitWorkId))
|
||||
baseQuery = baseQuery.Where(x => x.UnitWorkId == model.UnitWorkId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineId))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineId == model.PipelineId);
|
||||
if (!string.IsNullOrEmpty(model.PipelineCode))
|
||||
baseQuery = baseQuery.Where(x => x.PipelineCode.Contains(model.PipelineCode));
|
||||
if (!string.IsNullOrEmpty(model.WeldJointCode))
|
||||
baseQuery = baseQuery.Where(x => x.WeldJointCode.Contains(model.WeldJointCode));
|
||||
|
||||
// 阶段三:排序与分页控制(索引优化关键)
|
||||
var orderedQuery = baseQuery.OrderBy(x => x.WeldJointCode);
|
||||
|
||||
// 阶段四:分页执行(数据库层面分页)
|
||||
var pagedData = orderedQuery
|
||||
.Skip((pageIndex) * pageSize)
|
||||
.Take(pageSize)
|
||||
.ToList();
|
||||
|
||||
return pagedData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据壁厚计算焊口达因
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -153,6 +153,9 @@
|
|||
<HintPath>..\packages\System.Text.Encoding.CodePages.4.5.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.DataVisualization" />
|
||||
<Reference Include="System.Web.DynamicData" />
|
||||
<Reference Include="System.Web.Entity" />
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue