272 lines
12 KiB
C#
272 lines
12 KiB
C#
using BLL;
|
|
using MiniExcelLibs;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data.SqlClient;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using Model;
|
|
|
|
namespace FineUIPro.Web.WeldingProcess.WeldingReport
|
|
{
|
|
public partial class RepairExTrackingList : PageBase
|
|
{
|
|
public static DataTable source { get; set; }
|
|
public static int percent { get; set; }
|
|
public static string url { get; set; }
|
|
|
|
[System.Web.Services.WebMethod]
|
|
public static int getPercent()
|
|
{
|
|
return percent;
|
|
}
|
|
|
|
[System.Web.Services.WebMethod]
|
|
public static string getUrl()
|
|
{
|
|
return url;
|
|
}
|
|
#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_WorkAreaService.InitWorkAreaDropDownList(this.drpWorkAreaId, true, this.CurrUser.LoginProjectId, string.Empty, string.Empty, string.Empty, Resources.Lan.PleaseSelect);//区域
|
|
}
|
|
}
|
|
|
|
private DataTable GetDataTable()
|
|
{ //创建表
|
|
DataTable dt = new DataTable();
|
|
|
|
//1、添加列
|
|
dt.Columns.Add("WorkAreaCode", typeof(string));
|
|
dt.Columns.Add("PipelineCode", typeof(string));
|
|
dt.Columns.Add("WeldJointId", typeof(string));
|
|
dt.Columns.Add("WeldJointCode", typeof(string));
|
|
dt.Columns.Add("WelderCode", typeof(string));
|
|
dt.Columns.Add("TeamGroupName", typeof(string));
|
|
dt.Columns.Add("Specification", typeof(string));
|
|
dt.Columns.Add("TrustBatchCode", typeof(string));
|
|
dt.Columns.Add("TrustBatchCodeRepair", typeof(string));
|
|
dt.Columns.Add("WeldJointCodeEx1", typeof(string));
|
|
dt.Columns.Add("WeldJointCodeEx2", typeof(string));
|
|
dt.Columns.Add("IsClose", typeof(string));
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@projectId", this.CurrUser.LoginProjectId));
|
|
|
|
var view_Batch_BatchTrustItemSelect = (from x in Funs.DB.View_Batch_BatchTrustItemSelect
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.TrustType == "1"
|
|
select new {
|
|
x.WorkAreaCode,
|
|
x.PipelineCode,
|
|
x.WeldJointId,
|
|
x.WeldJointCode,
|
|
x.WelderCode,
|
|
x.TeamGroupName,
|
|
x.Specification,
|
|
x.TrustBatchCode,
|
|
x.WorkAreaId,
|
|
x.PipelineId,
|
|
}).ToList();//点口
|
|
var view_Batch_BatchTrustItemSelectEx = (from x in Funs.DB.View_Batch_BatchTrustItemSelect
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.TrustType == "2"
|
|
select new {
|
|
x.WorkAreaCode,
|
|
x.PipelineCode,
|
|
x.WeldJointId,
|
|
x.WeldJointCode,
|
|
x.WelderCode,
|
|
x.TeamGroupName,
|
|
x.Specification,
|
|
x.TrustBatchCode,
|
|
x.WorkAreaId,
|
|
x.PipelineId,
|
|
}).ToList(); //扩透
|
|
var view_Batch_BatchTrustItemSelectRepair = (from x in Funs.DB.View_Batch_BatchTrustItemSelect
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.TrustType == "3"
|
|
select new
|
|
{
|
|
x.WorkAreaCode,
|
|
x.PipelineCode,
|
|
x.WeldJointId,
|
|
x.WeldJointCode,
|
|
x.WelderCode,
|
|
x.TeamGroupName,
|
|
x.Specification,
|
|
x.TrustBatchCode,
|
|
x.WorkAreaId,
|
|
x.PipelineId,
|
|
}).ToList(); //返修
|
|
if (drpWorkAreaId.SelectedValue != Const._Null && drpWorkAreaId.SelectedValue != null)
|
|
{
|
|
view_Batch_BatchTrustItemSelect= view_Batch_BatchTrustItemSelect.Where(x => drpWorkAreaId.SelectedValueArray.Contains(x.WorkAreaId)).ToList();
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(drpPipeLine.SelectedValue) && drpPipeLine.SelectedValue != Const._Null)
|
|
{
|
|
view_Batch_BatchTrustItemSelect = view_Batch_BatchTrustItemSelect.Where(x => drpPipeLine.SelectedValueArray.Contains(x.PipelineId)).ToList();
|
|
|
|
}
|
|
|
|
|
|
foreach (var item in view_Batch_BatchTrustItemSelect)
|
|
{
|
|
DataRow dr = dt.NewRow();
|
|
dr["WorkAreaCode"] = item.WorkAreaCode;
|
|
dr["PipelineCode"] = item.PipelineCode;
|
|
dr["WeldJointId"] = item.WeldJointId;
|
|
dr["WeldJointCode"] = item.WeldJointCode;
|
|
dr["WelderCode"] = item.WelderCode;
|
|
dr["TeamGroupName"] = item.TeamGroupName;
|
|
dr["Specification"] = item.Specification;
|
|
dr["TrustBatchCode"] = item.TrustBatchCode;
|
|
dr["TrustBatchCodeRepair"] = view_Batch_BatchTrustItemSelectRepair.Where(x=>x.TrustBatchCode.Contains(item.TrustBatchCode+"R"))?.FirstOrDefault()?.TrustBatchCode;
|
|
|
|
var exWeldJointCodeList = view_Batch_BatchTrustItemSelectEx.Where(x => x.TrustBatchCode.Contains(item.TrustBatchCode + "EX")).Select(x=>x.WeldJointCode).ToList();
|
|
if (exWeldJointCodeList.Count == 1)
|
|
{
|
|
dr["WeldJointCodeEx1"] = exWeldJointCodeList[0]?.ToString();
|
|
}
|
|
else if (exWeldJointCodeList.Count == 2)
|
|
{
|
|
dr["WeldJointCodeEx1"] = exWeldJointCodeList[0]?.ToString();
|
|
dr["WeldJointCodeEx2"] = exWeldJointCodeList[1]?.ToString();
|
|
}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(dr["WeldJointCodeEx2"].ToString()) && !string.IsNullOrEmpty(dr["WeldJointCodeEx2"].ToString()))
|
|
{
|
|
dr["IsClose"] = "是";
|
|
}
|
|
dt.Rows.Add(dr);
|
|
}
|
|
return dt;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
this.Grid1.RecordCount = source.Rows.Count;
|
|
var table = this.GetPagedDataTable(Grid1, source);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
protected void drpWorkAreaId_OnSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
string[] workAreaIds = drpWorkAreaId.SelectedValueArray;
|
|
if (workAreaIds.Length == 1)
|
|
{
|
|
BLL.Pipeline_PipelineService.InitPipelineDropDownList(drpPipeLine, workAreaIds[0], Resources.Lan.PleaseSelect);
|
|
}
|
|
}
|
|
|
|
/// <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)
|
|
{
|
|
source = GetDataTable();
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 导出按钮
|
|
/// 导出按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnOut_Click(object sender, EventArgs e)
|
|
{
|
|
percent = 0;
|
|
url = "";
|
|
|
|
Thread t = new Thread(new ThreadStart(() => { Export(); }));
|
|
t.Start();
|
|
PageContext.RegisterStartupScript("showProcessBar()");
|
|
|
|
}
|
|
|
|
private void Export()
|
|
{
|
|
string templatePath = Funs.RootPath + @"File\Excel\HJGL_DataOut\返修扩探追踪报表.xlsx";
|
|
string path = Funs.RootPath + @"File\Excel\Temp\返修扩探追踪报表.xlsx";
|
|
path = path.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm}", DateTime.Now) + ".xlsx");
|
|
DataTable tb = GetDataTable();
|
|
tb.TableName = "Data";
|
|
var value = new Dictionary<string, object>()
|
|
{
|
|
["Data"] = tb,
|
|
};
|
|
MiniExcel.SaveAsByTemplate(path, templatePath, value);
|
|
|
|
percent = 100;
|
|
url = path.Replace(Server.MapPath("~/"), "");
|
|
/*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);*/
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
} |