This commit is contained in:
2024-06-20 17:12:59 +08:00
parent 8b222bd7c3
commit 6b59df065d
31 changed files with 1138 additions and 404 deletions
@@ -117,6 +117,9 @@
</f:TextBox>
<f:ToolbarFill ID="ToolbarFill2" runat="server">
</f:ToolbarFill>
<f:Button ID="btnExport" Text="打印" ToolTip="导出" EnableAjax="false" DisableControlBeforePostBack="false" Icon="ApplicationGet" runat="server"
OnClick="btnExport_Click">
</f:Button>
</Items>
</f:Toolbar>
</Toolbars>
@@ -144,11 +147,10 @@
HeaderTextAlign="Center" TextAlign="Left" Width="120px">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,QualityNo %>" ColumnID="QualityNo" DataField="QualityNo"
FieldType="String" TextAlign="Left" Width="150px">
FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,Acceptance %>" ColumnID="Acceptance"
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px">
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
</f:RenderField>
</Columns>
@@ -4,10 +4,9 @@ using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
namespace FineUIPro.Web.WeldingProcess.PMI
{
@@ -384,6 +383,176 @@ namespace FineUIPro.Web.WeldingProcess.PMI
#endregion
#endregion
protected void btnExport_Click(object sender, EventArgs e)
{
Alert.ShowInTop("待开发!", MessageBoxIcon.Warning);
return;
//if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_BatchTrustMenuId, Const.BtnOut))
//{
// if (string.IsNullOrWhiteSpace(this.tvControlItem.SelectedNodeID))
// {
// Alert.ShowInTop("请选择委托单!", MessageBoxIcon.Warning);
// return;
// }
// string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
// //导出文件
// string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
// if (!Directory.Exists(filePath))
// {
// Directory.CreateDirectory(filePath);
// }
// string ReportFileName = filePath + "out1.xlsx";
// int rowIndex = 0;
// XSSFWorkbook hssfworkbook = new XSSFWorkbook();
// XSSFSheet ws = new XSSFSheet();
// string trustBatchId = this.tvControlItem.SelectedNodeID;
//}
//else
//{
// ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
//}
}
#region
/// <summary>
/// 获取某一列的所有值
/// </summary>
/// <typeparam name="T">列数据类型</typeparam>
/// <param name="dtSource">数据表</param>
/// <param name="filedName">列名</param>
/// <returns></returns>
public static List<T> GetColumnValues<T>(DataTable dtSource, string filedName)
{
return (from r in dtSource.AsEnumerable() select r.Field<T>(filedName)).ToList<T>();
}
/// <summary>
/// 无损检测委托单行和列
/// </summary>
/// <returns></returns>
private XSSFSheet WsExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, int excelpart, bool isnobk = false)
{
for (int i = sRows; i <= eRows; i++)
{
ws.CreateRow(i);
if (excelpart == 1)
{
ws.GetRow(i).HeightInPoints =
i == sRows ? 27.75f :
i == (sRows + 1) ? 25.5f :
i == (sRows + 2) ? 25.5f :
i == (sRows + 3) ? 25.5f :
i == (sRows + 4) ? 23.25f :
i == (sRows + 5) ? 23.25f :
i == (sRows + 6) ? 23.25f :
i == (sRows + 7) ? 23.25f :
i == (sRows + 8) ? 23.25f :
i == (sRows + 9) ? 23.25f :
i == (sRows + 10) ? 23.25f :
i == (sRows + 11) ? 23.25f :
i == (sRows + 12) ? 23.25f :
17f;
}
else if (excelpart == 2)
{
ws.GetRow(i).HeightInPoints = 25.5f;
}
else
{
ws.GetRow(i).HeightInPoints = 15.5f;
}
for (int j = cStart; j <= cEnd; j++)
{
ws.GetRow(i).CreateCell(j);
if (isnobk)
{
ws.GetRow(i).GetCell(j).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10.5, true, false);
}
else
{
ws.GetRow(i).GetCell(j).CellStyle = style;
}
}
}
return ws;
}
/// <summary>
/// 材料及配件检测委托单行和列
/// </summary>
/// <returns></returns>
private XSSFSheet ClExcelCreateRow(XSSFSheet ws, XSSFWorkbook hssfworkbook, int sRows, int eRows, ICellStyle style, int cStart, int cEnd, bool istitle = false, bool isnobk = false)
{
for (int i = sRows; i <= eRows; i++)
{
ws.CreateRow(i);
if (istitle)
{
ws.GetRow(i).HeightInPoints =
i == sRows ? 27.75f :
i == (sRows + 1) ? 25f :
i == (sRows + 2) ? 21.75f :
i == (sRows + 3) ? 21.75f :
i == (sRows + 5) ? 28f :
14.75f;
}
else
{
ws.GetRow(i).HeightInPoints = 14.75f;
}
for (int j = cStart; j <= cEnd; j++)
{
ws.GetRow(i).CreateCell(j);
if (isnobk)
{
ws.GetRow(i).GetCell(j).CellStyle = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, NPOI.SS.UserModel.BorderStyle.None, NPOI.SS.UserModel.BorderStyle.None, VerticalAlignment.Center, HorizontalAlignment.Center, 10, true, false);
}
else
{
ws.GetRow(i).GetCell(j).CellStyle = style;
}
}
}
return ws;
}
/// <summary>
/// 查询指定条数分页
/// </summary>
/// <returns></returns>
public static DataTable GetPageToTable(DataTable dt, int StartNum, int EndNum)
{
//0页代表每页数据,直接返回
if (EndNum == 0) return dt;
//数据源为空返回空DataTable
if (dt == null) return new DataTable();
DataTable newdt = dt.Copy();
newdt.Clear();//copy dt的框架
if (StartNum >= dt.Rows.Count)
return newdt;//源数据记录数小于等于要显示的记录,直接返回dt
if (EndNum > dt.Rows.Count)
EndNum = dt.Rows.Count;
for (int i = StartNum; i <= EndNum - 1; i++)
{
DataRow newdr = newdt.NewRow();
DataRow dr = dt.Rows[i];
foreach (DataColumn column in dt.Columns)
{
newdr[column.ColumnName] = dr[column.ColumnName];
}
newdt.Rows.Add(newdr);
}
return newdt;
}
#endregion
#region
/// <summary>
/// 获取按钮权限
@@ -257,6 +257,15 @@ namespace FineUIPro.Web.WeldingProcess.PMI
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill2;
/// <summary>
/// btnExport 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnExport;
/// <summary>
/// ToolbarSeparator1 控件。
/// </summary>
@@ -117,14 +117,14 @@
TextAlign="Left" Width="220px">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,QualityNo %>" ColumnID="QualityNo" DataField="QualityNo"
FieldType="String" TextAlign="Left" Width="150px">
FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
<Editor>
<f:TextBox ID="tbxEditorQualityNo" Required="true" runat="server">
</f:TextBox>
</Editor>
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,Acceptance %>" ColumnID="Acceptance"
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px">
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
<Editor>
<f:TextBox ID="txtEditorAcceptance" Required="true" runat="server">
</f:TextBox>
@@ -85,7 +85,15 @@ namespace FineUIPro.Web.WeldingProcess.PMI
this.drpUnitId.SelectedValue = trust.UnitId;
}
this.txtDetectionMethod.Text = "PMI光谱分析";
this.txtDetectionStandard.Text = trust.DetectionStandard;
if (!string.IsNullOrEmpty(trust.DetectionStandard))
{
this.txtDetectionStandard.Text = trust.DetectionStandard;
}
else
{
txtDetectionStandard.Text = "GB 50184-2011";
}
if (!string.IsNullOrEmpty(trust.Tabler))
{
this.txtTabler.Text = BLL.Sys_UserService.GetUserNameByUserId(trust.Tabler);
@@ -94,6 +102,7 @@ namespace FineUIPro.Web.WeldingProcess.PMI
}
else
{
txtDetectionStandard.Text = "GB 50184-2011";
this.txtTabler.Text = this.CurrUser.UserName;
this.SimpleForm1.Reset(); //重置所有字段
}
@@ -151,10 +151,10 @@
TextAlign="Center" Width="160px">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,QualityNo %>" ColumnID="QualityNo" DataField="QualityNo"
FieldType="String" TextAlign="Left" Width="150px">
FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
</f:RenderField>
<f:RenderField HeaderText="<%$ Resources:Lan,Acceptance %>" ColumnID="Acceptance"
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px">
DataField="Acceptance" FieldType="String" TextAlign="Left" Width="150px" Hidden="true">
</f:RenderField>
<%-- 检测日期 --%>
<f:RenderField HeaderText="<%$ Resources:Lan,FilmDate %>" ColumnID="checkTime"
@@ -4106,12 +4106,12 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
ws.SetColumnWidth(12, 6 * 256);//M
ws.SetColumnWidth(13, 5 * 256);//N
ws.SetColumnWidth(14, 4 * 256);//O
ws.SetColumnWidth(15, 6 * 256);//P
ws.SetColumnWidth(15, 4 * 256);//P
ws.SetColumnWidth(16, 4 * 256);//Q
ws.SetColumnWidth(17, 5 * 256);//R
ws.SetColumnWidth(18, 6 * 256);//S
ws.SetColumnWidth(19, 7 * 256);//T
ws.SetColumnWidth(20, 13 * 256);//U
ws.SetColumnWidth(18, 5 * 256);//S
ws.SetColumnWidth(19, 5 * 256);//T
ws.SetColumnWidth(20, 18 * 256);//U
ws.AddMergedRegion(new CellRangeAddress(rowIndex, rowIndex + 3, 0, 2));
ws.GetRow(rowIndex).GetCell(0).SetCellValue("SH/T 3503-J412-1-2007");
@@ -7514,7 +7514,7 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
{
Directory.CreateDirectory(filePath);
}
string fileName = "模版报表-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
string fileName = "试压包报表-" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx";
string ReportFileName = filePath + fileName;
//XSSFWorkbook hssfworkbook = new XSSFWorkbook();
@@ -114,6 +114,14 @@
<f:Button ID="btnHandGenerate" Text="手动生成委托单" ToolTip="勾选需要生成委托单的焊口手动生成委托单" Icon="TableEdit" runat="server"
OnClick="btnHandGenerate_Click" >
</f:Button>
</Items>
</f:Toolbar>
<f:Toolbar ID="Toolbar4" Position="Top" runat="server" ToolbarAlign="Right">
<Items>
<f:Button ID="btnDailyCompPoint" Text="日报完成点口" ToolTip="日报忋完成审核点口" Icon="ArrowUndo"
runat="server" OnClick="btnDailyCompPoint_Click">
</f:Button>
<f:Button ID="btnbtnOpenResetPoint" Text="打开重新点口" ToolTip="打开重新点口" Icon="ArrowUndo"
runat="server" OnClick="btnbtnOpenResetPoint_Click">
</f:Button>
@@ -854,6 +854,332 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
}
}
/// <summary>
/// 日报完成点口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnDailyCompPoint_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointManageMenuId, Const.BtnOpenResetPoint))
{
string strSql = @"SELECT jot.ProjectId, pItem.PointBatchId,jot.CoverWelderId,rate.DetectionRateValue
FROM dbo.Batch_PointBatchItem pItem
LEFT JOIN dbo.Batch_PointBatch point ON point.PointBatchId = pItem.PointBatchId
LEFT JOIN dbo.Pipeline_WeldJoint jot ON jot.WeldJointId = pItem.WeldJointId
LEFT JOIN dbo.Base_DetectionRate rate ON rate.DetectionRateId=point.DetectionRateId
WHERE pItem.IsCompletedPoint=0
GROUP BY jot.ProjectId, pItem.PointBatchId,jot.CoverWelderId,rate.DetectionRateValue";
DataTable dt = SQLHelper.GetDataTableRunText(strSql, null);
if (dt.Rows.Count > 0)
{
foreach (DataRow r in dt.Rows)
{
// 已处理但批段未关闭的焊口
List<PointBatchList> batchNoClose = (from x in Funs.DB.Batch_PointBatchItem
join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId
where x.PointBatchId == r["PointBatchId"].ToString()
&& y.CoverWelderId == r["CoverWelderId"].ToString()
&& (x.BatchOrder == false || x.BatchOrder == null)
&& x.IsCompletedPoint == true
&& (y.IsCancel == false || y.IsCancel == null)
select new PointBatchList { PointBatchItemId = x.PointBatchItemId, JointAttribute = y.JointAttribute }).ToList();
// 未处理焊口
List<PointBatchList> jotList = (from x in Funs.DB.Batch_PointBatchItem
join y in Funs.DB.Pipeline_WeldJoint on x.WeldJointId equals y.WeldJointId
where x.PointBatchId == r["PointBatchId"].ToString()
&& y.CoverWelderId == r["CoverWelderId"].ToString()
&& (x.IsCompletedPoint == false || x.IsCompletedPoint == null)
&& (y.IsCancel == false || y.IsCancel == null)
orderby x.EnterDate
select new PointBatchList { PointBatchItemId = x.PointBatchItemId, JointAttribute = y.JointAttribute }).ToList();
// 未处理固定焊口
List<PointBatchList> GJot = jotList.Where(x=>x.JointAttribute == "固定F").ToList();
if (Convert.ToInt32(r["DetectionRateValue"]) != 0)
{
// 批中一段的数量
int dnum = Convert.ToInt32((double)100 / (int)r["DetectionRateValue"]);
// 已处理但批段未关闭的焊口数量
int batchNoCloseNum = batchNoClose.Count();
// 未处理焊口数量
int jotListNum = jotList.Count();
// 未处理固定焊口数量
int GJotNum = GJot.Count();
#region batchNoCloseNum大于0表示批段已处理但批段未关闭的焊口集合里
if (batchNoCloseNum > 0)
{
if ((batchNoCloseNum + jotListNum) > dnum)
{
// 关闭上一个批段还需要的数量
int closeNum = dnum - batchNoCloseNum;
var bachtclose = jotList.GetRange(0, closeNum);
// 补足上一个批段,关闭同时状态为已处理
foreach (var g in bachtclose)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
foreach (var g in batchNoClose)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
if ((jotListNum - closeNum) > dnum)
{
// 取模(余数)
int modelNum = (jotListNum - closeNum) % dnum;
// 取整
double doubleNum = Math.Ceiling((double)((jotListNum - closeNum) / (double)dnum));
int intNum = Convert.ToInt32(doubleNum);
// 补足上一个批段后剩余的待处理的列表
var remailList = jotList.GetRange(closeNum, (jotListNum - closeNum));
for (int i = 0; i < intNum; i++)
{
if (modelNum == 0)
{
var bachtOrder = remailList.GetRange(i * dnum, dnum);
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,并关闭此批段
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
}
else
{
if (i != intNum - 1)
{
var bachtOrder = remailList.GetRange(i * dnum, dnum);
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,并关闭此批段
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
}
// 最后一个段
else
{
var bachtOrder = remailList.GetRange(i * dnum, modelNum);
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,此批段不关闭
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
}
}
}
}
else if ((jotListNum - closeNum) == dnum)
{
var bachtOrder = jotList.GetRange(closeNum, (jotListNum - closeNum));
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,并关闭此批段
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
}
else
{
var bachtOrder = jotList.GetRange(closeNum, (jotListNum - closeNum));
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,此批段没关闭
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
}
}
// 当未关闭的批段+未处理焊口的数量等于探伤比例数量时批段关闭
else if (batchNoCloseNum + jotListNum == dnum)
{
// 批段关闭
foreach (var g in batchNoClose)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
// 批段关闭,状态为已处理
foreach (var g in jotList)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
}
else
{
// 待处理完成,但批段未关闭
foreach (var g in jotList)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
}
}
#endregion
#region batchNoCloseNum等于0表示这个批段开始
else
{
if (jotListNum > dnum)
{
// 取模(余数)
int modelNum = jotList.Count() % dnum;
// 取整
double doubleNum = Math.Ceiling((double)jotList.Count() / (double)dnum);
int intNum=Convert.ToInt32(doubleNum);
for (int i = 0; i < intNum; i++)
{
if (modelNum == 0)
{
var bachtOrder = jotList.GetRange(i * dnum, dnum);
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,并关闭此批段
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
}
else
{
if (i != intNum - 1)
{
var bachtOrder = jotList.GetRange(i * dnum, dnum);
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,并关闭此批段
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
}
// 最后一个段
else
{
var bachtOrder = jotList.GetRange(i * dnum, modelNum);
var bachtOrderG = bachtOrder.Where(p => p.JointAttribute == "固定F").ToList();
// 点口
GetRandomPoint(bachtOrderG, bachtOrder);
// 状态为已处理状态,此批段不关闭
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
}
}
}
}
else if (jotListNum == dnum)
{
// 点口
GetRandomPoint(GJot, jotList);
// 状态为已处理状态,并关闭此批段
foreach (var g in jotList)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, true);
}
}
else
{
// 点口
GetRandomPoint(GJot, jotList);
// 状态为已处理状态,但批段不关闭
foreach (var g in jotList)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(g.PointBatchItemId, true);
}
}
}
#endregion
}
else
{
// 不点口,状态为变已处理,批段完成
foreach (var q in jotList)
{
BLL.Batch_PointBatchItemService.UpdateIsCompletedPoint(q.PointBatchItemId, true);
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(q.PointBatchItemId, true);
}
}
}
}
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
}
private void GetRandomPoint(List<PointBatchList> GJot, List<PointBatchList> jotList)
{
// 先查找固定口数量,如有固定口,则优先点
if (GJot.Count() > 0)
{
int Gnum = GJot.Count();
int rnum = Funs.GetRandomNum(1, Gnum);
int j = 1;
foreach (var g in GJot)
{
if (rnum == j)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchItem(g.PointBatchItemId, "1", System.DateTime.Now, null);
}
j++;
}
}
else
{
if (jotList.Count() > 0)
{
int rnum = Funs.GetRandomNum(1, jotList.Count());
int j = 1;
foreach (var g in jotList)
{
if (rnum == j)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchItem(g.PointBatchItemId, "1", System.DateTime.Now, null);
}
j++;
}
}
}
}
/// <summary>
/// 手动结束批
/// </summary>
@@ -1632,6 +1958,20 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
return newTrustCode;
}
private class PointBatchList
{
public string PointBatchItemId
{
get;
set;
}
public string JointAttribute
{
get;
set;
}
}
}
}
@@ -203,6 +203,24 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
/// </remarks>
protected global::FineUIPro.Button btnHandGenerate;
/// <summary>
/// Toolbar4 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar4;
/// <summary>
/// btnDailyCompPoint 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnDailyCompPoint;
/// <summary>
/// btnbtnOpenResetPoint 控件。
/// </summary>
@@ -102,13 +102,15 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
protected void BtnExtract_Click(object sender, EventArgs e)
{
bool canWPS = true;
var jotList = (from x in Funs.DB.Pipeline_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId && x.WeldingDailyId != null && x.WeldingMethodId != null select x).ToList();
var jotList = (from x in Funs.DB.Pipeline_WeldJoint where x.ProjectId == this.CurrUser.LoginProjectId && x.WeldingDailyId != null && x.WeldingMethodId != null
select x).ToList(); // && x.PipelineId== "246c6b8c-8fbd-480c-9810-43062bf09646"
foreach (var jot in jotList)
{
var wps = BLL.WPQListServiceService.GetWPQById(jot.WPQId);
string floorWelder = jot.BackingWelderId;
string cellWelder = jot.CoverWelderId;
bool canWPS = true;
if (wps != null)
{
// 验证焊工WPS资质
@@ -143,7 +145,12 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
decimal? sch = jot.Thickness;
string[] wmeCodes = mat.WeldingMethodCode.Split('+');
string location = loc.WeldingLocationCode;
string location=string.Empty;
if (loc != null)
{
location = loc.WeldingLocationCode;
}
string ste = jot.Material1Id;
List<Model.Welder_WelderQualify> floorWelderQualifys = (from x in Funs.DB.Welder_WelderQualify
@@ -201,13 +208,17 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
}
}
if (canWPS==false || canSave == false)
if (canWPS == false || canSave == false)
{
jot.IsSuperQueWelding = true;
Funs.DB.SubmitChanges();
}
}
else
{
jot.IsSuperQueWelding = null;
}
}
Funs.DB.SubmitChanges();
ShowNotify("提取完成");
return;
@@ -9,6 +9,7 @@ using NPOI.SS.Util;
using NPOI.XSSF.UserModel;
using System.Linq;
using BLL;
using System.Web.Configuration;
namespace FineUIPro.Web.WeldingProcess.WeldingManage
{
@@ -353,6 +354,11 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
var weldJoints = BLL.Pipeline_WeldJointService.GetWeldlinesByWeldingDailyId(weldingDailyId);
if (weldJoints.Count() > 0)
{
string[] jointList = weldJoints.Select(p => p.WeldJointId).ToArray();
var pointBatchList = from x in Funs.DB.Batch_PointBatchItem
where jointList.Contains(x.WeldJointId)
select x;
string[] pointBatchIdList = pointBatchList.Select(p => p.PointBatchId).Distinct().ToArray();
foreach (var item in weldJoints)
{
var updateWeldJoint = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(item.WeldJointId);
@@ -369,8 +375,42 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
BLL.Batch_NDEItemService.DeleteAllNDEInfoToWeldJoint(item.WeldJointId);
}
}
// 打开批
if (pointBatchIdList.Count() > 0)
{
foreach (string p in pointBatchIdList)
{
var pItem = (from x in Funs.DB.Batch_PointBatchItem
orderby x.EnterDate descending
where x.PointBatchId == p
select x).ToList();
int pItemNum = pItem.Count();
if (pItemNum > 0)
{
var batch = BLL.Batch_PointBatchService.GetPointBatchById(p);
var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId);
int dnum = Convert.ToInt32((double)100 / (int)rate.DetectionRateValue);
// 取模(余数)
int modelNum = pItemNum % dnum;
// 等于0不处理
if (modelNum != 0)
{
var bachtOrder = pItem.GetRange(0, modelNum);
foreach (var g in bachtOrder)
{
BLL.Batch_PointBatchItemService.UpdatePointBatchOrder(g.PointBatchItemId, false);
}
}
}
}
}
}
BLL.Pipeline_WeldingDailyService.DeleteWeldingDailyByWeldingDailyId(weldingDailyId);
BLL.Sys_LogService.AddLog(BLL.Const.System_3, this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_WeldReportMenuId, Const.BtnDelete, weldingDailyId);
ShowNotify(Resources.Lan.DeletedSuccessfully, MessageBoxIcon.Success);
this.BindGrid();
@@ -1019,6 +1059,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
// }
//}
string oldmat1 = d.Material1Id;
if (ds.Tables[0].Rows[i]["材质1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["材质1"].ToString()))
{
var steel = materials.FirstOrDefault(x => x.MaterialCode == ds.Tables[0].Rows[i]["材质1"].ToString());
@@ -1050,7 +1091,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
else
{
if ((!string.IsNullOrEmpty(d.Material2Id) && steel.MaterialId != d.Material2Id)
&& (!string.IsNullOrEmpty(d.Material1Id) && steel.MaterialId != d.Material1Id))
&& (!string.IsNullOrEmpty(oldmat1) && steel.MaterialId != oldmat1))
{
errorInfos += (i + 2) + "行,材质2[" + ds.Tables[0].Rows[i]["材质2"].ToString() + "]验证不一至;";
}
@@ -1061,7 +1102,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
}
}
string oldCom1 = d.PipeAssembly1Id;
if (ds.Tables[0].Rows[i]["组件1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["组件1"].ToString()))
{
var com = componentss.FirstOrDefault(x => x.ComponentsCode == ds.Tables[0].Rows[i]["组件1"].ToString());
@@ -1093,8 +1134,8 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
}
else
{
if ((!string.IsNullOrEmpty(d.PipeAssembly1Id) && com.ComponentsId != d.PipeAssembly1Id)
&& (!string.IsNullOrEmpty(d.PipeAssembly2Id) && com.ComponentsId != d.PipeAssembly2Id))
if ((!string.IsNullOrEmpty(d.PipeAssembly2Id) && com.ComponentsId != d.PipeAssembly2Id)
&& (!string.IsNullOrEmpty(oldCom1) && com.ComponentsId != oldCom1))
{
errorInfos += (i + 2) + "行,组件2[" + ds.Tables[0].Rows[i]["组件2"].ToString() + "]验证不一至;";
}
@@ -1105,6 +1146,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
}
}
string oldHeartNo1 = d.HeartNo1;
if (ds.Tables[0].Rows[i]["炉批号1"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["炉批号1"].ToString()))
{
if ((!string.IsNullOrEmpty(d.HeartNo1) && ds.Tables[0].Rows[i]["炉批号1"].ToString() != d.HeartNo1)
@@ -1120,7 +1162,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
if (ds.Tables[0].Rows[i]["炉批号2"] != null && !string.IsNullOrEmpty(ds.Tables[0].Rows[i]["炉批号2"].ToString()))
{
if ((!string.IsNullOrEmpty(d.HeartNo1) && ds.Tables[0].Rows[i]["炉批号2"].ToString() != d.HeartNo1)
if ((!string.IsNullOrEmpty(oldHeartNo1) && ds.Tables[0].Rows[i]["炉批号2"].ToString() != oldHeartNo1)
&& (!string.IsNullOrEmpty(d.HeartNo2) && ds.Tables[0].Rows[i]["炉批号2"].ToString() != d.HeartNo2))
{
errorInfos += (i + 2) + "行,炉批号2[" + ds.Tables[0].Rows[i]["炉批号2"].ToString() + "]验证不一至;";
@@ -340,23 +340,30 @@ namespace FineUIPro.Web.WeldingProcess.WeldingManage
var wps = BLL.WPQListServiceService.GetWPQById(item.WPQId);
// 验证焊工资质
if (item.BackingWelderId == item.CoverWelderId)
if (wps != null)
{
if (!wps.WelderIds.Contains(item.BackingWelderId))
if (item.BackingWelderId == item.CoverWelderId)
{
errorCheck += rowIndex + "行,焊工:" + item.BackingWelderCode + "无WPS焊接资质,";
if (!wps.WelderIds.Contains(item.BackingWelderId))
{
errorCheck += rowIndex + "行,焊工:" + item.BackingWelderCode + "无WPS焊接资质,";
}
}
else
{
if (!wps.WelderIds.Contains(item.BackingWelderId))
{
errorCheck += rowIndex + "行,焊工:" + item.BackingWelderCode + "无WPS焊接资质,";
}
if (!wps.WelderIds.Contains(item.CoverWelderId))
{
errorCheck += rowIndex + "行,焊工:" + item.CoverWelderId + "无WPS焊接资质,";
}
}
}
else
{
if (!wps.WelderIds.Contains(item.BackingWelderId))
{
errorCheck += rowIndex + "行,焊工:" + item.BackingWelderCode + "无WPS焊接资质,";
}
if (!wps.WelderIds.Contains(item.CoverWelderId))
{
errorCheck += rowIndex + "行,焊工:" + item.CoverWelderId + "无WPS焊接资质,";
}
errorCheck += rowIndex + "行,WPS不能为空,";
}
// 验证数据是否一至
@@ -37,6 +37,9 @@
<f:DropDownList ID="drpUnit" runat="server" Label="施工单位" LabelAlign="Right" Width="240px" EmptyText="请选择施工单位"
LabelWidth="90px">
</f:DropDownList>
<f:DropDownList ID="drpJointAttribute" Label="<%$ Resources:Lan,WeldingJointQuality %>" runat="server" LabelAlign="Right" Width="180px"
LabelWidth="90px">
</f:DropDownList>
<f:DropDownList ID="drpTeamGroup" runat="server" Label="班组" EnableCheckBoxSelect="true" EnableMultiSelect="true"
LabelAlign="Right" Width="160px" LabelWidth="80px">
</f:DropDownList>
@@ -45,6 +48,15 @@
<f:ListItem Value="未审核" Text="未审核" />
<f:ListItem Value="已审核" Text="已审核" />
</f:DropDownList>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
</Items>
</f:Toolbar>
</Toolbars>
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" runat="server" ToolbarAlign="Left">
<Items>
<f:DatePicker runat="server" Label="焊接日期" ID="txtStarTime" LabelAlign="Right"
LabelWidth="90px" Width="210px">
</f:DatePicker>
@@ -53,15 +65,8 @@
<f:DatePicker runat="server" ID="txtEndTime" LabelAlign="Right" LabelWidth="80px"
Width="110px">
</f:DatePicker>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
<f:ToolbarFill ID="ToolbarFill2" runat="server">
</f:ToolbarFill>
</Items>
</f:Toolbar>
</Toolbars>
<Toolbars>
<f:Toolbar ID="Toolbar2" Position="Top" runat="server" ToolbarAlign="Left">
<Items>
<f:Button ID="BtnAnalyse" Text="<%$ Resources:Lan,Statistics %>" Icon="ChartPie"
runat="server" OnClick="BtnAnalyse_Click">
</f:Button>
@@ -40,6 +40,13 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
drpTeamGroup.DataSource = teamGroup;
drpTeamGroup.DataBind();
Funs.FineUIPleaseSelect(drpTeamGroup, "");
// 焊口属性
this.drpJointAttribute.DataTextField = "Text";
this.drpJointAttribute.DataValueField = "Value";
this.drpJointAttribute.DataSource = BLL.DropListService.HJGL_JointAttributeItem();
this.drpJointAttribute.DataBind();
Funs.FineUIPleaseSelect(this.drpJointAttribute, Resources.Lan.PleaseSelect);
}
}
@@ -103,6 +110,11 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
strSql += " AND pipeline.UnitId = @UnitId";
listStr.Add(new SqlParameter("@UnitId", drpUnit.SelectedValue));
}
if (this.drpJointAttribute.SelectedValue != Const._Null)
{
strSql += " AND weldJoint.JointAttribute = @JointAttribute";
listStr.Add(new SqlParameter("@JointAttribute", drpJointAttribute.SelectedValue));
}
if (this.drpTeamGroup.SelectedValueArray.Length>0)
{
string[] teamGroupList = drpTeamGroup.SelectedValueArray;
@@ -251,261 +263,294 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
}
//批量审核
protected void btnAuditAll_Click(object sender,EventArgs e)
protected void btnAuditAll_Click(object sender, EventArgs e)
{
var data = this.GetDataTable();
if (string.IsNullOrEmpty(txtStarTime.Text) && string.IsNullOrEmpty(txtEndTime.Text))
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WeldDailyExportMenuId, Const.BtnAuditing))
{
ShowNotify("请按照日期选择要审核的日报!",MessageBoxIcon.Warning);
var data = this.GetDataTable();
if (string.IsNullOrEmpty(txtStarTime.Text) && string.IsNullOrEmpty(txtEndTime.Text))
{
ShowNotify("请按照日期选择要审核的日报!", MessageBoxIcon.Warning);
return;
}
List<string> ids = new List<string>();
foreach (DataRow dr in data.Rows)
{
ids.Add(dr["WeldJointId"].ToString());
}
ModifyAuditStatus(ids, 1);
this.BindGrid();
ShowNotify("批量审核成功!", MessageBoxIcon.Success);
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
List<string> ids = new List<string>();
foreach (DataRow dr in data.Rows)
{
ids.Add(dr["WeldJointId"].ToString());
}
ModifyAuditStatus(ids, 1);
this.BindGrid();
ShowNotify("批量审核成功!", MessageBoxIcon.Success);
}
//审核
protected void btnAudit_Click(object sender,EventArgs e)
protected void btnAudit_Click(object sender, EventArgs e)
{
var listIds = GetWeldJointIdList();
if (listIds.Count == 0)
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WeldDailyExportMenuId, Const.BtnAuditing))
{
ShowNotify("请选择要审核的焊接日报数据", MessageBoxIcon.Warning);
var listIds = GetWeldJointIdList();
if (listIds.Count == 0)
{
ShowNotify("请选择要审核的焊接日报数据", MessageBoxIcon.Warning);
return;
}
ModifyAuditStatus(listIds, 1);
this.BindGrid();
ShowNotify("批量审核成功!", MessageBoxIcon.Success);
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
ModifyAuditStatus(listIds,1);
this.BindGrid();
ShowNotify("批量审核成功!", MessageBoxIcon.Success);
}
//取消审核
protected void btnCancel_Click(object sender, EventArgs e)
{
var listIds = GetWeldJointIdList();
if (listIds.Count == 0)
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WeldDailyExportMenuId, Const.BtnCancelAuditing))
{
ShowNotify("请选择要取消审核的焊接日报数据", MessageBoxIcon.Warning);
var listIds = GetWeldJointIdList();
if (listIds.Count == 0)
{
ShowNotify("请选择要取消审核的焊接日报数据", MessageBoxIcon.Warning);
return;
}
ModifyAuditStatus(listIds, 0);
this.BindGrid();
ShowNotify("批量取消审核成功!", MessageBoxIcon.Success);
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
ModifyAuditStatus(listIds,0);
this.BindGrid();
ShowNotify("批量取消审核成功!", MessageBoxIcon.Success);
}
//发送邮件
protected void btnSendEmail_Click(object sender,EventArgs e)
protected void btnSendEmail_Click(object sender, EventArgs e)
{
DataTable dt = GetDataTableAuditStatus();
if (dt.Rows.Count == 0)
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.WeldDailyExportMenuId, Const.BtnSendEmail))
{
ShowNotify("暂无已审核的数据!",MessageBoxIcon.Warning);
DataTable dt = GetDataTableAuditStatus();
if (dt.Rows.Count == 0)
{
ShowNotify("暂无已审核的数据!", MessageBoxIcon.Warning);
return;
}
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 + $"焊接日报_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx";
try
{
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
hssfworkbook.RemoveAt(0);
XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("Sheet1");
int rowIndex = 0;
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 20, true, true, "Arial");
#region
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex, style, 0, 19, true);
ws.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(rowIndex, rowIndex, 0, 19));
//设置表头文字
ws.GetRow(rowIndex).GetCell(0).SetCellValue("焊接日报表\nWelding Daily Report");
var style2 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, true, true, "Arial");
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 2, style2, 0, 19, true);
//设置表格表头
ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("序号");
ws.GetRow(rowIndex + 1).GetCell(1).SetCellValue("管线号-页码");
ws.GetRow(rowIndex + 1).GetCell(2).SetCellValue("图纸版本");
ws.GetRow(rowIndex + 1).GetCell(3).SetCellValue("焊口号");
ws.GetRow(rowIndex + 1).GetCell(4).SetCellValue("焊接形式");
ws.GetRow(rowIndex + 1).GetCell(5).SetCellValue("焊接位置");
ws.GetRow(rowIndex + 1).GetCell(6).SetCellValue("寸径");
ws.GetRow(rowIndex + 1).GetCell(7).SetCellValue("规格");
ws.GetRow(rowIndex + 1).GetCell(8).SetCellValue("焊工号");
ws.GetRow(rowIndex + 1).GetCell(9).SetCellValue("组对部件1");
ws.GetRow(rowIndex + 1).GetCell(10).SetCellValue("组件1材质");
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("组件1炉批号");
ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("组对部件2");
ws.GetRow(rowIndex + 1).GetCell(13).SetCellValue("组件2材质");
ws.GetRow(rowIndex + 1).GetCell(14).SetCellValue("组件2炉批号");
ws.GetRow(rowIndex + 1).GetCell(15).SetCellValue("焊接方法");
ws.GetRow(rowIndex + 1).GetCell(16).SetCellValue("组对");
ws.GetRow(rowIndex + 1).GetCell(17).SetCellValue("外观");
ws.GetRow(rowIndex + 1).GetCell(18).SetCellValue("焊接日期");
ws.GetRow(rowIndex + 1).GetCell(19).SetCellValue("备注");
ws.GetRow(rowIndex + 2).GetCell(0).SetCellValue("S/N");
ws.GetRow(rowIndex + 2).GetCell(1).SetCellValue("LineNo.-PageNo.");
ws.GetRow(rowIndex + 2).GetCell(2).SetCellValue("Drawing\nRev");
ws.GetRow(rowIndex + 2).GetCell(3).SetCellValue("Joint\nNo.");
ws.GetRow(rowIndex + 2).GetCell(4).SetCellValue("JointType");
ws.GetRow(rowIndex + 2).GetCell(5).SetCellValue("Welding\nLocation");
ws.GetRow(rowIndex + 2).GetCell(6).SetCellValue("Inch");
ws.GetRow(rowIndex + 2).GetCell(7).SetCellValue("Size");
ws.GetRow(rowIndex + 2).GetCell(8).SetCellValue("Welder\nNo.");
ws.GetRow(rowIndex + 2).GetCell(9).SetCellValue("Part(1)");
ws.GetRow(rowIndex + 2).GetCell(10).SetCellValue("Material(1)");
ws.GetRow(rowIndex + 2).GetCell(11).SetCellValue("Heat\nNo.(1)");
ws.GetRow(rowIndex + 2).GetCell(12).SetCellValue("Part(2)");
ws.GetRow(rowIndex + 2).GetCell(13).SetCellValue("Material(2)");
ws.GetRow(rowIndex + 2).GetCell(14).SetCellValue("Heat\nNo.(2)");
ws.GetRow(rowIndex + 2).GetCell(15).SetCellValue("Weld\nProcess");
ws.GetRow(rowIndex + 2).GetCell(16).SetCellValue("Fit\nUp");
ws.GetRow(rowIndex + 2).GetCell(17).SetCellValue("VT");
ws.GetRow(rowIndex + 2).GetCell(18).SetCellValue("Welding\nDate");
ws.GetRow(rowIndex + 2).GetCell(19).SetCellValue("Remark");
ws.GetRow(rowIndex).Height = 69 * 20;
ws.GetRow(rowIndex + 1).Height = 15 * 20;
ws.GetRow(rowIndex + 2).Height = 30 * 20;
ws.SetColumnWidth(0, 5 * 256);
ws.SetColumnWidth(1, (int)(21.67 * 256));
ws.SetColumnWidth(2, (int)(9.78 * 256));
ws.SetColumnWidth(3, (int)(5.33 * 256));
ws.SetColumnWidth(4, (int)(7.67 * 256));
ws.SetColumnWidth(5, (int)(8.33 * 256));
ws.SetColumnWidth(6, (int)(7 * 256));
ws.SetColumnWidth(7, (int)(10.82 * 256));
ws.SetColumnWidth(8, (int)(8.33 * 256));
ws.SetColumnWidth(9, (int)(8.40 * 256));
ws.SetColumnWidth(10, (int)(15.67 * 256));
ws.SetColumnWidth(11, (int)(12 * 256));
ws.SetColumnWidth(12, (int)(8.22 * 256));
ws.SetColumnWidth(13, (int)(16.33 * 256));
ws.SetColumnWidth(14, (int)(11.45 * 256));
ws.SetColumnWidth(15, (int)(11.00 * 256));
ws.SetColumnWidth(16, (int)(4.00 * 256));
ws.SetColumnWidth(17, (int)(4.00 * 256));
ws.SetColumnWidth(18, (int)(9.00 * 256));
ws.SetColumnWidth(19, (int)(7 * 256));
#endregion
const int pageSize = 65;
var style3 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, false, false, "sans-serif");
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 3, dt.Rows.Count + 2, style3, 0, 19);
for (int i = 0; i < dt.Rows.Count; i++)
{
int startIndex = (i + 3);
ws.GetRow(startIndex).GetCell(0).SetCellValue(i + 1);
ws.GetRow(startIndex).GetCell(1).SetCellValue(dt.Rows[i]["SingleNumber"].ToString());
ws.GetRow(startIndex).GetCell(2).SetCellValue(dt.Rows[i]["DrawingsNum"].ToString());
ws.GetRow(startIndex).GetCell(3).SetCellValue(dt.Rows[i]["WeldJointCode"].ToString());
ws.GetRow(startIndex).GetCell(4).SetCellValue(dt.Rows[i]["WeldTypeCode"].ToString());
ws.GetRow(startIndex).GetCell(5).SetCellValue(dt.Rows[i]["WeldingLocationCode"].ToString());
ws.GetRow(startIndex).GetCell(6).SetCellValue(dt.Rows[i]["Size"].ToString());
ws.GetRow(startIndex).GetCell(7).SetCellValue(dt.Rows[i]["Specification"].ToString());
ws.GetRow(startIndex).GetCell(8).SetCellValue(dt.Rows[i]["WelderCode"].ToString());
ws.GetRow(startIndex).GetCell(9).SetCellValue(dt.Rows[i]["ComponentsName1"].ToString());
ws.GetRow(startIndex).GetCell(10).SetCellValue(dt.Rows[i]["MaterialCode1"].ToString());
ws.GetRow(startIndex).GetCell(11).SetCellValue(dt.Rows[i]["HeartNo1"].ToString());
ws.GetRow(startIndex).GetCell(12).SetCellValue(dt.Rows[i]["ComponentsName2"].ToString());
ws.GetRow(startIndex).GetCell(13).SetCellValue(dt.Rows[i]["MaterialCode2"].ToString());
ws.GetRow(startIndex).GetCell(14).SetCellValue(dt.Rows[i]["HeartNo2"].ToString());
ws.GetRow(startIndex).GetCell(15).SetCellValue(dt.Rows[i]["WeldingMethodName"].ToString());
ws.GetRow(startIndex).GetCell(16).SetCellValue("ACC");
ws.GetRow(startIndex).GetCell(17).SetCellValue("ACC");
ws.GetRow(startIndex).GetCell(18).SetCellValue(dt.Rows[i]["WeldingDate"].ToString());
ws.GetRow(startIndex).GetCell(19).SetCellValue(dt.Rows[i]["Remark"].ToString());
ws.GetRow(startIndex).Height = 10 * 20;
if (startIndex == pageSize)
{
ws.SetRowBreak(startIndex);
startIndex += pageSize;
}
}
if (dt.Rows.Count > 0)
{
string weldingDate = string.Empty;
if (txtStarTime.Text == txtEndTime.Text)
{
weldingDate = txtStarTime.Text;
}
else
{
weldingDate = txtStarTime.Text + "-" + txtEndTime.Text;
}
var style4 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, true, true, "Arial");
ws = ExcelCreateRow(ws, hssfworkbook, dt.Rows.Count + 3, dt.Rows.Count + 3, style4, 0, 19);
var distinctPipelineCode = dt.AsEnumerable().GroupBy(row => row.Field<string>("PipelineCode")).Select(group => group.First());
var distinctWelder = dt.AsEnumerable().GroupBy(row => row.Field<string>("WelderCode")).Select(group => group.First());
decimal sumSize = decimal.Parse(dt.Compute("sum(Size)", "").ToString());
ws.GetRow(dt.Rows.Count + 3).GetCell(0).SetCellValue("Total");
ws.GetRow(dt.Rows.Count + 3).GetCell(1).SetCellValue($"{distinctPipelineCode.Count().ToString()}");
ws.GetRow(dt.Rows.Count + 3).GetCell(3).SetCellValue($"{dt.Rows.Count}");
ws.GetRow(dt.Rows.Count + 3).GetCell(6).SetCellValue($"{sumSize}");
ws.GetRow(dt.Rows.Count + 3).GetCell(8).SetCellValue($"{distinctWelder.Count().ToString()}");
ws.GetRow(dt.Rows.Count + 3).Height = 20 * 20;
}
#region
IFooter footer = ws.Footer;
string str = " CC7: 监理: Worley:";
str += "\n\n第 &P 页,共 &N 页";
footer.Center = str;
#endregion
ws.FitToPage = true;
ws.PrintSetup.FitWidth = 1;
ws.PrintSetup.FitHeight = short.MaxValue;
ws.SetMargin(MarginType.LeftMargin, (double)1.2 / 3);
ws.SetMargin(MarginType.RightMargin, (double)0.5 / 3);
ws.SetMargin(MarginType.TopMargin, (double)1.8 / 3);
ws.SetMargin(MarginType.BottomMargin, (double)2.9 / 3);
ws.PrintSetup.Landscape = true;
ws.ForceFormulaRecalculation = true;
ws.PrintSetup.PaperSize = (int)PaperSize.A4_Small;
ws.RepeatingRows = new NPOI.SS.Util.CellRangeAddress(0, 2, 0, 19);
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
{
hssfworkbook.Write(filess);
}
hssfworkbook.Close();
this.GetEmailTemplateAndSendEmail(ReportFileName);
File.Delete(ReportFileName);
ShowNotify("焊接日报发送成功!", MessageBoxIcon.Success);
}
catch (Exception ex)
{
ShowNotify($"发送失败,原因:{ex.Message}", MessageBoxIcon.Error);
}
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
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 + $"焊接日报_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx";
try
{
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
hssfworkbook.RemoveAt(0);
XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("Sheet1");
int rowIndex = 0;
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 20, true, true, "微软雅黑");
#region
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex, style, 0, 19, true);
ws.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(rowIndex, rowIndex, 0, 19));
//设置表头文字
ws.GetRow(rowIndex).GetCell(0).SetCellValue("焊接日报表\nWelding Daily Report");
var style2 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, true, true, "Arial");
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 1, rowIndex + 2, style2, 0, 19, true);
//设置表格表头
ws.GetRow(rowIndex + 1).GetCell(0).SetCellValue("序号");
ws.GetRow(rowIndex + 1).GetCell(1).SetCellValue("管线号-页码");
ws.GetRow(rowIndex + 1).GetCell(2).SetCellValue("图纸版本");
ws.GetRow(rowIndex + 1).GetCell(3).SetCellValue("焊口号");
ws.GetRow(rowIndex + 1).GetCell(4).SetCellValue("焊接形式");
ws.GetRow(rowIndex + 1).GetCell(5).SetCellValue("焊接位置");
ws.GetRow(rowIndex + 1).GetCell(6).SetCellValue("寸径");
ws.GetRow(rowIndex + 1).GetCell(7).SetCellValue("规格");
ws.GetRow(rowIndex + 1).GetCell(8).SetCellValue("焊工号");
ws.GetRow(rowIndex + 1).GetCell(9).SetCellValue("组对部件1");
ws.GetRow(rowIndex + 1).GetCell(10).SetCellValue("组件1材质");
ws.GetRow(rowIndex + 1).GetCell(11).SetCellValue("组件1炉批号");
ws.GetRow(rowIndex + 1).GetCell(12).SetCellValue("组对部件2");
ws.GetRow(rowIndex + 1).GetCell(13).SetCellValue("组件2材质");
ws.GetRow(rowIndex + 1).GetCell(14).SetCellValue("组件2炉批号");
ws.GetRow(rowIndex + 1).GetCell(15).SetCellValue("焊接方法");
ws.GetRow(rowIndex + 1).GetCell(16).SetCellValue("组对");
ws.GetRow(rowIndex + 1).GetCell(17).SetCellValue("外观");
ws.GetRow(rowIndex + 1).GetCell(18).SetCellValue("焊接日期");
ws.GetRow(rowIndex + 1).GetCell(19).SetCellValue("备注");
ws.GetRow(rowIndex + 2).GetCell(0).SetCellValue("S/N");
ws.GetRow(rowIndex + 2).GetCell(1).SetCellValue("LineNo.-PageNo.");
ws.GetRow(rowIndex + 2).GetCell(2).SetCellValue("Drawing\nRev");
ws.GetRow(rowIndex + 2).GetCell(3).SetCellValue("Joint\nNo.");
ws.GetRow(rowIndex + 2).GetCell(4).SetCellValue("JointType");
ws.GetRow(rowIndex + 2).GetCell(5).SetCellValue("Welding\nLocation");
ws.GetRow(rowIndex + 2).GetCell(6).SetCellValue("Inch");
ws.GetRow(rowIndex + 2).GetCell(7).SetCellValue("Size");
ws.GetRow(rowIndex + 2).GetCell(8).SetCellValue("Welder\nNo.");
ws.GetRow(rowIndex + 2).GetCell(9).SetCellValue("Part(1)");
ws.GetRow(rowIndex + 2).GetCell(10).SetCellValue("Material(1)");
ws.GetRow(rowIndex + 2).GetCell(11).SetCellValue("Heat\nNo.(1)");
ws.GetRow(rowIndex + 2).GetCell(12).SetCellValue("Part(2)");
ws.GetRow(rowIndex + 2).GetCell(13).SetCellValue("Material(2)");
ws.GetRow(rowIndex + 2).GetCell(14).SetCellValue("Heat\nNo.(2)");
ws.GetRow(rowIndex + 2).GetCell(15).SetCellValue("Weld\nProcess");
ws.GetRow(rowIndex + 2).GetCell(16).SetCellValue("Fit\nUp");
ws.GetRow(rowIndex + 2).GetCell(17).SetCellValue("VT");
ws.GetRow(rowIndex + 2).GetCell(18).SetCellValue("Welding\nDate");
ws.GetRow(rowIndex + 2).GetCell(19).SetCellValue("Remark");
ws.GetRow(rowIndex).Height = 69 * 20;
ws.GetRow(rowIndex + 1).Height = 15 * 20;
ws.GetRow(rowIndex + 2).Height = 30 * 20;
ws.SetColumnWidth(0, 5 * 256);
ws.SetColumnWidth(1, (int)(21.67 * 256));
ws.SetColumnWidth(2, (int)(9.78 * 256));
ws.SetColumnWidth(3, (int)(5.33 * 256));
ws.SetColumnWidth(4, (int)(7.67 * 256));
ws.SetColumnWidth(5, (int)(8.33 * 256));
ws.SetColumnWidth(6, (int)(7 * 256));
ws.SetColumnWidth(7, (int)(10.82 * 256));
ws.SetColumnWidth(8, (int)(8.33 * 256));
ws.SetColumnWidth(9, (int)(8.40 * 256));
ws.SetColumnWidth(10, (int)(15.67 * 256));
ws.SetColumnWidth(11, (int)(12 * 256));
ws.SetColumnWidth(12, (int)(8.22 * 256));
ws.SetColumnWidth(13, (int)(16.33 * 256));
ws.SetColumnWidth(14, (int)(11.45 * 256));
ws.SetColumnWidth(15, (int)(11.00 * 256));
ws.SetColumnWidth(16, (int)(4.00 * 256));
ws.SetColumnWidth(17, (int)(4.00 * 256));
ws.SetColumnWidth(18, (int)(9.00 * 256));
ws.SetColumnWidth(19, (int)(7 * 256));
#endregion
const int pageSize = 65;
var style3 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, false, false, "sans-serif");
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex + 3, dt.Rows.Count + 2, style3, 0, 19);
for (int i = 0; i < dt.Rows.Count; i++)
{
int startIndex = (i + 3);
ws.GetRow(startIndex).GetCell(0).SetCellValue(i + 1);
ws.GetRow(startIndex).GetCell(1).SetCellValue(dt.Rows[i]["SingleNumber"].ToString());
ws.GetRow(startIndex).GetCell(2).SetCellValue(dt.Rows[i]["DrawingsNum"].ToString());
ws.GetRow(startIndex).GetCell(3).SetCellValue(dt.Rows[i]["WeldJointCode"].ToString());
ws.GetRow(startIndex).GetCell(4).SetCellValue(dt.Rows[i]["WeldTypeCode"].ToString());
ws.GetRow(startIndex).GetCell(5).SetCellValue(dt.Rows[i]["WeldingLocationCode"].ToString());
ws.GetRow(startIndex).GetCell(6).SetCellValue(dt.Rows[i]["Size"].ToString());
ws.GetRow(startIndex).GetCell(7).SetCellValue(dt.Rows[i]["Specification"].ToString());
ws.GetRow(startIndex).GetCell(8).SetCellValue(dt.Rows[i]["WelderCode"].ToString());
ws.GetRow(startIndex).GetCell(9).SetCellValue(dt.Rows[i]["ComponentsName1"].ToString());
ws.GetRow(startIndex).GetCell(10).SetCellValue(dt.Rows[i]["MaterialCode1"].ToString());
ws.GetRow(startIndex).GetCell(11).SetCellValue(dt.Rows[i]["HeartNo1"].ToString());
ws.GetRow(startIndex).GetCell(12).SetCellValue(dt.Rows[i]["ComponentsName2"].ToString());
ws.GetRow(startIndex).GetCell(13).SetCellValue(dt.Rows[i]["MaterialCode2"].ToString());
ws.GetRow(startIndex).GetCell(14).SetCellValue(dt.Rows[i]["HeartNo2"].ToString());
ws.GetRow(startIndex).GetCell(15).SetCellValue(dt.Rows[i]["WeldingMethodName"].ToString());
ws.GetRow(startIndex).GetCell(16).SetCellValue("ACC");
ws.GetRow(startIndex).GetCell(17).SetCellValue("ACC");
ws.GetRow(startIndex).GetCell(18).SetCellValue(dt.Rows[i]["WeldingDate"].ToString());
ws.GetRow(startIndex).GetCell(19).SetCellValue(dt.Rows[i]["Remark"].ToString());
ws.GetRow(startIndex).Height = 10 * 20;
if (startIndex == pageSize)
{
ws.SetRowBreak(startIndex);
startIndex += pageSize;
}
}
if (dt.Rows.Count > 0)
{
string weldingDate = string.Empty;
if (txtStarTime.Text == txtEndTime.Text)
{
weldingDate = txtStarTime.Text;
}
else
{
weldingDate = txtStarTime.Text + "-" + txtEndTime.Text;
}
var style4 = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, BorderStyle.Thin, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 9, true, true, "Arial");
ws = ExcelCreateRow(ws, hssfworkbook, dt.Rows.Count + 3, dt.Rows.Count + 3, style4, 0, 19);
var distinctPipelineCode = dt.AsEnumerable().GroupBy(row => row.Field<string>("PipelineCode")).Select(group => group.First());
var distinctWelder = dt.AsEnumerable().GroupBy(row => row.Field<string>("WelderCode")).Select(group => group.First());
decimal sumSize = decimal.Parse(dt.Compute("sum(Size)", "").ToString());
ws.GetRow(dt.Rows.Count + 3).GetCell(0).SetCellValue("Total");
ws.GetRow(dt.Rows.Count + 3).GetCell(1).SetCellValue($"{distinctPipelineCode.Count().ToString()}");
ws.GetRow(dt.Rows.Count + 3).GetCell(3).SetCellValue($"{dt.Rows.Count}");
ws.GetRow(dt.Rows.Count + 3).GetCell(6).SetCellValue($"{sumSize}");
ws.GetRow(dt.Rows.Count + 3).GetCell(8).SetCellValue($"{distinctWelder.Count().ToString()}");
ws.GetRow(dt.Rows.Count + 3).Height = 20 * 20;
}
#region
IFooter footer = ws.Footer;
string str = " CC7: 监理: Worley:";
str += "\n\n第 &P 页,共 &N 页";
footer.Center = str;
#endregion
ws.FitToPage = true;
ws.PrintSetup.FitWidth = 1;
ws.PrintSetup.FitHeight = short.MaxValue;
ws.SetMargin(MarginType.LeftMargin, (double)1.2 / 3);
ws.SetMargin(MarginType.RightMargin, (double)0.5 / 3);
ws.SetMargin(MarginType.TopMargin, (double)1.8 / 3);
ws.SetMargin(MarginType.BottomMargin, (double)2.9 / 3);
ws.PrintSetup.Landscape = true;
ws.ForceFormulaRecalculation = true;
ws.PrintSetup.PaperSize = (int)PaperSize.A4_Small;
ws.RepeatingRows = new NPOI.SS.Util.CellRangeAddress(0, 2, 0, 19);
using (FileStream filess = System.IO.File.OpenWrite(ReportFileName))
{
hssfworkbook.Write(filess);
}
hssfworkbook.Close();
this.GetEmailTemplateAndSendEmail(ReportFileName);
File.Delete(ReportFileName);
ShowNotify("焊接日报发送成功!", MessageBoxIcon.Success);
}
catch (Exception ex)
{
ShowNotify($"发送失败,原因:{ex.Message}", MessageBoxIcon.Error);
}
}
protected void Window1_Close(object sender, EventArgs e)
{
@@ -580,7 +625,7 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
XSSFSheet ws = (XSSFSheet)hssfworkbook.CreateSheet("Sheet1");
int rowIndex = 0;
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 20, true, true, "微软雅黑");
var style = CommonPrint.SetExcelStyle(hssfworkbook, BorderStyle.None, BorderStyle.None, BorderStyle.None, BorderStyle.None, VerticalAlignment.Center, NPOI.SS.UserModel.HorizontalAlignment.Center, 20, true, true, "Arial");
#region
ws = ExcelCreateRow(ws, hssfworkbook, rowIndex, rowIndex, style, 0, 19, true);
@@ -86,6 +86,15 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
/// </remarks>
protected global::FineUIPro.DropDownList drpUnit;
/// <summary>
/// drpJointAttribute 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.DropDownList drpJointAttribute;
/// <summary>
/// drpTeamGroup 控件。
/// </summary>
@@ -104,6 +113,24 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
/// </remarks>
protected global::FineUIPro.DropDownList drpAudit;
/// <summary>
/// ToolbarFill1 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
/// <summary>
/// txtStarTime 控件。
/// </summary>
@@ -132,22 +159,13 @@ namespace FineUIPro.Web.WeldingProcess.WeldingReport
protected global::FineUIPro.DatePicker txtEndTime;
/// <summary>
/// ToolbarFill1 控件。
/// ToolbarFill2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// Toolbar2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Toolbar Toolbar2;
protected global::FineUIPro.ToolbarFill ToolbarFill2;
/// <summary>
/// BtnAnalyse 控件。