@@ -2,10 +2,13 @@
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.IO ;
using System.Linq ;
using System.Web ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
using Aspose.Words ;
using Aspose.Words.Tables ;
using BLL ;
namespace FineUIPro.Web.CQMS.ManageReportNew
@@ -142,5 +145,771 @@ namespace FineUIPro.Web.CQMS.ManageReportNew
}
}
#endregion
#region 导 出
/**
* 创建列值
* @param value 要插入的值
* @param doc Document对象
* @return
*/
public static Cell CreateCell ( String value , Document doc , double cellWidth )
{
Cell cell = new Cell ( doc ) ;
Paragraph p = new Paragraph ( doc ) ;
p . AppendChild ( new Run ( doc , value ) ) ;
cell . CellFormat . Width = cellWidth ;
cell . AppendChild ( p ) ;
return cell ;
}
protected void btnPrinter_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length = = 0 )
{
Alert . ShowInTop ( "请至少选择一条记录!" , MessageBoxIcon . Warning ) ;
return ;
}
string Id = Grid1 . SelectedRowID ; //质量月报的主键
try
{
string rootPath = Server . MapPath ( "~/" ) ;
string initTemplatePath = string . Empty ;
string uploadfilepath = string . Empty ;
string newUrl = string . Empty ;
string filePath = string . Empty ;
Model . SGGLDB db = Funs . DB ;
initTemplatePath = Const . MonthReportNewTemplateUrl ;
uploadfilepath = rootPath + initTemplatePath ;
newUrl = uploadfilepath . Replace ( ".doc" , "(" + Funs . GetNewFileName ( ) + ")" + ".doc" ) ;
if ( File . Exists ( newUrl ) )
{
File . Delete ( newUrl ) ;
}
File . Copy ( uploadfilepath , newUrl ) ;
//更新书签内容
Document doc = new Aspose . Words . Document ( newUrl ) ;
DocumentBuilder builder = new DocumentBuilder ( doc ) ;
//根据id获取质量月报主表数据
var weekModel = db . Report_WeekAndMonthReport_New . FirstOrDefault ( x = > x . Id = = Id ) ;
var startDate = Convert . ToDateTime ( weekModel . StartDate ) ;
var endDate = Convert . ToDateTime ( weekModel . EndDate ) ;
//获取project
var pModel = db . Base_Project . FirstOrDefault ( x = > x . ProjectId = = weekModel . ProjectId ) ;
#region 头 部 静 态 列
Bookmark bkmark = doc . Range . Bookmarks [ "username" ] ;
if ( bkmark ! = null ) {
var uModel = db . Sys_User . FirstOrDefault ( x = > x . UserId = = weekModel . CreateMan ) ;
if ( uModel ! = null )
{
bkmark . Text = uModel . UserName ;
}
}
bkmark = doc . Range . Bookmarks [ "projectNo" ] ;
if ( bkmark ! = null )
{
bkmark . Text = pModel . ProjectCode ;
}
bkmark = doc . Range . Bookmarks [ "createdate" ] ;
if ( bkmark ! = null )
{
bkmark . Text = weekModel . CreateDate . ToString ( ) . Split ( ' ' ) [ 0 ] . Replace ( '/' , '.' ) ;
}
bkmark = doc . Range . Bookmarks [ "projectname" ] ;
if ( bkmark ! = null )
{
bkmark . Text = pModel . ProjectName + "(" + pModel . ProjectCode + ")" ;
}
bkmark = doc . Range . Bookmarks [ "quamanagername" ] ;
if ( bkmark ! = null ) {
var zlName = "" ;
//根据项目获取质量经理
var puserList = db . Project_ProjectUser . Where ( x = > x . ProjectId = = weekModel . ProjectId & & x . RoleId . Contains ( BLL . Const . QAManager ) ) . ToList ( ) ;
foreach ( var item in puserList )
{
zlName + = db . Sys_User . FirstOrDefault ( x = > x . UserId = = item . UserId ) . UserName + "," ;
}
bkmark . Text = zlName ;
}
bkmark = doc . Range . Bookmarks [ "reportAlldate" ] ;
//20XX年XX月XX日至20XX年XX月XX日
if ( bkmark ! = null )
{
var sdate = Convert . ToDateTime ( weekModel . StartDate ) ;
var edate = Convert . ToDateTime ( weekModel . EndDate ) ;
bkmark . Text = sdate . Year + "年" + sdate . Month + "月" + sdate . Day + "日至" +
edate . Year + "年" + edate . Month + "月" + edate . Day + "日" ;
}
bkmark = doc . Range . Bookmarks [ "reportindex" ] ;
if ( bkmark ! = null )
{
bkmark . Text = weekModel . SortId ;
}
bkmark = doc . Range . Bookmarks [ "fromcode" ] ;
//fromcode,项目号-RM-PQM-顺序号
if ( bkmark ! = null )
{
bkmark . Text = pModel . ProjectCode + "-RM-PQM-" + weekModel . SortId ;
}
#endregion
#region 本 月 质 量 目 标 管 理 情 况
//获取word文档中的第二个表格
int whileIndex = 1 ;
Aspose . Words . Tables . Table table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , 1 , true ) ;
bool isYm = true ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else {
isYm = false ;
}
}
var cqrmTargetList = db . Report_CqmsTarget . Where ( x = > x . ReportId = = Id ) . OrderBy ( x = > x . SortId ) ;
int numberIndex = 1 ;
foreach ( var item in cqrmTargetList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . ProStage , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . ProDescribe , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . TargetValue , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . MonthPer , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 5 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
#endregion
#region 本 月 主 要 工 作 内 容
var txtReportList = Funs . DB . Report_TextBoxContent . Where ( x = > x . ReportId = = Id ) . ToList ( ) ;
bkmark = doc . Range . Bookmarks [ "Content1" ] ;
if ( bkmark ! = null )
{
bkmark . Text = txtReportList . FirstOrDefault ( x = > x . ContentType = = "0" ) . ContentText ;
}
bkmark = doc . Range . Bookmarks [ "Content2" ] ;
if ( bkmark ! = null )
{
bkmark . Text = txtReportList . FirstOrDefault ( x = > x . ContentType = = "1" ) . ContentText ;
}
bkmark = doc . Range . Bookmarks [ "Content3" ] ;
if ( bkmark ! = null )
{
bkmark . Text = txtReportList . FirstOrDefault ( x = > x . ContentType = = "2" ) . ContentText ;
}
#endregion
var ContuructionAllList = db . Report_Construction_Plan . Where ( x = > x . ReportId = = Id ) . OrderBy ( x = > x . UnitOrMajor ) . ToList ( ) ;
#region 3. 施 工 方 案 及 检 验 试 验 计 划 审 批 情 况
#region 一 般 施 工 方 案 审 批 情 况
var ybsgfaList = ContuructionAllList . Where ( x = > x . ReType = = "0" ) . ToList ( ) ;
if ( ybsgfaList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 1 ;
int? num1 = 0 , num2 = 0 ;
foreach ( var item in ybsgfaList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitOrMajor , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
num1 + = item . Quantity1 ;
num2 + = item . Quantity2 ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#region 危 大 工 程 方 案 审 批 情 况
var wdsgfaList = ContuructionAllList . Where ( x = > x . ReType = = "1" ) . ToList ( ) ;
if ( wdsgfaList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 1 ;
int? num1 = 0 , num2 = 0 , num3 = 0 ;
foreach ( var item in wdsgfaList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitOrMajor , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity3 . ToString ( ) , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 5 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
num1 + = item . Quantity1 ;
num2 + = item . Quantity2 ;
num3 + = item . Quantity3 ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num3 . ToString ( ) , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 5 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#region 质 量 控 制 点 或 检 验 试 验 计 划 ( ITP ) 情 况
var itpList = ContuructionAllList . Where ( x = > x . ReType = = "2" ) . ToList ( ) ;
if ( itpList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 1 ;
int? num1 = 0 , num2 = 0 ;
foreach ( var item in itpList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitOrMajor , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
num1 + = item . Quantity1 ;
num2 + = item . Quantity2 ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#endregion
#region 设 计 交 底 管 理 情 况
var sjjdList = ContuructionAllList . Where ( x = > x . ReType = = "3" ) . ToList ( ) ;
if ( sjjdList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 1 ;
int? num1 = 0 , num2 = 0 ;
foreach ( var item in sjjdList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitOrMajor , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
num1 + = item . Quantity1 ;
num2 + = item . Quantity2 ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#region 图 纸 会 审 管 理 情 况
var tzhsList = ContuructionAllList . Where ( x = > x . ReType = = "4" ) . ToList ( ) ;
if ( tzhsList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 1 ;
int? num1 = 0 , num2 = 0 ;
foreach ( var item in tzhsList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitOrMajor , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
num1 + = item . Quantity1 ;
num2 + = item . Quantity2 ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#region 6. 设 计 变 更 管 理 情 况
int Quantity1Sum = 0 , Quantity2Sum = 0 , Quantity3Sum = 0 , Quantity4Sum = 0 , Quantity5Sum = 0 , Quantity6Sum = 0 ;
DateTime projectStartDate = Convert . ToDateTime ( "2015-01-01" ) ;
List < Model . CheckStatisc > StatisticsList = new List < Model . CheckStatisc > ( ) ;
Model . Base_Project project = BLL . ProjectService . GetProjectByProjectId ( this . CurrUser . LoginProjectId ) ;
if ( project ! = null )
{
if ( project . StartDate ! = null )
{
projectStartDate = Convert . ToDateTime ( project . StartDate ) ;
}
}
int i = 1 ;
var cNProfessionals = from x in Funs . DB . Base_CNProfessional orderby x . SortIndex select x ;
foreach ( var item in cNProfessionals )
{
//专业下所有集合
List < Model . Comprehensive_DesignChangeOrder > totalManagementList = BLL . DesignChangeOrderService . GetDesignChangeOrderListByCNProfessionalIdAndDate ( this . CurrUser . LoginProjectId , item . CNProfessionalId , projectStartDate , DateTime . Now ) ;
//专业下当期集合
List < Model . Comprehensive_DesignChangeOrder > managementList = BLL . DesignChangeOrderService . GetDesignChangeOrderListByCNProfessionalIdAndDate ( this . CurrUser . LoginProjectId , item . CNProfessionalId , startDate , endDate ) ;
Model . CheckStatisc checkStatisc = new Model . CheckStatisc ( ) ;
checkStatisc . Num = i ;
checkStatisc . WorkName = item . ProfessionalName ;
checkStatisc . CheckNum = managementList . Count ( ) ;
checkStatisc . TotalCheckNum = totalManagementList . Count ( ) ;
checkStatisc . OKNum = managementList . Count ( x = > x . ApprovalDate ! = null ) ;
checkStatisc . TotalOKNum = totalManagementList . Count ( x = > x . ApprovalDate ! = null ) ;
checkStatisc . OneOKRate = managementList . Count ( x = > x . Status = = "3" ) . ToString ( ) ; //当期完成数
checkStatisc . TotalOneOKRate = totalManagementList . Count ( x = > x . Status = = "3" ) . ToString ( ) ; //累计完成数
StatisticsList . Add ( checkStatisc ) ;
Quantity1Sum + = checkStatisc . CheckNum ;
Quantity2Sum + = checkStatisc . TotalCheckNum ;
Quantity3Sum + = checkStatisc . OKNum ;
Quantity4Sum + = checkStatisc . TotalOKNum ;
Quantity5Sum + = Convert . ToInt32 ( checkStatisc . OneOKRate ) ;
Quantity6Sum + = Convert . ToInt32 ( checkStatisc . TotalOneOKRate ) ;
}
if ( StatisticsList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 2 ;
//需要插入的table
foreach ( var item in StatisticsList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( ( numberIndex - 1 ) . ToString ( ) , doc , table . Rows [ 0 ] . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . WorkName , doc , table . Rows [ 0 ] . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . CheckNum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . TotalCheckNum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . OKNum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 4 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . TotalOKNum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 5 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . OneOKRate . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 6 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . TotalOneOKRate . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 7 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . Rows [ 0 ] . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . Rows [ 0 ] . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity1Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity2Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity3Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 4 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity4Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 5 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity5Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 6 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity6Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 7 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#region 7.1 合 格 焊 工 管 理 情 况
Quantity1Sum = 0 ; Quantity2Sum = 0 ; Quantity3Sum = 0 ; Quantity4Sum = 0 ; Quantity5Sum = 0 ; Quantity6Sum = 0 ;
int Quantity7Sum = 0 , Quantity8Sum = 0 ;
List < Model . PassWelderStatisc > PassWelderList = new List < Model . PassWelderStatisc > ( ) ;
if ( project ! = null )
{
if ( project . StartDate ! = null )
{
projectStartDate = Convert . ToDateTime ( project . StartDate ) ;
}
}
i = 1 ;
var units = from x in Funs . DB . Project_ProjectUnit
join y in Funs . DB . Base_Unit on x . UnitId equals y . UnitId
where x . ProjectId = = this . CurrUser . LoginProjectId & & x . UnitType = = BLL . Const . ProjectUnitType_2
orderby y . UnitCode
select new { x . UnitId , y . UnitName } ;
foreach ( var item in units )
{
var query = from c in db . Comprehensive_InspectionPerson
join u in db . Base_Unit on c . UnitId equals u . UnitId into unitJoin
from u in unitJoin . DefaultIfEmpty ( )
join cn in db . Base_CNProfessional on c . CNProfessionalId equals cn . CNProfessionalId into cnJoin
from cn in cnJoin . DefaultIfEmpty ( )
join p in db . Base_Post on c . PostId equals p . PostId into postJoin
from p in postJoin . DefaultIfEmpty ( )
where c . ProjectId = = this . CurrUser . LoginProjectId & & c . UnitId = = item . UnitId
select new
{
c . InspectionPersonId ,
c . ProjectId ,
u . UnitId ,
u . UnitName ,
c . PersonName ,
c . ApprovalTime ,
cn . ProfessionalName ,
p . PostName
} ;
//单位下所有集合
// List<Model.BS_Welder> totalWelderList = BLL.PersonManageService.GetWelderListByUnitId(this.CurrUser.LoginProjectId, item.UnitId);
//List<Model.BS_Welder> welderList = BLL.PersonManageService.GetWelderListByUnitIdAndDate(this.CurrUser.LoginProjectId, item.UnitId, startDate, endDate);
var totalWelderList = query . ToList ( ) ;
var welderList = query
. Where ( x = > ( x . ApprovalTime > = Convert . ToDateTime ( startDate ) & & x . ApprovalTime < = Convert . ToDateTime ( endDate ) ) ) ;
Model . PassWelderStatisc passWelderStatisc = new Model . PassWelderStatisc ( ) ;
passWelderStatisc . Num = i ;
passWelderStatisc . UnitName = item . UnitName ;
passWelderStatisc . PipeMountGuard = welderList . Count ( x = > x . ProfessionalName = = "管道" & & x . PostName = = "焊工" ) ;
passWelderStatisc . PipeTotal = totalWelderList . Count ( x = > x . ProfessionalName = = "管道" & & x . PostName = = "焊工" ) ;
passWelderStatisc . SteelStructureMountGuard = welderList . Count ( x = > x . ProfessionalName = = "土建" & & x . PostName = = "焊工" ) ;
passWelderStatisc . SteelStructureTotal = totalWelderList . Count ( x = > x . ProfessionalName = = "土建" & & x . PostName = = "焊工" ) ;
passWelderStatisc . EquipmentMountGuard = welderList . Count ( x = > x . ProfessionalName = = "设备" & & x . PostName = = "焊工" ) ;
passWelderStatisc . EquipmentTotal = totalWelderList . Count ( x = > x . ProfessionalName = = "设备" & & x . PostName = = "焊工" ) ;
passWelderStatisc . OtherMountGuard = welderList . Count ( x = > x . ProfessionalName ! = "管道" & & x . ProfessionalName ! = "土建" & & x . ProfessionalName ! = "设备" & & x . PostName = = "焊工" ) ;
passWelderStatisc . OtherTotal = totalWelderList . Count ( x = > x . ProfessionalName ! = "管道" & & x . ProfessionalName ! = "土建" & & x . ProfessionalName ! = "设备" & & x . PostName = = "焊工" ) ;
PassWelderList . Add ( passWelderStatisc ) ;
i + + ;
Quantity1Sum + = passWelderStatisc . PipeMountGuard ;
Quantity2Sum + = passWelderStatisc . PipeTotal ;
Quantity3Sum + = passWelderStatisc . SteelStructureMountGuard ;
Quantity4Sum + = passWelderStatisc . SteelStructureTotal ;
Quantity5Sum + = passWelderStatisc . EquipmentMountGuard ;
Quantity6Sum + = passWelderStatisc . EquipmentTotal ;
Quantity7Sum + = passWelderStatisc . OtherMountGuard ;
Quantity8Sum + = passWelderStatisc . OtherTotal ;
}
if ( PassWelderList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 2 ;
//需要插入的table
foreach ( var item in PassWelderList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( ( numberIndex - 1 ) . ToString ( ) , doc , table . Rows [ 0 ] . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitName , doc , table . Rows [ 0 ] . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . PipeMountGuard . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . PipeTotal . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . SteelStructureMountGuard . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 4 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . SteelStructureTotal . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 5 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . EquipmentMountGuard . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 6 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . EquipmentTotal . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 7 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . OtherMountGuard . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 8 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . OtherTotal . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 9 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . Rows [ 0 ] . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . Rows [ 0 ] . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity1Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity2Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity3Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 4 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity4Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 5 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity5Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 6 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity6Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 7 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity7Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 8 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( Quantity8Sum . ToString ( ) , doc , table . Rows [ 1 ] . Cells [ 9 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
#region 7.2 PQR / WPS报验情况
var pqrList = ContuructionAllList . Where ( x = > x . ReType = = "5" ) . ToList ( ) ;
if ( pqrList . Count > 0 )
{
isYm = true ;
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
//跳过页眉的表头
while ( isYm )
{
if ( table . Range . Text . Substring ( 0 , 2 ) ! = "序号" )
{
whileIndex + = 1 ;
table = ( Aspose . Words . Tables . Table ) doc . GetChild ( NodeType . Table , whileIndex , true ) ;
}
else
{
isYm = false ;
}
}
numberIndex = 1 ;
int? num1 = 0 , num2 = 0 ;
foreach ( var item in pqrList )
{
//创建行
Row row = new Row ( doc ) ;
row . Cells . Add ( CreateCell ( numberIndex . ToString ( ) , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . UnitOrMajor , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Quantity2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
row . Cells . Add ( CreateCell ( item . Remarks , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , row ) ;
num1 + = item . Quantity1 ;
num2 + = item . Quantity2 ;
numberIndex + = 1 ;
}
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
//创建合计
//创建行
Row rowhj = new Row ( doc ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 0 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "合计" , doc , table . FirstRow . Cells [ 1 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num1 . ToString ( ) , doc , table . FirstRow . Cells [ 2 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( num2 . ToString ( ) , doc , table . FirstRow . Cells [ 3 ] . CellFormat . Width ) ) ;
rowhj . Cells . Add ( CreateCell ( "" , doc , table . FirstRow . Cells [ 4 ] . CellFormat . Width ) ) ;
table . Rows . Insert ( numberIndex , rowhj ) ;
//自动设置表格样式
table . AutoFit ( AutoFitBehavior . FixedColumnWidths ) ;
}
#endregion
doc . Save ( newUrl ) ;
string fileName = Path . GetFileName ( newUrl ) ;
FileInfo info = new FileInfo ( newUrl ) ;
long fileSize = info . Length ;
Response . Clear ( ) ;
Response . ContentType = "application/x-zip-compressed" ;
Response . AddHeader ( "Content-Disposition" , "attachment;filename=" + System . Web . HttpUtility . UrlEncode ( fileName , System . Text . Encoding . UTF8 ) ) ;
Response . AddHeader ( "Content-Length" , fileSize . ToString ( ) ) ;
Response . TransmitFile ( newUrl , 0 , fileSize ) ;
Response . Flush ( ) ;
Response . Close ( ) ;
File . Delete ( newUrl ) ;
}
catch ( Exception ex )
{
Alert . ShowInTop ( ex . Message , MessageBoxIcon . Warning ) ;
throw ;
}
}
#endregion
}
}