合并行提交

This commit is contained in:
2024-06-13 23:53:27 +08:00
parent 74a2cd0399
commit ccf6ac836d
3 changed files with 481 additions and 116 deletions
@@ -7,6 +7,7 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Web;
using System.Web.UI;
@@ -3995,85 +3996,85 @@ namespace FineUIPro.Web.WeldingProcess.TestPackageManage
{
var info = GetTestPackageInfo(this.tvControlItem.SelectedNodeID);
////模拟数据
//string sql = "SELECT '' AS totalNum,'' TestPackageNo,'' PipelineId,'模拟数据' PipelineCode,'' Specification,'' MaterialCode,'' WelderCode,'' FNum,'' NdeNum,'' FNdeNum,'' NdeCode from Sys_User union all SELECT '' AS totalNum,'' TestPackageNo,'' PipelineId,'模拟数据' PipelineCode,'' Specification,'' MaterialCode,'' WelderCode,'' FNum,'' NdeNum,'' FNdeNum,'' NdeCode from Sys_User union all SELECT '' AS totalNum,'' TestPackageNo,'' PipelineId,'模拟数据' PipelineCode,'' Specification,'' MaterialCode,'' WelderCode,'' FNum,'' NdeNum,'' FNdeNum,'' NdeCode from Sys_User";
//模拟数据
string sql = "SELECT top 5 'AA' PipelineCode,'BB' MaterialCode,'CC' Specification,'DD' jointCount,'EE' FjointCount,'W1' WelderCode,'3' WelderNum,'1' NdeNum,'11' FNdeNum,'2' NdeReportNo FROM Sys_User union all SELECT top 6 'FF' PipelineCode,'GG' MaterialCode,'HH' Specification,'II' jointCount,'JJ' FjointCount,'W2' WelderCode,'3' WelderNum,'1' NdeNum,'2' FNdeNum,'D2' NdeReportNo FROM Sys_User union all SELECT top 7 'KK' PipelineCode,'LL' MaterialCode,'MM' Specification,'NN' jointCount,'OO' FjointCount,'W3' WelderCode,'3' WelderNum,'1' NdeNum,'2' FNdeNum,'D3' NdeReportNo FROM Sys_User union all SELECT top 1 '1' PipelineCode,'2' MaterialCode,'3' Specification,'4' jointCount,'5' FjointCount,'6' WelderCode,'3' WelderNum,'1' NdeNum,'2' FNdeNum,'D3' NdeReportNo FROM Sys_User";
string sql = @"use HJGLDB_ZJBSF
// string sql = @"use HJGLDB_ZJBSF
select * from (
select d.PipelineCode,
(select MaterialCode from Base_Material as m where d.MainMaterialId=m.MaterialId) as MaterialCode ,
d.Specification,
(select count(1) from Pipeline_WeldJoint as joint where joint.PipelineId=a.PipelineId) as jointCount, --线
( case when a.isAll=1 then
(select count(1) from Pipeline_WeldJoint as joint where joint.PipelineId=a.PipelineId and joint.JointAttribute='F')
else
(select count(1) from Pipeline_WeldJoint as joint where joint.PipelineId=a.PipelineId and joint.JointAttribute='' and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0)
//select * from (
//select d.PipelineCode,
//(select MaterialCode from Base_Material as m where d.MainMaterialId=m.MaterialId) as MaterialCode ,
//d.Specification,
//(select count(1) from Pipeline_WeldJoint as joint where joint.PipelineId=a.PipelineId) as jointCount, --当前管线的焊口总数
// ( case when a.isAll=1 then
// (select count(1) from Pipeline_WeldJoint as joint where joint.PipelineId=a.PipelineId and joint.JointAttribute='固定F')
// else
// (select count(1) from Pipeline_WeldJoint as joint where joint.PipelineId=a.PipelineId and joint.JointAttribute='固定' and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0)
end ) as FjointCount, --线
c.WelderCode, --
( case when a.isAll=1 then
(select count(1) from View_Pipeline_WeldJoint as vjoint where vjoint.PipelineId=a.PipelineId and vjoint.WelderCode=c.WelderCode)
else
(select count(1) from View_Pipeline_WeldJoint as vjoint where vjoint.PipelineId=a.PipelineId
and CHARINDEX(','+vjoint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and vjoint.WelderCode=c.WelderCode)
end ) as WelderNum,
(case when a.isAll=1 then
(select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
ON trust.TrustBatchItemId = nde.TrustBatchItemId
inner join View_Pipeline_WeldJoint as joint
ON joint.WeldJointId=trust.WeldJointId
where joint.PipelineId=a.PipelineId and joint.WelderCode=c.WelderCode)
else
(
select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
ON trust.TrustBatchItemId = nde.TrustBatchItemId
inner join View_Pipeline_WeldJoint as joint
ON joint.WeldJointId=trust.WeldJointId
where joint.PipelineId=a.PipelineId and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and joint.WelderCode=c.WelderCode
)
end
) as NdeNum, --
(case when a.isAll=1 then
(select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
ON trust.TrustBatchItemId = nde.TrustBatchItemId
inner join View_Pipeline_WeldJoint as joint
ON joint.WeldJointId=trust.WeldJointId
where joint.PipelineId=a.PipelineId and joint.JointAttribute='F' and joint.WelderCode=c.WelderCode)
else
(
select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
ON trust.TrustBatchItemId = nde.TrustBatchItemId
inner join View_Pipeline_WeldJoint as joint
ON joint.WeldJointId=trust.WeldJointId
where joint.PipelineId=a.PipelineId and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and joint.JointAttribute='F' and joint.WelderCode=c.WelderCode
)
end
) as FNdeNum , --
(
case when a.isAll=1 then
(stuff((select ','+nde.NDEReportNo from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
ON trust.TrustBatchItemId = nde.TrustBatchItemId
inner join View_Pipeline_WeldJoint as joint
ON joint.WeldJointId=trust.WeldJointId
where joint.PipelineId=a.PipelineId and joint.WelderCode=c.WelderCode FOR xml path ('') ),1,1,''))
else
(stuff((select ','+nde.NDEReportNo from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
ON trust.TrustBatchItemId = nde.TrustBatchItemId
inner join View_Pipeline_WeldJoint as joint
ON joint.WeldJointId=trust.WeldJointId
where joint.PipelineId=a.PipelineId and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and joint.WelderCode=c.WelderCode FOR xml path ( '' ) ),1,1,'') )
end) as NdeReportNo
from
PTP_PipelineList as a inner join
PTP_TestPackage as b on a.PTP_ID=b.PTP_ID
inner join View_Pipeline_WeldJoint as c
on c.PipelineId=a.PipelineId
inner join Pipeline_Pipeline as d
on c.PipelineId=d.PipelineId
where b.PTP_ID=@PTPID and b.ProjectId=@projectId
) as t
group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCount,t.WelderCode,t.WelderNum,t.NdeNum,t.FNdeNum,t.NdeReportNo";
// end ) as FjointCount, --当前管线的焊口的固定口总数
//c.WelderCode, --焊工号
// ( case when a.isAll=1 then
// (select count(1) from View_Pipeline_WeldJoint as vjoint where vjoint.PipelineId=a.PipelineId and vjoint.WelderCode=c.WelderCode)
// else
// (select count(1) from View_Pipeline_WeldJoint as vjoint where vjoint.PipelineId=a.PipelineId
// and CHARINDEX(','+vjoint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and vjoint.WelderCode=c.WelderCode)
// end ) as WelderNum,
// (case when a.isAll=1 then
// (select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
// ON trust.TrustBatchItemId = nde.TrustBatchItemId
// inner join View_Pipeline_WeldJoint as joint
// ON joint.WeldJointId=trust.WeldJointId
// where joint.PipelineId=a.PipelineId and joint.WelderCode=c.WelderCode)
// else
// (
// select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
// ON trust.TrustBatchItemId = nde.TrustBatchItemId
// inner join View_Pipeline_WeldJoint as joint
// ON joint.WeldJointId=trust.WeldJointId
// where joint.PipelineId=a.PipelineId and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and joint.WelderCode=c.WelderCode
// )
// end
// ) as NdeNum, --检测口数量
// (case when a.isAll=1 then
// (select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
// ON trust.TrustBatchItemId = nde.TrustBatchItemId
// inner join View_Pipeline_WeldJoint as joint
// ON joint.WeldJointId=trust.WeldJointId
// where joint.PipelineId=a.PipelineId and joint.JointAttribute='固定F' and joint.WelderCode=c.WelderCode)
// else
// (
// select count(1) from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
// ON trust.TrustBatchItemId = nde.TrustBatchItemId
// inner join View_Pipeline_WeldJoint as joint
// ON joint.WeldJointId=trust.WeldJointId
// where joint.PipelineId=a.PipelineId and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and joint.JointAttribute='固定F' and joint.WelderCode=c.WelderCode
// )
// end
// ) as FNdeNum , --检测固定口数量
// (
// case when a.isAll=1 then
// (stuff((select ','+nde.NDEReportNo from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
// ON trust.TrustBatchItemId = nde.TrustBatchItemId
// inner join View_Pipeline_WeldJoint as joint
// ON joint.WeldJointId=trust.WeldJointId
// where joint.PipelineId=a.PipelineId and joint.WelderCode=c.WelderCode FOR xml path ('') ),1,1,''))
// else
// (stuff((select ','+nde.NDEReportNo from Batch_NDEItem as nde inner join Batch_BatchTrustItem as trust
// ON trust.TrustBatchItemId = nde.TrustBatchItemId
// inner join View_Pipeline_WeldJoint as joint
// ON joint.WeldJointId=trust.WeldJointId
// where joint.PipelineId=a.PipelineId and CHARINDEX(','+joint.WeldJointCode+',',','+a.WeldJonintCode+'')>0 and joint.WelderCode=c.WelderCode FOR xml path ( '' ) ),1,1,'') )
// end) as NdeReportNo
//from
//PTP_PipelineList as a inner join
//PTP_TestPackage as b on a.PTP_ID=b.PTP_ID
//inner join View_Pipeline_WeldJoint as c
//on c.PipelineId=a.PipelineId
//inner join Pipeline_Pipeline as d
//on c.PipelineId=d.PipelineId
//where b.PTP_ID=@PTPID and b.ProjectId=@projectId
//) as t
//group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCount,t.WelderCode,t.WelderNum,t.NdeNum,t.FNdeNum,t.NdeReportNo";
SqlParameter[] parms =
{
@@ -4245,10 +4246,14 @@ group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCoun
for (int k = rowIndex + 7; k < rowIndex + 16; k++)
{
ws.GetRow(k).Height = 18 * 20;
ws.AddMergedRegion(new CellRangeAddress(k, k, 0, 1));
ws.AddMergedRegion(new CellRangeAddress(k, k, 3, 4));
ws.AddMergedRegion(new CellRangeAddress(k, k, 5, 6));
ws.AddMergedRegion(new CellRangeAddress(k, k, 7, 8));
//小计行
if (k == rowIndex + 15)
{
ws.AddMergedRegion(new CellRangeAddress(k, k, 0, 1));
ws.AddMergedRegion(new CellRangeAddress(k, k, 3, 4));
ws.AddMergedRegion(new CellRangeAddress(k, k, 5, 6));
ws.AddMergedRegion(new CellRangeAddress(k, k, 7, 8));
}
ws.AddMergedRegion(new CellRangeAddress(k, k, 9, 10));
ws.AddMergedRegion(new CellRangeAddress(k, k, 11, 12));
ws.AddMergedRegion(new CellRangeAddress(k, k, 13, 14));
@@ -4260,6 +4265,13 @@ group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCoun
var pageTb = GetPageToTable(tb, dStart, dEnd);
int j = 0;
var pagelist = DataTableEx.ToList<template22Dto>(pageTb);
int oneNum = 1;
int twoNum = 1;
int threeNum = 1;
int fourNum = 1;
int fiveNum = 1;
for (int k = 0; k < 8; k++)
{
int dataIndex = dataTit + j;
@@ -4267,10 +4279,83 @@ group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCoun
{
DataRow dr = pageTb.Rows[k];
ws.GetRow(dataIndex).GetCell(0).SetCellValue(dr["PipelineCode"].ToString());
var PipelineCodeNum = pagelist.Count(x => x.PipelineCode == dr["PipelineCode"].ToString());
if (PipelineCodeNum > 1)
{
if (oneNum == 1)
{
oneNum += PipelineCodeNum;
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex + PipelineCodeNum - 1, 0, 1));
}
oneNum -= 1;
}
else
{
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 0, 1));
}
ws.GetRow(dataIndex).GetCell(2).SetCellValue(dr["MaterialCode"].ToString());
var MaterialCodeNum = pagelist.Count(x => x.MaterialCode == dr["MaterialCode"].ToString());
if (MaterialCodeNum > 1)
{
if (twoNum == 1)
{
twoNum += MaterialCodeNum;
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex + MaterialCodeNum - 1, 2, 2));
}
twoNum -= 1;
}
ws.GetRow(dataIndex).GetCell(3).SetCellValue(dr["Specification"].ToString());
var SpecificationNum = pagelist.Count(x => x.Specification == dr["Specification"].ToString());
if (SpecificationNum > 1)
{
if (threeNum == 1)
{
threeNum += SpecificationNum;
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex + SpecificationNum - 1, 3, 4));
}
threeNum -= 1;
}
else
{
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 3, 4));
}
ws.GetRow(dataIndex).GetCell(5).SetCellValue(dr["jointCount"].ToString());
ws.GetRow(dataIndex).GetCell(7).SetCellValue(dr["fjointCount"].ToString());
var jointCountNum = pagelist.Count(x => x.jointCount == dr["jointCount"].ToString());
if (jointCountNum > 1)
{
if (fourNum == 1)
{
fourNum += jointCountNum;
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex + jointCountNum - 1, 5, 6));
}
fourNum -= 1;
}
else
{
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 5, 6));
}
ws.GetRow(dataIndex).GetCell(7).SetCellValue(dr["FjointCount"].ToString());
var FjointCountNum = pagelist.Count(x => x.FjointCount == dr["FjointCount"].ToString());
if (FjointCountNum > 1)
{
if (fiveNum == 1)
{
fiveNum += FjointCountNum;
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex + FjointCountNum - 1, 7, 8));
}
fiveNum -= 1;
}
else
{
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 7, 8));
}
ws.GetRow(dataIndex).GetCell(9).SetCellValue(dr["WelderCode"].ToString());
ws.GetRow(dataIndex).GetCell(11).SetCellValue(dr["WelderNum"].ToString());
ws.GetRow(dataIndex).GetCell(13).SetCellValue(dr["NdeNum"].ToString());
@@ -4289,43 +4374,16 @@ group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCoun
}
ws.GetRow(dataIndex).GetCell(20).SetCellValue(dr["NdeReportNo"].ToString());
}
else
{
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 0, 1));
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 3, 4));
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 5, 6));
ws.AddMergedRegion(new CellRangeAddress(dataIndex, dataIndex, 7, 8));
}
j++;
}
//foreach (DataRow dr in pageTb.Rows)
//{
// int dataIndex = dataTit + j;
// ws.GetRow(dataIndex).GetCell(0).SetCellValue(dr["PipelineCode"].ToString());
// ws.GetRow(dataIndex).GetCell(2).SetCellValue(dr["MaterialCode"].ToString());
// ws.GetRow(dataIndex).GetCell(3).SetCellValue(dr["Specification"].ToString());
// ws.GetRow(dataIndex).GetCell(5).SetCellValue(dr["totalNum"].ToString());
// ws.GetRow(dataIndex).GetCell(7).SetCellValue(dr["Fnum"].ToString());
// ws.GetRow(dataIndex).GetCell(9).SetCellValue(dr["WelderCode"].ToString());
// ws.GetRow(dataIndex).GetCell(11).SetCellValue(dr["Fnum"].ToString());
// ws.GetRow(dataIndex).GetCell(13).SetCellValue(dr["NdeNum"].ToString());
// ws.GetRow(dataIndex).GetCell(15).SetCellValue(dr["FNdeNum"].ToString());
// string a = string.IsNullOrEmpty(dr["NdeNum"].ToString()) ? "0" : dr["NdeNum"].ToString();
// string b = string.IsNullOrEmpty(dr["Fnum"].ToString()) ? "0" : dr["Fnum"].ToString();
// if (b == "0")
// {
// ws.GetRow(dataIndex).GetCell(17).SetCellValue("0%");
// }
// else
// {
// decimal rate = Math.Round((decimal.Parse(a) / decimal.Parse(b)), 2);
// ws.GetRow(dataIndex).GetCell(17).SetCellValue($"{rate * 100}%");
// }
// ws.GetRow(dataIndex).GetCell(20).SetCellValue(dr["NdeCode"].ToString());
// //模拟数据
// j++;
//}
ws.GetRow(rowIndex + 15).GetCell(0).SetCellValue("小计\r\nTotal");
ws.GetRow(rowIndex + 15).Height = 30 * 20;
@@ -4409,7 +4467,7 @@ group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCoun
#endregion
rowIndex = rowIndex + 23;
rowIndex = rowIndex + 24;
}
ws.PrintSetup.Landscape = true;
@@ -7787,6 +7845,24 @@ group by t.PipelineCode,t.MaterialCode,t.Specification,t.jointCount,t.FjointCoun
pict.Resize(w, h);
}
/// <summary>
/// 22 实体
/// </summary>
private class template22Dto
{
public string PipelineCode { get; set; }
public string MaterialCode { get; set; }
public string Specification { get; set; }
public string jointCount { get; set; }
public string FjointCount { get; set; }
public string WelderCode { get; set; }
public string WelderNum { get; set; }
public string NdeNum { get; set; }
public string FNdeNum { get; set; }
public string NdeReportNo { get; set; }
}
#endregion
}
#endregion