595 lines
30 KiB
C#
595 lines
30 KiB
C#
using BLL;
|
|
using NPOI.XSSF.UserModel;
|
|
using NPOI.SS.UserModel;
|
|
using NPOI.HSSF.Util;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|
{
|
|
public partial class WeldDailyExport : PageBase
|
|
{
|
|
#region 加载
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
|
|
BLL.Project_InstallationService.InitInstallationDropDownList(drpInstallation, true, CurrUser.LoginProjectId, Resources.Lan.PleaseSelect);
|
|
BLL.Base_UnitService.InitProjectUnitDropDownList(this.drpUnit, true, CurrUser.LoginProjectId, Const.UnitType_5, Resources.Lan.PleaseSelect);
|
|
Funs.FineUIPleaseSelect(drpWorkAreaId, Resources.Lan.PleaseSelect);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 数据表
|
|
/// </summary>
|
|
private DataTable GetDataTable()
|
|
{
|
|
string strSql = @"SELECT weldJoint.WeldJointId,weldJoint.ProjectId,ins.InstallationCode,unit.UnitName,pipeline.PipelineCode,
|
|
(CASE WHEN weldJoint.PageNum IS NOT NULL AND weldJoint.PageNum<>'' THEN pipeline.SingleNumber+'-'+weldJoint.PageNum ELSE pipeline.SingleNumber END) AS SingleNumber,
|
|
pipeline.DrawingsNum,CONVERT(NVARCHAR(10),weldingDaily.WeldingDate,120) AS WeldingDate,rate.DetectionRateCode, weldJoint.WeldJointCode,
|
|
CAST(ISNULL(weldJoint.Size,0) AS REAL) AS Size,(CAST(ISNULL(weldJoint.Thickness,0) AS REAL)) AS Thickness,weldJoint.Specification,
|
|
weldType.WeldTypeCode,com1.ComponentsCode AS ComponentsName1,mat1.MaterialCode AS MaterialCode1,weldJoint.HeartNo1,
|
|
com2.ComponentsCode AS ComponentsName2,mat2.MaterialCode AS MaterialCode2,weldJoint.HeartNo2, WeldMethod.WeldingMethodName,
|
|
(CASE WHEN weldJoint.CoverWelderId!=weldJoint.BackingWelderId THEN cw.WelderCode+'/'+fw.WelderCode ELSE cw.WelderCode END) AS WelderCode ,
|
|
(CASE WHEN weldJoint.WeldMatId IS NOT NULL AND weldJoint.WeldSilkId IS NOT NULL THEN weldJoint.WeldSilkId+'|'+ weldJoint.WeldMatId
|
|
WHEN weldJoint.WeldMatId IS NOT NULL AND weldJoint.WeldSilkId IS NULL THEN weldJoint.WeldMatId
|
|
WHEN weldJoint.WeldSilkId IS NOT NULL AND weldJoint.WeldMatId IS NULL THEN weldJoint.WeldSilkId
|
|
ELSE '' END) AS WeldMaterial, wl.WeldingLocationCode,weldJoint.Remark
|
|
FROM Pipeline_WeldJoint AS weldJoint
|
|
LEFT JOIN Pipeline_Pipeline AS pipeline ON pipeline.PipelineId = weldJoint.PipelineId
|
|
LEFT JOIN dbo.Project_Installation ins ON ins.InstallationId = pipeline.InstallationId
|
|
LEFT JOIN dbo.Base_Unit unit ON unit.UnitId = pipeline.UnitId
|
|
LEFT JOIN dbo.Base_Components com1 ON com1.ComponentsId =weldJoint.PipeAssembly1Id
|
|
LEFT JOIN Base_Material AS mat1 ON mat1.MaterialId = weldJoint.Material1Id
|
|
LEFT JOIN dbo.Base_WeldingLocation wl ON wl.WeldingLocationId = weldJoint.WeldingLocationId
|
|
LEFT JOIN dbo.Base_Components com2 ON com2.ComponentsId =weldJoint.PipeAssembly2Id
|
|
LEFT JOIN Base_Material AS mat2 ON mat2.MaterialId = weldJoint.Material2Id
|
|
LEFT JOIN Base_WeldingMethod AS WeldMethod ON WeldMethod.WeldingMethodId = weldJoint.WeldingMethodId
|
|
LEFT JOIN dbo.Base_WeldType weldType ON weldType.WeldTypeId = weldJoint.WeldTypeId
|
|
LEFT JOIN Pipeline_WeldingDaily AS weldingDaily ON weldingDaily.WeldingDailyId = weldJoint.WeldingDailyId
|
|
left join Welder_Welder AS fw on weldJoint.BackingWelderId = fw.WelderId
|
|
left join Welder_Welder AS cw on weldJoint.CoverWelderId = cw.WelderId
|
|
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId = pipeline.DetectionRateId
|
|
WHERE weldJoint.WeldingDailyId IS NOT NULL AND weldJoint.ProjectId=@projectId";
|
|
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
|
|
|
if (drpInstallation.SelectedValue != Const._Null)
|
|
{
|
|
strSql += " AND pipeline.InstallationId = @InstallationId";
|
|
listStr.Add(new SqlParameter("@InstallationId", this.drpInstallation.SelectedValue));
|
|
//string[] pipeList = drpPipeLine.SelectedValueArray;
|
|
//string pipeLineIds = string.Join(",", pipeList);
|
|
//listStr.Add(new SqlParameter("@pipelineIds", pipeLineIds));
|
|
}
|
|
//else
|
|
//{
|
|
// listStr.Add(new SqlParameter("@pipelineIds", null));
|
|
//}
|
|
if (this.drpWorkAreaId.SelectedValue != Const._Null && this.drpWorkAreaId.SelectedValue != null)
|
|
{
|
|
strSql += " AND pipeline.WorkAreaId = @WorkAreaId";
|
|
listStr.Add(new SqlParameter("@WorkAreaId", drpWorkAreaId.SelectedValue));
|
|
}
|
|
if (this.drpUnit.SelectedValue != Const._Null)
|
|
{
|
|
strSql += " AND pipeline.UnitId = @UnitId";
|
|
listStr.Add(new SqlParameter("@UnitId", drpUnit.SelectedValue));
|
|
}
|
|
//if (this.drpWelder.SelectedValue!=Const._Null)
|
|
//{
|
|
// strSql += " AND (weldJoint.CoverWelderId=@WelderId OR weldJoint.BackingWelderId=@WelderId)";
|
|
// listStr.Add(new SqlParameter("@WelderId", drpWelder.SelectedValue));
|
|
//}
|
|
if (txtStarTime.Text != "")
|
|
{
|
|
strSql += " AND weldingDaily.WeldingDate> = @WeldingStartDate";
|
|
listStr.Add(new SqlParameter("@WeldingStartDate", txtStarTime.Text.Trim()));
|
|
}
|
|
if (txtEndTime.Text != "")
|
|
{
|
|
strSql += " AND weldingDaily.WeldingDate< = @WeldingEndDate";
|
|
listStr.Add(new SqlParameter("@WeldingEndDate", txtEndTime.Text.Trim()));
|
|
}
|
|
|
|
strSql += " ORDER BY pipeline.PipelineCode,WeldJointCode";
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
DataTable tb = GetDataTable();
|
|
this.Grid1.RecordCount = tb.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
|
|
if (tb.Rows.Count>0)
|
|
{
|
|
// 合计
|
|
var distinctPipelineCode = tb.AsEnumerable().GroupBy(row => row.Field<string>("PipelineCode")).Select(group => group.First());
|
|
var distinctWelder = tb.AsEnumerable().GroupBy(row => row.Field<string>("WelderCode")).Select(group => group.First());
|
|
decimal sumSize = decimal.Parse(tb.Compute("sum(Size)", "").ToString());
|
|
string weldingDate = string.Empty;
|
|
if (txtStarTime.Text == txtEndTime.Text)
|
|
{
|
|
weldingDate = txtStarTime.Text;
|
|
}
|
|
else
|
|
{
|
|
weldingDate = txtStarTime.Text + "-" + txtEndTime.Text;
|
|
}
|
|
JObject summary = new JObject();
|
|
summary.Add("tfNumber", "合计");
|
|
summary.Add("SingleNumber", distinctPipelineCode.Count().ToString());
|
|
summary.Add("WeldJointCode", tb.Rows.Count);
|
|
summary.Add("Size", sumSize);
|
|
summary.Add("WelderCode", distinctWelder.Count().ToString());
|
|
summary.Add("WeldingDate", weldingDate);
|
|
|
|
Grid1.SummaryData = summary;
|
|
}
|
|
}
|
|
|
|
protected void drpInstallation_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
drpWorkAreaId.Items.Clear();
|
|
string ins = drpInstallation.SelectedValue;
|
|
if (!string.IsNullOrEmpty(ins))
|
|
{
|
|
BLL.Project_WorkAreaService.InitWorkAreaDropDownList(this.drpWorkAreaId, true, this.CurrUser.LoginProjectId, ins, string.Empty, string.Empty, Resources.Lan.PleaseSelect);//区域
|
|
//BLL.Pipeline_PipelineService.InitPipelineDropDownList(drpPipeLine, workAreaId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 统计按钮事件
|
|
/// <summary>
|
|
/// 统计
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
|
//模板文件
|
|
string TempletFileName = rootPath + "WeldDailyExport.xlsx";
|
|
//导出文件
|
|
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
|
if (!Directory.Exists(filePath))
|
|
{
|
|
Directory.CreateDirectory(filePath);
|
|
}
|
|
string ReportFileName = filePath + "out.xlsx";
|
|
|
|
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
|
|
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
|
|
|
#region WeldDailyExport
|
|
XSSFSheet reportModel = (XSSFSheet)hssfworkbook.GetSheet("Sheet1");
|
|
|
|
XSSFFont cs_content_Font1 = (XSSFFont)hssfworkbook.CreateFont(); //创建字体
|
|
cs_content_Font1.FontName = "sans-serif";//字体
|
|
cs_content_Font1.FontHeightInPoints = 9; //字体大小
|
|
|
|
ICellStyle style = hssfworkbook.CreateCellStyle();
|
|
style.SetFont(cs_content_Font1);
|
|
|
|
XSSFFont cs_content_Font = (XSSFFont)hssfworkbook.CreateFont(); //创建字体
|
|
cs_content_Font.FontName = "sans-serif";//字体
|
|
cs_content_Font.FontHeightInPoints = 10; //字体大小
|
|
cs_content_Font.Color= HSSFColor.Red.Index;
|
|
|
|
IDataFormat dataformat = hssfworkbook.CreateDataFormat();
|
|
ICellStyle styleDate = hssfworkbook.CreateCellStyle();
|
|
styleDate.SetFont(cs_content_Font1);
|
|
styleDate.DataFormat = dataformat.GetFormat("yyyy-mm-dd");
|
|
|
|
DataTable tb = GetDataTable();
|
|
|
|
if (tb.Rows.Count > 0)
|
|
{
|
|
var rowIndex = 2;
|
|
foreach (DataRow itemOver in tb.Rows)
|
|
{
|
|
if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex);
|
|
|
|
#region 列赋值
|
|
//序号
|
|
if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0);
|
|
reportModel.GetRow(rowIndex).GetCell(0).SetCellValue((rowIndex - 1).ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(0).CellStyle = style; //将字体绑定到样式
|
|
|
|
//管线号-页码
|
|
if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1);
|
|
reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(itemOver["SingleNumber"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(1).CellStyle = style;
|
|
//图纸版本
|
|
if (reportModel.GetRow(rowIndex).GetCell(2) == null) reportModel.GetRow(rowIndex).CreateCell(2);
|
|
reportModel.GetRow(rowIndex).GetCell(2).SetCellValue(itemOver["DrawingsNum"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(2).CellStyle = style;
|
|
//焊口号
|
|
if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3);
|
|
reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(itemOver["WeldJointCode"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(3).CellStyle = style;
|
|
//焊接形式
|
|
if (reportModel.GetRow(rowIndex).GetCell(4) == null) reportModel.GetRow(rowIndex).CreateCell(4);
|
|
reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(itemOver["WeldTypeCode"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(4).CellStyle = style;
|
|
//if (itemOver.FCR_COST_CNY.HasValue)
|
|
//{
|
|
// reportModel.GetRow(rowIndex).GetCell(4).SetCellValue(string.Format("{0:N}", itemOver.FCR_COST_CNY));
|
|
//}
|
|
//焊接位置
|
|
if (reportModel.GetRow(rowIndex).GetCell(5) == null) reportModel.GetRow(rowIndex).CreateCell(5);
|
|
reportModel.GetRow(rowIndex).GetCell(5).SetCellValue(itemOver["WeldingLocationCode"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(5).CellStyle = style;
|
|
//寸径
|
|
if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6);
|
|
reportModel.GetRow(rowIndex).GetCell(6).SetCellValue(itemOver["Size"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(6).CellStyle = style;
|
|
//规格
|
|
if (reportModel.GetRow(rowIndex).GetCell(7) == null) reportModel.GetRow(rowIndex).CreateCell(7);
|
|
reportModel.GetRow(rowIndex).GetCell(7).SetCellValue(itemOver["Specification"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(7).CellStyle = style;
|
|
//焊工号
|
|
if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8);
|
|
reportModel.GetRow(rowIndex).GetCell(8).SetCellValue(itemOver["WelderCode"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(8).CellStyle = style;
|
|
//组对部件
|
|
if (reportModel.GetRow(rowIndex).GetCell(9) == null) reportModel.GetRow(rowIndex).CreateCell(9);
|
|
reportModel.GetRow(rowIndex).GetCell(9).SetCellValue(itemOver["ComponentsName1"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(9).CellStyle = style;
|
|
//组件1材质
|
|
if (reportModel.GetRow(rowIndex).GetCell(10) == null) reportModel.GetRow(rowIndex).CreateCell(10);
|
|
reportModel.GetRow(rowIndex).GetCell(10).SetCellValue(itemOver["MaterialCode1"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(10).CellStyle = style;
|
|
//组件1炉批号
|
|
if (reportModel.GetRow(rowIndex).GetCell(11) == null) reportModel.GetRow(rowIndex).CreateCell(11);
|
|
reportModel.GetRow(rowIndex).GetCell(11).SetCellValue(itemOver["HeartNo1"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(11).CellStyle = style;
|
|
//组对部件2
|
|
if (reportModel.GetRow(rowIndex).GetCell(12) == null) reportModel.GetRow(rowIndex).CreateCell(12);
|
|
reportModel.GetRow(rowIndex).GetCell(12).SetCellValue(itemOver["ComponentsName2"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(12).CellStyle = style;
|
|
//组件2材质
|
|
if (reportModel.GetRow(rowIndex).GetCell(13) == null) reportModel.GetRow(rowIndex).CreateCell(13);
|
|
reportModel.GetRow(rowIndex).GetCell(13).SetCellValue(itemOver["MaterialCode2"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(13).CellStyle = style;
|
|
//组件2炉批号
|
|
if (reportModel.GetRow(rowIndex).GetCell(14) == null) reportModel.GetRow(rowIndex).CreateCell(14);
|
|
reportModel.GetRow(rowIndex).GetCell(14).SetCellValue(itemOver["HeartNo2"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(14).CellStyle = style;
|
|
|
|
//焊接方法
|
|
if (reportModel.GetRow(rowIndex).GetCell(15) == null) reportModel.GetRow(rowIndex).CreateCell(15);
|
|
reportModel.GetRow(rowIndex).GetCell(15).SetCellValue(itemOver["WeldingMethodName"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(15).CellStyle = style;
|
|
//焊材牌号
|
|
if (reportModel.GetRow(rowIndex).GetCell(16) == null) reportModel.GetRow(rowIndex).CreateCell(16);
|
|
reportModel.GetRow(rowIndex).GetCell(16).SetCellValue(ConvertWeldMaterial(itemOver["WeldMaterial"]));
|
|
reportModel.GetRow(rowIndex).GetCell(16).CellStyle = style;
|
|
//探伤比例
|
|
if (reportModel.GetRow(rowIndex).GetCell(17) == null) reportModel.GetRow(rowIndex).CreateCell(17);
|
|
reportModel.GetRow(rowIndex).GetCell(17).SetCellValue(itemOver["DetectionRateCode"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(17).CellStyle = style;
|
|
//焊接日期
|
|
if (reportModel.GetRow(rowIndex).GetCell(18) == null) reportModel.GetRow(rowIndex).CreateCell(18);
|
|
reportModel.GetRow(rowIndex).GetCell(18).SetCellValue(itemOver["WeldingDate"].ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(18).CellStyle = styleDate;
|
|
#endregion
|
|
|
|
rowIndex++;
|
|
}
|
|
|
|
var distinctPipelineCode = tb.AsEnumerable().GroupBy(row => row.Field<string>("PipelineCode")).Select(group => group.First());
|
|
var distinctWelder = tb.AsEnumerable().GroupBy(row => row.Field<string>("WelderCode")).Select(group => group.First());
|
|
decimal sumSize = decimal.Parse(tb.Compute("sum(Size)", "").ToString());
|
|
string weldingDate = string.Empty;
|
|
if (txtStarTime.Text == txtEndTime.Text)
|
|
{
|
|
weldingDate = txtStarTime.Text;
|
|
}
|
|
else
|
|
{
|
|
weldingDate = txtStarTime.Text + "-" + txtEndTime.Text;
|
|
}
|
|
|
|
// 合计
|
|
if (reportModel.GetRow(rowIndex) == null) reportModel.CreateRow(rowIndex);
|
|
if (reportModel.GetRow(rowIndex).GetCell(0) == null) reportModel.GetRow(rowIndex).CreateCell(0);
|
|
reportModel.GetRow(rowIndex).GetCell(0).SetCellValue("合计Total");
|
|
reportModel.GetRow(rowIndex).GetCell(0).CellStyle.SetFont(cs_content_Font);//将字体绑定到样式
|
|
|
|
//管线号-页码
|
|
if (reportModel.GetRow(rowIndex).GetCell(1) == null) reportModel.GetRow(rowIndex).CreateCell(1);
|
|
reportModel.GetRow(rowIndex).GetCell(1).SetCellValue(distinctPipelineCode.Count().ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(1).CellStyle.SetFont(cs_content_Font);
|
|
|
|
//焊口号
|
|
if (reportModel.GetRow(rowIndex).GetCell(3) == null) reportModel.GetRow(rowIndex).CreateCell(3);
|
|
reportModel.GetRow(rowIndex).GetCell(3).SetCellValue(tb.Rows.Count);
|
|
reportModel.GetRow(rowIndex).GetCell(3).CellStyle.SetFont(cs_content_Font);
|
|
|
|
if (reportModel.GetRow(rowIndex).GetCell(6) == null) reportModel.GetRow(rowIndex).CreateCell(6);
|
|
reportModel.GetRow(rowIndex).GetCell(6).SetCellValue(sumSize.ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(6).CellStyle.SetFont(cs_content_Font);
|
|
|
|
//焊工号
|
|
if (reportModel.GetRow(rowIndex).GetCell(8) == null) reportModel.GetRow(rowIndex).CreateCell(8);
|
|
reportModel.GetRow(rowIndex).GetCell(8).SetCellValue(distinctWelder.Count().ToString());
|
|
reportModel.GetRow(rowIndex).GetCell(8).CellStyle.SetFont(cs_content_Font);
|
|
|
|
//焊接日期
|
|
if (reportModel.GetRow(rowIndex).GetCell(18) == null) reportModel.GetRow(rowIndex).CreateCell(18);
|
|
reportModel.GetRow(rowIndex).GetCell(18).SetCellValue(weldingDate);
|
|
reportModel.GetRow(rowIndex).GetCell(18).CellStyle.SetFont(cs_content_Font);
|
|
}
|
|
#endregion
|
|
reportModel.ForceFormulaRecalculation = true;
|
|
|
|
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
|
|
{
|
|
hssfworkbook.Write(filess);
|
|
}
|
|
FileInfo filet = new FileInfo(ReportFileName);
|
|
Response.Clear();
|
|
Response.Charset = "GB2312";
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
|
Response.AddHeader("Content-Disposition", "attachment; filename=焊接日报_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
|
|
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
|
Response.AddHeader("Content-Length", filet.Length.ToString());
|
|
// 指定返回的是一个不能被客户端读取的流,必须被下载
|
|
Response.ContentType = "application/ms-excel";
|
|
// 把文件流发送到客户端
|
|
Response.WriteFile(filet.FullName);
|
|
// 停止页面的执行
|
|
Response.End();
|
|
|
|
//Response.ClearContent();
|
|
//string filename = Funs.GetNewFileName();
|
|
//Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("焊接日报表" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|
//Response.ContentType = "application/excel";
|
|
//Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
//Response.Write(GetGridTableHtml(Grid1));
|
|
//Response.End();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
//private string GetGridTableHtml(Grid grid)
|
|
//{
|
|
// StringBuilder sb = new StringBuilder();
|
|
// grid.PageSize = 500000;
|
|
// BindGrid();
|
|
|
|
// sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|
// sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|
// sb.Append("<tr>");
|
|
// foreach (GridColumn column in grid.Columns)
|
|
// {
|
|
// sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|
// }
|
|
// sb.Append("</tr>");
|
|
// foreach (GridRow row in grid.Rows)
|
|
// {
|
|
// sb.Append("<tr>");
|
|
// foreach (GridColumn column in grid.Columns)
|
|
// {
|
|
// string html = row.Values[column.ColumnIndex].ToString();
|
|
// if (column.ColumnID == "tfNumber")
|
|
// {
|
|
// html = (row.FindControl("labNumber") as AspNet.Label).Text;
|
|
// }
|
|
// if (column.ColumnID == "tfIsHotProess")
|
|
// {
|
|
// html = (row.FindControl("lblIsHotProess") as AspNet.Label).Text;
|
|
// }
|
|
// //if (column.ColumnID == "tfif_dk")
|
|
// //{
|
|
// // html = (row.FindControl("lblif_dk") as AspNet.Label).Text;
|
|
// //}
|
|
// sb.AppendFormat("<td>{0}</td>", html);
|
|
// }
|
|
|
|
// sb.Append("</tr>");
|
|
// }
|
|
// sb.Append("</table>");
|
|
|
|
// return sb.ToString();
|
|
//}
|
|
#endregion
|
|
|
|
#region 格式化字符串
|
|
/// <summary>
|
|
/// 是否热处理
|
|
/// </summary>
|
|
/// <param name="isHotProess"></param>
|
|
/// <returns></returns>
|
|
protected string ConvertIsHotProess(object isHotProess)
|
|
{
|
|
if (isHotProess != null)
|
|
{
|
|
if (isHotProess.ToString() == "True")
|
|
{
|
|
return Resources.Lan.Yes;
|
|
}
|
|
else
|
|
{
|
|
return Resources.Lan.No;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否点口
|
|
/// </summary>
|
|
/// <param name="if_dk"></param>
|
|
/// <returns></returns>
|
|
protected string Convertif_dk(object if_dk)
|
|
{
|
|
if (if_dk != null)
|
|
{
|
|
if (if_dk.ToString() == "1")
|
|
{
|
|
return Resources.Lan.Yes;
|
|
}
|
|
else
|
|
{
|
|
return Resources.Lan.No;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
protected string ConvertWeldMaterial(object WeldMaterial)
|
|
{
|
|
string weldMaterial = string.Empty;
|
|
string silkName = string.Empty;
|
|
string fluxName = string.Empty;
|
|
string matName = string.Empty;
|
|
|
|
if (WeldMaterial != null && weldMaterial!="")
|
|
{
|
|
string[] wmts = WeldMaterial.ToString().Split('|');
|
|
if (wmts.Count() > 0)
|
|
{
|
|
if (wmts.Count() == 1)
|
|
{
|
|
string[] silks = wmts[0].Split(',');
|
|
if (silks.Count() > 1) // 焊丝
|
|
{
|
|
foreach (string s in silks)
|
|
{
|
|
var silk = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(s);
|
|
if (!string.IsNullOrEmpty(silk.UserFlux))
|
|
{
|
|
fluxName = fluxName + silk.UserFlux + "/";
|
|
silkName = silkName + silk.ConsumablesName + "/";
|
|
}
|
|
else
|
|
{
|
|
silkName = silkName + silk.ConsumablesName + "/";
|
|
}
|
|
}
|
|
|
|
if (fluxName.Length > 0)
|
|
{
|
|
fluxName = fluxName.Substring(0, fluxName.Length - 1);
|
|
weldMaterial = silkName + fluxName;
|
|
}
|
|
else
|
|
{
|
|
weldMaterial= silkName.Substring(0, silkName.Length - 1);
|
|
}
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
var mat = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(wmts[0]);
|
|
weldMaterial = mat.ConsumablesName;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
string[] silks = wmts[0].Split(',');
|
|
foreach (string s in silks)
|
|
{
|
|
var silk = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(s);
|
|
if (!string.IsNullOrEmpty(silk.UserFlux))
|
|
{
|
|
fluxName = fluxName + silk.UserFlux + "/";
|
|
silkName = silkName + silk.ConsumablesName + "/";
|
|
}
|
|
else
|
|
{
|
|
silkName = silkName + silk.ConsumablesName + "/";
|
|
}
|
|
}
|
|
|
|
var mat = BLL.Base_ConsumablesService.GetConsumablesByConsumablesId(wmts[1]);
|
|
weldMaterial = silkName + mat.ConsumablesName;
|
|
|
|
if (fluxName.Length > 0)
|
|
{
|
|
fluxName = fluxName.Substring(0, fluxName.Length - 1);
|
|
weldMaterial = silkName + mat.ConsumablesName + "/" + fluxName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return weldMaterial;
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
} |