2025-02-12 09:27:47 +08:00
using BLL ;
using System ;
using System.Collections.Generic ;
using System.Data ;
using System.Data.SqlClient ;
using System.Linq ;
using Newtonsoft.Json.Linq ;
using System.IO ;
using NPOI.XSSF.UserModel ;
using NPOI.SS.UserModel ;
using System.Runtime.Serialization ;
using NPOI.SS.Util ;
using NPOI.HSSF.UserModel ;
using AspNet = System . Web . UI . WebControls ;
namespace FineUIPro.Web.HJGL.WeldingReport
{
public partial class OneWeekReport : PageBase
{
#region 定 义 变 量
/// <summary>
/// 主键
/// </summary>
public string NDTReportId
{
get
{
return ( string ) ViewState [ "NDTReportId" ] ;
}
set
{
ViewState [ "NDTReportId" ] = value ;
}
}
#endregion
#region 加 载
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
List < Model . Base_Unit > units = new List < Model . Base_Unit > ( ) ;
var pUnit = BLL . ProjectUnitService . GetProjectUnitByUnitIdProjectId ( this . CurrUser . LoginProjectId , this . CurrUser . UnitId ) ;
if ( pUnit = = null | | pUnit . UnitType = = Const . ProjectUnitType_1 )
{
units = BLL . UnitService . GetUnitByProjectIdUnitTypeList ( this . CurrUser . LoginProjectId , BLL . Const . ProjectUnitType_2 ) ;
this . drpUnit . DataTextField = "UnitName" ;
this . drpUnit . DataValueField = "UnitId" ;
this . drpUnit . DataSource = units ;
this . drpUnit . DataBind ( ) ;
this . drpUnit . SelectedValue = CurrUser . UnitId ;
Funs . FineUIPleaseSelect ( this . drpUnit ) ;
}
else
{
units = BLL . UnitService . GetSubUnitsListBySupervisorUnitId ( this . CurrUser . LoginProjectId , this . CurrUser . UnitId ) ;
this . drpUnit . Enabled = false ;
this . drpUnit . DataTextField = "UnitName" ;
this . drpUnit . DataValueField = "UnitId" ;
this . drpUnit . DataSource = units ;
this . drpUnit . DataBind ( ) ;
this . drpUnit . SelectedValue = CurrUser . UnitId ;
}
///单位
this . txtEndDate . Text = string . Format ( "{0:yyyy-MM-dd}" , DateTime . Now ) ;
this . txtStartDate . Text = string . Format ( "{0:yyyy-MM-dd}" , DateTime . Now . AddDays ( - 6 ) ) ;
if ( this . drpUnit . SelectedValue = = BLL . Const . _Null )
{
this . drpUnit . SelectedIndex = 1 ;
}
//BindGrid();
}
}
private void BindGrid ( )
{
string strSql0 = @"SELECT 0 id, WorkArea.WorkAreaId, WorkArea.WorkAreaCode ,--工区代号
WorkArea.WorkAreaName ,--工区代号
CAST(ISNULL(total_jot.total_din,0) AS DECIMAL(19,2)) AS total_din ,--总达因
finished_total_din_bq,week_total_din_bq,0 res_din, '' has_per ,WelderNum
FROM ProjectData_WorkArea AS WorkArea
LEFT JOIN (SELECT COUNT(*) total_jot ,pw_isoinfo.WorkAreaId ,
SUM( case when pw_isoinfo.[Is_Standard] = 0 then JOT_Size else JOT_Size end) AS total_din
,SUM(JOT_DoneDin) AS finished_total_din
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId ='" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId) AS total_jot ON total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS finished_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as has_total_jot on has_total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS week_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as week_total_jot on week_total_jot.WorkAreaId = WorkArea.WorkAreaId
left join(
select WorkAreaId, sum(WelderNum)as WelderNum from(
select WorkAreaId,[day],[month], COUNT(distinct JOT_CellWelder) as WelderNum from(SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_CellWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
union
SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_FloorWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
) as a group by WorkAreaId,[day],[month]) as b group by b.WorkAreaId) as week_welder_num on week_welder_num.WorkAreaId = WorkArea.WorkAreaId
WHERE WorkArea.ProjectId = '" + this . CurrUser . LoginProjectId + "' and WorkArea.UnitId ='" + this . drpUnit . SelectedValue + @"'
" ;
SqlParameter [ ] parameter0 = new SqlParameter [ ] { } ;
DataTable tb0 = SQLHelper . GetDataTableRunText ( strSql0 , parameter0 ) ;
if ( tb0 ! = null )
{
var newRow = tb0 . NewRow ( ) ;
newRow [ "WorkAreaName" ] = "合计" ;
newRow [ "WorkAreaCode" ] = "" ;
newRow [ "WorkAreaId" ] = "total" ;
decimal total_din = 0 ;
decimal finished_total_din_bq = 0 ;
decimal week_total_din_bq = 0 ;
int WelderNum = 0 ;
for ( int i = 0 ; i < tb0 . Rows . Count ; i + + )
{
try
{
total_din + = decimal . Parse ( tb0 . Rows [ i ] [ "total_din" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
finished_total_din_bq + = decimal . Parse ( tb0 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
week_total_din_bq + = decimal . Parse ( tb0 . Rows [ i ] [ "week_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
WelderNum + = int . Parse ( tb0 . Rows [ i ] [ "WelderNum" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb0 . Rows [ i ] [ "res_din" ] = decimal . Parse ( tb0 . Rows [ i ] [ "total_din" ] . ToString ( ) ) - decimal . Parse ( tb0 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb0 . Rows [ i ] [ "has_per" ] = ( 100 * decimal . Parse ( tb0 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) / decimal . Parse ( tb0 . Rows [ i ] [ "total_din" ] . ToString ( ) ) ) . ToString ( "##.##" ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
}
newRow [ "total_din" ] = total_din ;
newRow [ "finished_total_din_bq" ] = finished_total_din_bq ;
newRow [ "week_total_din_bq" ] = week_total_din_bq ;
newRow [ "WelderNum" ] = WelderNum ;
try
{
newRow [ "res_din" ] = decimal . Parse ( newRow [ "total_din" ] . ToString ( ) ) - decimal . Parse ( newRow [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
newRow [ "has_per" ] = ( 100 * decimal . Parse ( newRow [ "finished_total_din_bq" ] . ToString ( ) ) / decimal . Parse ( newRow [ "total_din" ] . ToString ( ) ) ) . ToString ( "##.##" ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
tb0 . Rows . Add ( newRow ) ;
}
this . Grid0 . DataSource = tb0 ;
this . Grid0 . DataBind ( ) ;
string strSql1 = @"SELECT 0 id, WorkArea.WorkAreaId, WorkArea.WorkAreaCode ,--工区代号
WorkArea.WorkAreaName ,--工区代号
CAST(ISNULL(total_jot.total_din,0) AS DECIMAL(19,2)) AS total_din ,--总达因
finished_total_din_bq,week_total_din_bq,0 res_din, '' has_per ,WelderNum
FROM ProjectData_WorkArea AS WorkArea
LEFT JOIN (SELECT COUNT(*) total_jot ,pw_isoinfo.WorkAreaId ,
SUM( case when pw_isoinfo.[Is_Standard] = 0 then JOT_Size else JOT_Size end) AS total_din
,SUM(JOT_DoneDin) AS finished_total_din
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId ='" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId) AS total_jot ON total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS finished_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as has_total_jot on has_total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS week_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as week_total_jot on week_total_jot.WorkAreaId = WorkArea.WorkAreaId
left join(
select WorkAreaId, sum(WelderNum)as WelderNum from(
select WorkAreaId,[day],[month], COUNT(distinct JOT_CellWelder) as WelderNum from(SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_CellWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
union
SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_FloorWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
) as a group by WorkAreaId,[day],[month]) as b group by b.WorkAreaId) as week_welder_num on week_welder_num.WorkAreaId = WorkArea.WorkAreaId
WHERE WorkArea.ProjectId = '" + this . CurrUser . LoginProjectId + "' and WorkArea.UnitId ='" + this . drpUnit . SelectedValue + @"'
" ;
SqlParameter [ ] parameter1 = new SqlParameter [ ] { } ;
DataTable tb1 = SQLHelper . GetDataTableRunText ( strSql1 , parameter1 ) ;
if ( tb1 ! = null )
{
var newRow = tb1 . NewRow ( ) ;
newRow [ "WorkAreaName" ] = "合计" ;
newRow [ "WorkAreaCode" ] = "" ;
newRow [ "WorkAreaId" ] = "total" ;
decimal total_din = 0 ;
decimal finished_total_din_bq = 0 ;
decimal week_total_din_bq = 0 ;
int WelderNum = 0 ;
for ( int i = 0 ; i < tb1 . Rows . Count ; i + + )
{
try
{
total_din + = decimal . Parse ( tb1 . Rows [ i ] [ "total_din" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
finished_total_din_bq + = decimal . Parse ( tb1 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
week_total_din_bq + = decimal . Parse ( tb1 . Rows [ i ] [ "week_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
WelderNum + = int . Parse ( tb1 . Rows [ i ] [ "WelderNum" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb1 . Rows [ i ] [ "res_din" ] = decimal . Parse ( tb1 . Rows [ i ] [ "total_din" ] . ToString ( ) ) - decimal . Parse ( tb1 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb1 . Rows [ i ] [ "has_per" ] = ( 100 * decimal . Parse ( tb1 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) / decimal . Parse ( tb1 . Rows [ i ] [ "total_din" ] . ToString ( ) ) ) . ToString ( "##.##" ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
}
newRow [ "total_din" ] = total_din ;
newRow [ "finished_total_din_bq" ] = finished_total_din_bq ;
newRow [ "week_total_din_bq" ] = week_total_din_bq ;
newRow [ "WelderNum" ] = WelderNum ;
try
{
newRow [ "res_din" ] = decimal . Parse ( newRow [ "total_din" ] . ToString ( ) ) - decimal . Parse ( newRow [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
newRow [ "has_per" ] = ( 100 * decimal . Parse ( newRow [ "finished_total_din_bq" ] . ToString ( ) ) / decimal . Parse ( newRow [ "total_din" ] . ToString ( ) ) ) . ToString ( "##.##" ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
tb1 . Rows . Add ( newRow ) ;
}
this . Grid1 . DataSource = tb1 ;
this . Grid1 . DataBind ( ) ;
string sql2 = @"/*焊工业绩分析*/
SELECT distinct
welder.WED_ID,
welder.ProjectId,
welder.wed_code,-- 焊工代码
welder.wed_name,--焊工名称
welder.Steels,
(CASE WHEN welder.WED_Sex ='2' THEN '女' ELSE '男' END) AS Sex, --性别
ISNULL(nowtotalfilm.nowtotalfilm,0) AS nowtotalfilm, --本期拍片总数
ISNULL(nowtotalfilm.nowpassfilm,0) AS nowpassfilm, --本期拍片合格数
CAST((CASE ISNULL(nowtotalfilm.nowtotalfilm,0) WHEN 0 THEN 0
ELSE 1.0 * isnull(nowtotalfilm.nowpassfilm,0)/(1.0 * nowtotalfilm.nowtotalfilm) END) AS DECIMAL(19,3))
AS nowpassrate , ---本期拍片合格率
ISNULL(totalfilm.totalfilm,0) AS totalfilm, --总片数
ISNULL(totalfilm.passfilm,0) AS passfilm, --合格片数
(ISNULL(totalfilm.totalfilm , 0) - ISNULL(totalfilm.passfilm ,0)) AS notpassfilm, --不合格片数
CAST((CASE ISNULL(totalfilm.totalfilm,0) WHEN 0 THEN 0
ELSE 1.0 * isnull(totalfilm.passfilm,0)/(1.0 * totalfilm.totalfilm) END) AS DECIMAL(19,3))
AS passrate --合格率
FROM BS_Welder AS welder
LEFT JOIN ProjectData_TeamGroup AS teamGroup ON teamGroup.TeamGroupId= welder.TeamGroupId
---本期拍片总数 --本期拍片合格数
LEFT JOIN (SELECT SUM(cht_totalfilm) AS nowtotalfilm
,SUM(cht_passfilm) AS nowpassfilm
,pw_jointinfo.JOT_CellWelder
FROM ch_checkitem
LEFT JOIN pw_jointinfo ON pw_jointinfo.jot_id=ch_checkitem.jot_id
LEFT JOIN CH_Check ON CH_Check.CHT_CheckID=ch_checkitem.CHT_CheckID
WHERE (pw_jointinfo.ProjectId = @projectId OR @projectId IS NULL)
AND ch_checkitem.jot_id is not null
AND pw_jointinfo.dreportid is not null
AND ( CH_Check.CHT_CheckDate>= @date1 or @date1 is null) AND (CH_Check.CHT_CheckDate <= @date2 or @date2 is null)
GROUP BY pw_jointinfo.JOT_CellWelder) AS nowtotalfilm ON nowtotalfilm.JOT_CellWelder = welder.WED_ID
--总片数 --合格片数
LEFT JOIN (SELECT SUM(cht_totalfilm) AS totalfilm
,SUM(cht_passfilm) AS passfilm
,pw_jointinfo.JOT_CellWelder
FROM ch_checkitem
LEFT JOIN pw_jointinfo ON pw_jointinfo.jot_id=ch_checkitem.jot_id
WHERE (pw_jointinfo.ProjectId = @projectId OR @projectId IS NULL)
AND ch_checkitem.jot_id is not null
GROUP BY pw_jointinfo.JOT_CellWelder) AS totalfilm ON totalfilm.JOT_CellWelder = welder.WED_ID
WHERE (welder.ProjectId = @projectId OR @projectId IS NULL)
AND (welder.WED_Unit=@unitcode OR @unitcode IS NULL)
order BY welder.WED_Code
" ;
List < SqlParameter > listStr = new List < SqlParameter >
{
new SqlParameter ( "@projectId" , this . CurrUser . LoginProjectId )
} ;
if ( this . drpUnit . SelectedValue ! = BLL . Const . _Null & & ! string . IsNullOrEmpty ( this . drpUnit . SelectedValue ) )
{
listStr . Add ( new SqlParameter ( "@unitcode" , this . drpUnit . SelectedValue ) ) ;
}
else
{
listStr . Add ( new SqlParameter ( "@unitcode" , null ) ) ;
}
listStr . Add ( new SqlParameter ( "@date1" , this . txtStartDate . Text . Trim ( ) ) ) ;
listStr . Add ( new SqlParameter ( "@date2" , this . txtEndDate . Text . Trim ( ) ) ) ;
SqlParameter [ ] parameter2 = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( sql2 , parameter2 ) ;
DataTable tb3 = tb . Clone ( ) ;
DataTable tb4 = tb . Clone ( ) ;
foreach ( DataRow row in tb . Rows )
{
var welder = WelderService . GetWelderById ( row [ "WED_ID" ] . ToString ( ) ) ;
if ( welder . WED_TYPE = = "管道" )
{
var temprow = tb3 . NewRow ( ) ;
for ( int i = 0 ; i < tb3 . Columns . Count ; i + + )
{
temprow [ i ] = row [ i ] ;
}
tb3 . Rows . Add ( temprow ) ;
}
else if ( welder . WED_TYPE = = "设备" )
{
var temprow = tb4 . NewRow ( ) ;
for ( int i = 0 ; i < tb3 . Columns . Count ; i + + )
{
temprow [ i ] = row [ i ] ;
}
tb4 . Rows . Add ( temprow ) ;
}
}
this . Grid2 . RecordCount = tb3 . Rows . Count ;
//var table3 = this.GetPagedDataTable(Grid2, tb3);
Grid2 . DataSource = tb3 ;
Grid2 . SummaryData = OutputSummaryData ( tb3 ) ;
Grid2 . DataBind ( ) ;
this . Grid3 . RecordCount = tb4 . Rows . Count ;
//var table4 = this.GetPagedDataTable(Grid3, tb4);
Grid3 . DataSource = tb4 ;
Grid3 . SummaryData = OutputSummaryData ( tb4 ) ;
Grid3 . DataBind ( ) ;
string strSql4 = @"SELECT WorkArea.ProjectId
,Unit.UnitCode AS bsu_unitcode--单位代码
,Unit.UnitName AS bsu_unitname--单位名称
,Installation.InstallationCode AS devicecode--装置代号
,Installation.InstallationName AS devicename--装置名称
,WorkArea.WorkAreaCode AS baw_areano--工区代号
,WorkArea.WorkAreaName AS baw_areaname--工区代号
,ISNULL(current_total_film.current_total_film, 0) AS current_total_film --本期总拍片数
,ISNULL(current_total_film.current_pass_film, 0) AS current_pass_film --本期合格片数
,CAST((CASE ISNULL(current_total_film.current_total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_total_film.current_pass_film, 0) / (1.0 * current_total_film.current_total_film)
END) AS DECIMAL(19,3)) AS current_passreate --本期合格率
,ISNULL(current_check_count_total.total_film, 0) AS total_film --总拍片数
,ISNULL(current_check_count_total.pass_film, 0) AS pass_film --合格片数
,CAST((CASE ISNULL(current_check_count_total.total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_check_count_total.pass_film, 0) / (1.0 * current_check_count_total.total_film)
END) AS DECIMAL(19,3)) AS passreate --合格率
FROM(select WorkAreaCode, WorkAreaName,WorkAreaId, UnitId, InstallationId, ProjectId, SupervisorUnitId
from ProjectData_WorkArea ) AS WorkArea
LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId = Unit.UnitId
LEFT JOIN Project_Installation AS Installation ON Installation.InstallationId = WorkArea.InstallationId
--本期总拍片数
LEFT JOIN(SELECT SUM(cht_totalfilm) AS current_total_film
, SUM(cht_passfilm) AS current_pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
AND(cht_checkdate >= @date1 OR @date1 IS NULL) and(cht_checkdate <= @date2 OR @date2 IS NULL)) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_total_film ON current_total_film.WorkAreaId = WorkArea.WorkAreaId
--本期总检测数
LEFT JOIN(SELECT COUNT(*) AS current_check_count_total
, SUM(cht_totalfilm) AS total_film
, SUM(cht_passfilm) AS pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_check_count_total ON current_check_count_total.WorkAreaId = WorkArea.WorkAreaId
WHERE(WorkArea.ProjectId = @projectId) AND
(WorkArea.UnitId = @unitno OR @UnitNo IS NULL)
ORDER BY Unit.UnitCode ,Installation.InstallationCode" ;
List < SqlParameter > listpar4 = new List < SqlParameter >
{
new SqlParameter ( "@projectId" , this . CurrUser . LoginProjectId )
} ;
if ( this . drpUnit . SelectedValue ! = BLL . Const . _Null & & ! string . IsNullOrEmpty ( this . drpUnit . SelectedValue ) )
{
listpar4 . Add ( new SqlParameter ( "@unitNo" , this . drpUnit . SelectedValue ) ) ;
}
else
{
listpar4 . Add ( new SqlParameter ( "@unitNo" , null ) ) ;
} ;
listpar4 . Add ( new SqlParameter ( "@date1" , this . txtStartDate . Text . Trim ( ) ) ) ;
listpar4 . Add ( new SqlParameter ( "@date2" , this . txtEndDate . Text . Trim ( ) ) ) ;
listpar4 . Add ( new SqlParameter ( "@WED_TYPE" , "管道" ) ) ;
SqlParameter [ ] parameter4 = listpar4 . ToArray ( ) ;
DataTable dt4 = SQLHelper . GetDataTableRunText ( strSql4 , parameter4 ) ;
Grid4 . DataSource = dt4 ;
Grid4 . SummaryData = OutputSummaryData2 ( dt4 ) ;
Grid4 . DataBind ( ) ;
string strSql5 = @"SELECT WorkArea.ProjectId
,Unit.UnitCode AS bsu_unitcode--单位代码
,Unit.UnitName AS bsu_unitname--单位名称
,Installation.InstallationCode AS devicecode--装置代号
,Installation.InstallationName AS devicename--装置名称
,WorkArea.WorkAreaCode AS baw_areano--工区代号
,WorkArea.WorkAreaName AS baw_areaname--工区代号
,ISNULL(current_total_film.current_total_film, 0) AS current_total_film --本期总拍片数
,ISNULL(current_total_film.current_pass_film, 0) AS current_pass_film --本期合格片数
,CAST((CASE ISNULL(current_total_film.current_total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_total_film.current_pass_film, 0) / (1.0 * current_total_film.current_total_film)
END) AS DECIMAL(19,3)) AS current_passreate --本期合格率
,ISNULL(current_check_count_total.total_film, 0) AS total_film --总拍片数
,ISNULL(current_check_count_total.pass_film, 0) AS pass_film --合格片数
,CAST((CASE ISNULL(current_check_count_total.total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_check_count_total.pass_film, 0) / (1.0 * current_check_count_total.total_film)
END) AS DECIMAL(19,3)) AS passreate --合格率
FROM(select WorkAreaCode, WorkAreaName,WorkAreaId, UnitId, InstallationId, ProjectId, SupervisorUnitId
from ProjectData_WorkArea ) AS WorkArea
LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId = Unit.UnitId
LEFT JOIN Project_Installation AS Installation ON Installation.InstallationId = WorkArea.InstallationId
--本期总拍片数
LEFT JOIN(SELECT SUM(cht_totalfilm) AS current_total_film
, SUM(cht_passfilm) AS current_pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
AND(cht_checkdate >= @date1 OR @date1 IS NULL) and(cht_checkdate <= @date2 OR @date2 IS NULL)) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_total_film ON current_total_film.WorkAreaId = WorkArea.WorkAreaId
--本期总检测数
LEFT JOIN(SELECT COUNT(*) AS current_check_count_total
, SUM(cht_totalfilm) AS total_film
, SUM(cht_passfilm) AS pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_check_count_total ON current_check_count_total.WorkAreaId = WorkArea.WorkAreaId
WHERE(WorkArea.ProjectId = @projectId) AND
(WorkArea.UnitId = @unitno OR @UnitNo IS NULL)
ORDER BY Unit.UnitCode ,Installation.InstallationCode" ;
List < SqlParameter > listpar5 = new List < SqlParameter >
{
new SqlParameter ( "@projectId" , this . CurrUser . LoginProjectId )
} ;
if ( this . drpUnit . SelectedValue ! = BLL . Const . _Null & & ! string . IsNullOrEmpty ( this . drpUnit . SelectedValue ) )
{
listpar5 . Add ( new SqlParameter ( "@unitNo" , this . drpUnit . SelectedValue ) ) ;
}
else
{
listpar5 . Add ( new SqlParameter ( "@unitNo" , null ) ) ;
} ;
listpar5 . Add ( new SqlParameter ( "@date1" , this . txtStartDate . Text . Trim ( ) ) ) ;
listpar5 . Add ( new SqlParameter ( "@date2" , this . txtEndDate . Text . Trim ( ) ) ) ;
listpar5 . Add ( new SqlParameter ( "@WED_TYPE" , "设备" ) ) ;
SqlParameter [ ] parameter5 = listpar5 . ToArray ( ) ;
DataTable dt5 = SQLHelper . GetDataTableRunText ( strSql5 , parameter5 ) ;
Grid5 . DataSource = dt5 ;
Grid5 . SummaryData = OutputSummaryData2 ( dt5 ) ;
Grid5 . DataBind ( ) ;
}
#endregion
#region 计 算 合 计
/// <summary>
/// 计算合计
/// </summary>
protected JObject OutputSummaryData ( DataTable tb )
{
if ( tb ! = null )
{
int nowtotalfilm = 0 ; //本期拍片总数
int nowpassfilm = 0 ; //本期拍片合格数
string nowpassrate = "" ;
int totalfilm = 0 ; //总片数
int passfilm = 0 ; //合格片数
string passrate = "" ;
foreach ( DataRow row in tb . Rows )
{
nowtotalfilm + = Funs . GetNewIntOrZero ( row [ "nowtotalfilm" ] . ToString ( ) ) ;
nowpassfilm + = Funs . GetNewIntOrZero ( row [ "nowpassfilm" ] . ToString ( ) ) ;
totalfilm + = Funs . GetNewIntOrZero ( row [ "totalfilm" ] . ToString ( ) ) ;
passfilm + = Funs . GetNewIntOrZero ( row [ "passfilm" ] . ToString ( ) ) ;
}
if ( totalfilm > 0 )
passrate = ( 100.0 * passfilm / totalfilm ) . ToString ( "#.#" ) + "%" ;
if ( nowtotalfilm > 0 )
nowpassrate = ( 100.0 * nowpassfilm / nowtotalfilm ) . ToString ( "#.#" ) + "%" ;
JObject summary = new JObject
{
{ "wed_name" , "合计" } ,
{ "nowtotalfilm" , nowtotalfilm } ,
{ "nowpassfilm" , nowpassfilm } ,
{ "nowpassrate" , nowpassrate } ,
{ "totalfilm" , totalfilm } ,
{ "passfilm" , passfilm } ,
{ "passrate" , passrate }
} ;
return summary ;
}
return null ;
}
protected JObject OutputSummaryData2 ( DataTable tb )
{
if ( tb ! = null )
{
int current_count_film = 0 ; //本期拍片焊口数
int current_pass_film = 0 ; //本期拍片焊口合格数
int totalfilm = 0 ; //总片数
int passfilm = 0 ; //合格片数
string passrate = "0.0%" ;
string current_passrate = "0.0%" ;
foreach ( DataRow row in tb . Rows )
{
current_count_film + = Funs . GetNewIntOrZero ( row [ "current_total_film" ] . ToString ( ) ) ;
current_pass_film + = Funs . GetNewIntOrZero ( row [ "current_pass_film" ] . ToString ( ) ) ;
totalfilm + = Funs . GetNewIntOrZero ( row [ "total_film" ] . ToString ( ) ) ;
passfilm + = Funs . GetNewIntOrZero ( row [ "pass_film" ] . ToString ( ) ) ;
}
if ( current_count_film > 0 )
current_passrate = ( 100.0 * current_pass_film / current_count_film ) . ToString ( "#.#" ) + "%" ;
if ( totalfilm > 0 )
passrate = ( 100.0 * passfilm / totalfilm ) . ToString ( "#.#" ) + "%" ;
JObject summary = new JObject
{
{ "baw_areaname" , "合计" } ,
{ "current_total_film" , current_count_film } ,
{ "current_pass_film" , current_pass_film } ,
{ "total_film" , totalfilm } ,
{ "pass_film" , passfilm } ,
{ "passreate" , passrate } ,
{ "current_passreate" , current_passrate }
} ;
return summary ;
}
return null ;
}
#endregion
#region 查 询
/// <summary>
/// 查询
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSearch_Click ( object sender , EventArgs e )
{
string projectName = BLL . ProjectService . GetProjectByProjectId ( this . CurrUser . LoginProjectId ) . ProjectName ;
if ( string . IsNullOrEmpty ( this . txtStartDate . Text ) | | string . IsNullOrEmpty ( this . txtEndDate . Text ) )
{
Alert . ShowInTop ( "日期不能为空!" , MessageBoxIcon . Warning ) ;
return ;
}
if ( drpUnit . SelectedValue = = BLL . Const . _Null )
{
Alert . ShowInTop ( "单位不能为空!" , MessageBoxIcon . Warning ) ;
return ;
}
this . LabelUnit3 . Text = "施工单位:" + drpUnit . SelectedText ;
var unit1 = ProjectUnitService . GetProjectUnitListByProjectIdUnitType ( this . CurrUser . LoginProjectId , Const . ProjectUnitType_1 ) ;
if ( unit1 ! = null & & unit1 . Count > 0 )
{
string unitids1 = "" ;
foreach ( var u in unit1 )
{
unitids1 + = u . UnitId + "," ;
}
this . LabelUnit1 . Text = "总包单位:" + UnitService . getUnitNamesUnitIds ( unitids1 . TrimEnd ( ',' ) ) ;
}
var unit3 = ProjectUnitService . GetProjectUnitListByProjectIdUnitType ( this . CurrUser . LoginProjectId , Const . ProjectUnitType_3 ) ;
if ( unit3 ! = null & & unit1 . Count > 0 )
{
string unitids1 = "" ;
foreach ( var u in unit3 )
{
unitids1 + = u . UnitId + "," ;
}
this . LabelUnit2 . Text = "监理单位:" + UnitService . getUnitNamesUnitIds ( unitids1 . TrimEnd ( ',' ) ) ;
}
BindGrid ( ) ;
}
#endregion
#region 保 存
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( this . txtStartDate . Text ) & & ! string . IsNullOrEmpty ( this . txtEndDate . Text ) )
{
Model . NDTReport ndtReport = new Model . NDTReport ( ) ;
ndtReport . NDTReportId = this . NDTReportId ;
ndtReport . ProjectId = this . CurrUser . LoginProjectId ;
ndtReport . StartDate = Funs . GetNewDateTime ( this . txtStartDate . Text . Trim ( ) ) ;
ndtReport . EndDate = Funs . GetNewDateTime ( this . txtEndDate . Text . Trim ( ) ) ;
ndtReport . RType = "1" ;
BLL . NDTReportService . AddNDTReort ( ndtReport ) ;
ShowNotify ( "保存成功!" , MessageBoxIcon . Success ) ;
BindGrid ( ) ;
this . txtStartDate . Text = string . Empty ;
this . txtEndDate . Text = string . Empty ;
}
else
{
Alert . ShowInTop ( "日期不能为空!" , MessageBoxIcon . Warning ) ;
return ;
}
}
#endregion
/// <summary>
/// 导出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click ( object sender , EventArgs e )
{
Dictionary < string , string > keyValuePairs = new Dictionary < string , string > ( ) ;
keyValuePairs . Add ( "ConUnit" , drpUnit . SelectedText ) ;
var unit1 = ProjectUnitService . GetProjectUnitListByProjectIdUnitType ( this . CurrUser . LoginProjectId , Const . ProjectUnitType_1 ) ;
if ( unit1 ! = null & & unit1 . Count > 0 )
{
string unitids1 = "" ;
foreach ( var u in unit1 )
{
unitids1 + = u . UnitId + "," ;
}
keyValuePairs . Add ( "totalUnit" , UnitService . getUnitNamesUnitIds ( unitids1 . TrimEnd ( ',' ) ) ) ;
}
var unit3 = ProjectUnitService . GetProjectUnitListByProjectIdUnitType ( this . CurrUser . LoginProjectId , Const . ProjectUnitType_3 ) ;
if ( unit3 ! = null & & unit1 . Count > 0 )
{
string unitids1 = "" ;
foreach ( var u in unit3 )
{
unitids1 + = u . UnitId + "," ;
}
keyValuePairs . Add ( "supUnit" , UnitService . getUnitNamesUnitIds ( unitids1 . TrimEnd ( ',' ) ) ) ;
}
BLL . Common . FastReportService . ResetData ( ) ;
BLL . Common . FastReportService . AddFastreportParameter ( keyValuePairs ) ;
string strSql1 = @"SELECT 0 id,'' StaDate, WorkArea.WorkAreaId, WorkArea.WorkAreaCode ,--工区代号
WorkArea.WorkAreaName ,--工区代号
CAST(ISNULL(total_jot.total_din,0) AS DECIMAL(19,2)) AS total_din ,--总达因
finished_total_din_bq,week_total_din_bq,0 res_din, '' has_per ,WelderNum
FROM ProjectData_WorkArea AS WorkArea
LEFT JOIN (SELECT COUNT(*) total_jot ,pw_isoinfo.WorkAreaId ,
SUM( case when pw_isoinfo.[Is_Standard] = 0 then JOT_Size else JOT_Size end) AS total_din
,SUM(JOT_DoneDin) AS finished_total_din
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId ='" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId) AS total_jot ON total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS finished_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as has_total_jot on has_total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS week_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as week_total_jot on week_total_jot.WorkAreaId = WorkArea.WorkAreaId
left join(
select WorkAreaId, sum(WelderNum)as WelderNum from(
select WorkAreaId,[day],[month], COUNT(distinct JOT_CellWelder) as WelderNum from(SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_CellWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
union
SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_FloorWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 0 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
) as a group by WorkAreaId,[day],[month]) as b group by b.WorkAreaId) as week_welder_num on week_welder_num.WorkAreaId = WorkArea.WorkAreaId
WHERE WorkArea.ProjectId = '" + this . CurrUser . LoginProjectId + "' and WorkArea.UnitId ='" + this . drpUnit . SelectedValue + @"'
" ;
SqlParameter [ ] parameter1 = new SqlParameter [ ] { } ;
DataTable tb1 = SQLHelper . GetDataTableRunText ( strSql1 , parameter1 ) ;
if ( tb1 ! = null )
{
int WelderNum = 0 ;
for ( int i = 0 ; i < tb1 . Rows . Count ; i + + )
{
try
{
if ( string . IsNullOrEmpty ( tb1 . Rows [ i ] [ "WelderNum" ] . ToString ( ) ) )
{
tb1 . Rows [ i ] [ "WelderNum" ] = 0 ;
}
if ( string . IsNullOrEmpty ( tb1 . Rows [ i ] [ "week_total_din_bq" ] . ToString ( ) ) )
{
tb1 . Rows [ i ] [ "week_total_din_bq" ] = 0 ;
}
if ( string . IsNullOrEmpty ( tb1 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) )
{
tb1 . Rows [ i ] [ "finished_total_din_bq" ] = 0 ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
WelderNum + = int . Parse ( tb1 . Rows [ i ] [ "WelderNum" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb1 . Rows [ i ] [ "res_din" ] = decimal . Parse ( tb1 . Rows [ i ] [ "total_din" ] . ToString ( ) ) - decimal . Parse ( tb1 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb1 . Rows [ i ] [ "has_per" ] = ( 100 * decimal . Parse ( tb1 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) / decimal . Parse ( tb1 . Rows [ i ] [ "total_din" ] . ToString ( ) ) ) . ToString ( "##.##" ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
}
}
tb1 . TableName = "Table0" ;
BLL . Common . FastReportService . AddFastreportTable ( tb1 ) ;
string strSql = @"SELECT 0 id,'' StaDate, WorkArea.WorkAreaId, WorkArea.WorkAreaCode ,--工区代号
WorkArea.WorkAreaName ,--工区代号
CAST(ISNULL(total_jot.total_din,0) AS DECIMAL(19,2)) AS total_din ,--总达因
finished_total_din_bq,week_total_din_bq,0 res_din, '' has_per ,WelderNum
FROM ProjectData_WorkArea AS WorkArea
LEFT JOIN (SELECT COUNT(*) total_jot ,pw_isoinfo.WorkAreaId ,
SUM( case when pw_isoinfo.[Is_Standard] = 0 then JOT_Size else JOT_Size end) AS total_din
,SUM(JOT_DoneDin) AS finished_total_din
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId ='" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId) AS total_jot ON total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS finished_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as has_total_jot on has_total_jot.WorkAreaId = WorkArea.WorkAreaId
LEFT JOIN(
SELECT
pw_isoinfo.WorkAreaId , SUM(
case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else [JOT_DoneDin] end
) AS week_total_din_bq
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
GROUP BY pw_isoinfo.WorkAreaId ) as week_total_jot on week_total_jot.WorkAreaId = WorkArea.WorkAreaId
left join(
select WorkAreaId, sum(WelderNum)as WelderNum from(
select WorkAreaId,[day],[month], COUNT(distinct JOT_CellWelder) as WelderNum from(SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_CellWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
union
SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
pw_isoinfo.WorkAreaId, JOT_FloorWelder
FROM pw_jointinfo
LEFT JOIN pw_isoinfo ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
LEFT JOIN Base_Material ON Base_Material.MaterialId = pw_jointinfo.MaterialId
LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
WHERE pw_isoinfo.[Is_Standard] = 1 and pw_isoinfo.ProjectId = '" + this . CurrUser . LoginProjectId + "' and pw_isoinfo.UnitId = '" + this . drpUnit . SelectedValue + @"' and jot_welddate >='" + txtStartDate . SelectedDate . Value . ToString ( "yyyy-MM-dd" ) + "' and jot_welddate <'" + txtEndDate . SelectedDate . Value . AddMonths ( 1 ) . ToString ( "yyyy-MM-dd" ) + @"'
) as a group by WorkAreaId,[day],[month]) as b group by b.WorkAreaId) as week_welder_num on week_welder_num.WorkAreaId = WorkArea.WorkAreaId
WHERE WorkArea.ProjectId = '" + this . CurrUser . LoginProjectId + "' and WorkArea.UnitId ='" + this . drpUnit . SelectedValue + @"'
" ;
SqlParameter [ ] parameter = new SqlParameter [ ] { } ;
DataTable tb2 = SQLHelper . GetDataTableRunText ( strSql , parameter ) ;
if ( tb2 ! = null )
{
int WelderNum = 0 ;
for ( int i = 0 ; i < tb2 . Rows . Count ; i + + )
{
try
{
if ( string . IsNullOrEmpty ( tb2 . Rows [ i ] [ "WelderNum" ] . ToString ( ) ) )
{
tb2 . Rows [ i ] [ "WelderNum" ] = 0 ;
}
if ( string . IsNullOrEmpty ( tb2 . Rows [ i ] [ "week_total_din_bq" ] . ToString ( ) ) )
{
tb2 . Rows [ i ] [ "week_total_din_bq" ] = 0 ;
}
if ( string . IsNullOrEmpty ( tb2 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) )
{
tb2 . Rows [ i ] [ "finished_total_din_bq" ] = 0 ;
}
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
WelderNum + = int . Parse ( tb2 . Rows [ i ] [ "WelderNum" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb2 . Rows [ i ] [ "res_din" ] = decimal . Parse ( tb2 . Rows [ i ] [ "total_din" ] . ToString ( ) ) - decimal . Parse ( tb2 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
try
{
tb2 . Rows [ i ] [ "has_per" ] = ( 100 * decimal . Parse ( tb2 . Rows [ i ] [ "finished_total_din_bq" ] . ToString ( ) ) / decimal . Parse ( tb2 . Rows [ i ] [ "total_din" ] . ToString ( ) ) ) . ToString ( "##.##" ) ;
}
2026-08-24 11:07:59 +08:00
catch ( Exception ) { }
2025-02-12 09:27:47 +08:00
}
}
tb2 . TableName = "Table1" ;
BLL . Common . FastReportService . AddFastreportTable ( tb2 ) ;
string sql2 = @"/*焊工业绩分析*/
SELECT distinct
welder.WED_ID,
welder.ProjectId,
welder.wed_code,-- 焊工代码
welder.wed_name,--焊工名称
welder.Steels,
(CASE WHEN welder.WED_Sex ='2' THEN '女' ELSE '男' END) AS Sex, --性别
ISNULL(nowtotalfilm.nowtotalfilm,0) AS nowtotalfilm, --本期拍片总数
ISNULL(nowtotalfilm.nowpassfilm,0) AS nowpassfilm, --本期拍片合格数
CAST((CASE ISNULL(nowtotalfilm.nowtotalfilm,0) WHEN 0 THEN 0
ELSE 1.0 * isnull(nowtotalfilm.nowpassfilm,0)/(1.0 * nowtotalfilm.nowtotalfilm) END) AS DECIMAL(19,3))
AS nowpassrate , ---本期拍片合格率
ISNULL(totalfilm.totalfilm,0) AS totalfilm, --总片数
ISNULL(totalfilm.passfilm,0) AS passfilm, --合格片数
(ISNULL(totalfilm.totalfilm , 0) - ISNULL(totalfilm.passfilm ,0)) AS notpassfilm, --不合格片数
CAST((CASE ISNULL(totalfilm.totalfilm,0) WHEN 0 THEN 0
ELSE 1.0 * isnull(totalfilm.passfilm,0)/(1.0 * totalfilm.totalfilm) END) AS DECIMAL(19,3))
AS passrate --合格率
FROM BS_Welder AS welder
LEFT JOIN ProjectData_TeamGroup AS teamGroup ON teamGroup.TeamGroupId= welder.TeamGroupId
---本期拍片总数 --本期拍片合格数
LEFT JOIN (SELECT SUM(cht_totalfilm) AS nowtotalfilm
,SUM(cht_passfilm) AS nowpassfilm
,pw_jointinfo.JOT_CellWelder
FROM ch_checkitem
LEFT JOIN pw_jointinfo ON pw_jointinfo.jot_id=ch_checkitem.jot_id
LEFT JOIN CH_Check ON CH_Check.CHT_CheckID=ch_checkitem.CHT_CheckID
WHERE (pw_jointinfo.ProjectId = @projectId OR @projectId IS NULL)
AND ch_checkitem.jot_id is not null
AND pw_jointinfo.dreportid is not null
AND ( CH_Check.CHT_CheckDate>= @date1 or @date1 is null) AND (CH_Check.CHT_CheckDate <= @date2 or @date2 is null)
GROUP BY pw_jointinfo.JOT_CellWelder) AS nowtotalfilm ON nowtotalfilm.JOT_CellWelder = welder.WED_ID
--总片数 --合格片数
LEFT JOIN (SELECT SUM(cht_totalfilm) AS totalfilm
,SUM(cht_passfilm) AS passfilm
,pw_jointinfo.JOT_CellWelder
FROM ch_checkitem
LEFT JOIN pw_jointinfo ON pw_jointinfo.jot_id=ch_checkitem.jot_id
WHERE (pw_jointinfo.ProjectId = @projectId OR @projectId IS NULL)
AND ch_checkitem.jot_id is not null
GROUP BY pw_jointinfo.JOT_CellWelder) AS totalfilm ON totalfilm.JOT_CellWelder = welder.WED_ID
WHERE (welder.ProjectId = @projectId OR @projectId IS NULL)
AND (welder.WED_Unit=@unitcode OR @unitcode IS NULL)
order BY welder.WED_Code
" ;
List < SqlParameter > listStr = new List < SqlParameter >
{
new SqlParameter ( "@projectId" , this . CurrUser . LoginProjectId )
} ;
if ( this . drpUnit . SelectedValue ! = BLL . Const . _Null & & ! string . IsNullOrEmpty ( this . drpUnit . SelectedValue ) )
{
listStr . Add ( new SqlParameter ( "@unitcode" , this . drpUnit . SelectedValue ) ) ;
}
else
{
listStr . Add ( new SqlParameter ( "@unitcode" , null ) ) ;
}
listStr . Add ( new SqlParameter ( "@date1" , this . txtStartDate . Text . Trim ( ) ) ) ;
listStr . Add ( new SqlParameter ( "@date2" , this . txtEndDate . Text . Trim ( ) ) ) ;
SqlParameter [ ] parameter2 = listStr . ToArray ( ) ;
DataTable tb = SQLHelper . GetDataTableRunText ( sql2 , parameter2 ) ;
DataTable tb3 = tb . Clone ( ) ;
DataTable tb4 = tb . Clone ( ) ;
foreach ( DataRow row in tb . Rows )
{
var welder = WelderService . GetWelderById ( row [ "WED_ID" ] . ToString ( ) ) ;
if ( welder . WED_TYPE = = "管道" )
{
var temprow = tb3 . NewRow ( ) ;
for ( int i = 0 ; i < tb3 . Columns . Count ; i + + )
{
temprow [ i ] = row [ i ] ;
}
tb3 . Rows . Add ( temprow ) ;
}
else if ( welder . WED_TYPE = = "设备" )
{
var temprow = tb4 . NewRow ( ) ;
for ( int i = 0 ; i < tb3 . Columns . Count ; i + + )
{
temprow [ i ] = row [ i ] ;
}
tb4 . Rows . Add ( temprow ) ;
}
}
tb3 . TableName = "Table4" ;
tb4 . TableName = "Table5" ;
BLL . Common . FastReportService . AddFastreportTable ( tb3 ) ;
BLL . Common . FastReportService . AddFastreportTable ( tb4 ) ;
string strSql4 = @"SELECT WorkArea.ProjectId
,Unit.UnitCode AS bsu_unitcode--单位代码
,Unit.UnitName AS bsu_unitname--单位名称
,Installation.InstallationCode AS devicecode--装置代号
,Installation.InstallationName AS devicename--装置名称
,WorkArea.WorkAreaCode AS baw_areano--工区代号
,WorkArea.WorkAreaName AS baw_areaname--工区代号
,ISNULL(current_total_film.current_total_film, 0) AS current_total_film --本期总拍片数
,ISNULL(current_total_film.current_pass_film, 0) AS current_pass_film --本期合格片数
,CAST((CASE ISNULL(current_total_film.current_total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_total_film.current_pass_film, 0) / (1.0 * current_total_film.current_total_film)
END) AS DECIMAL(19,3)) AS current_passreate --本期合格率
,ISNULL(current_check_count_total.total_film, 0) AS total_film --总拍片数
,ISNULL(current_check_count_total.pass_film, 0) AS pass_film --合格片数
,CAST((CASE ISNULL(current_check_count_total.total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_check_count_total.pass_film, 0) / (1.0 * current_check_count_total.total_film)
END) AS DECIMAL(19,3)) AS passreate --合格率
FROM(select WorkAreaCode, WorkAreaName,WorkAreaId, UnitId, InstallationId, ProjectId, SupervisorUnitId
from ProjectData_WorkArea ) AS WorkArea
LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId = Unit.UnitId
LEFT JOIN Project_Installation AS Installation ON Installation.InstallationId = WorkArea.InstallationId
--本期总拍片数
LEFT JOIN(SELECT SUM(cht_totalfilm) AS current_total_film
, SUM(cht_passfilm) AS current_pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
AND(cht_checkdate >= @date1 OR @date1 IS NULL) and(cht_checkdate <= @date2 OR @date2 IS NULL)) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_total_film ON current_total_film.WorkAreaId = WorkArea.WorkAreaId
--本期总检测数
LEFT JOIN(SELECT COUNT(*) AS current_check_count_total
, SUM(cht_totalfilm) AS total_film
, SUM(cht_passfilm) AS pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_check_count_total ON current_check_count_total.WorkAreaId = WorkArea.WorkAreaId
WHERE(WorkArea.ProjectId = @projectId) AND
(WorkArea.UnitId = @unitno OR @UnitNo IS NULL)
ORDER BY Unit.UnitCode ,Installation.InstallationCode" ;
List < SqlParameter > listpar4 = new List < SqlParameter >
{
new SqlParameter ( "@projectId" , this . CurrUser . LoginProjectId )
} ;
if ( this . drpUnit . SelectedValue ! = BLL . Const . _Null & & ! string . IsNullOrEmpty ( this . drpUnit . SelectedValue ) )
{
listpar4 . Add ( new SqlParameter ( "@unitNo" , this . drpUnit . SelectedValue ) ) ;
}
else
{
listpar4 . Add ( new SqlParameter ( "@unitNo" , null ) ) ;
} ;
listpar4 . Add ( new SqlParameter ( "@date1" , this . txtStartDate . Text . Trim ( ) ) ) ;
listpar4 . Add ( new SqlParameter ( "@date2" , this . txtEndDate . Text . Trim ( ) ) ) ;
listpar4 . Add ( new SqlParameter ( "@WED_TYPE" , "管道" ) ) ;
SqlParameter [ ] parameter4 = listpar4 . ToArray ( ) ;
DataTable dt4 = SQLHelper . GetDataTableRunText ( strSql4 , parameter4 ) ;
dt4 . TableName = "Table6" ;
BLL . Common . FastReportService . AddFastreportTable ( dt4 ) ;
string strSql5 = @"SELECT WorkArea.ProjectId
,Unit.UnitCode AS bsu_unitcode--单位代码
,Unit.UnitName AS bsu_unitname--单位名称
,Installation.InstallationCode AS devicecode--装置代号
,Installation.InstallationName AS devicename--装置名称
,WorkArea.WorkAreaCode AS baw_areano--工区代号
,WorkArea.WorkAreaName AS baw_areaname--工区代号
,ISNULL(current_total_film.current_total_film, 0) AS current_total_film --本期总拍片数
,ISNULL(current_total_film.current_pass_film, 0) AS current_pass_film --本期合格片数
,CAST((CASE ISNULL(current_total_film.current_total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_total_film.current_pass_film, 0) / (1.0 * current_total_film.current_total_film)
END) AS DECIMAL(19,3)) AS current_passreate --本期合格率
,ISNULL(current_check_count_total.total_film, 0) AS total_film --总拍片数
,ISNULL(current_check_count_total.pass_film, 0) AS pass_film --合格片数
,CAST((CASE ISNULL(current_check_count_total.total_film, 0)
WHEN 0 THEN 0
ELSE 1.0 * ISNULL(current_check_count_total.pass_film, 0) / (1.0 * current_check_count_total.total_film)
END) AS DECIMAL(19,3)) AS passreate --合格率
FROM(select WorkAreaCode, WorkAreaName,WorkAreaId, UnitId, InstallationId, ProjectId, SupervisorUnitId
from ProjectData_WorkArea ) AS WorkArea
LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId = Unit.UnitId
LEFT JOIN Project_Installation AS Installation ON Installation.InstallationId = WorkArea.InstallationId
--本期总拍片数
LEFT JOIN(SELECT SUM(cht_totalfilm) AS current_total_film
, SUM(cht_passfilm) AS current_pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
AND(cht_checkdate >= @date1 OR @date1 IS NULL) and(cht_checkdate <= @date2 OR @date2 IS NULL)) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_total_film ON current_total_film.WorkAreaId = WorkArea.WorkAreaId
--本期总检测数
LEFT JOIN(SELECT COUNT(*) AS current_check_count_total
, SUM(cht_totalfilm) AS total_film
, SUM(cht_passfilm) AS pass_film
, isoinfo.WorkAreaId
FROM(select CHT_CheckID from CH_Check
where ProjectId = @projectId
and(UnitId = @unitNo OR @unitNo IS NULL)
) as Checks
LEFT JOIN CH_CheckItem ON ch_checkitem.CHT_CheckID = Checks.CHT_CheckID
LEFT JOIN PW_JointInfo as JointInfo ON JointInfo.JOT_ID = ch_checkitem.JOT_ID
LEFT JOIN(select iso_id, WorkAreaId from pw_isoinfo
where ProjectId = @projectId ) as isoinfo ON jointinfo.ISO_ID = isoinfo.ISO_ID
where exists(select 1 from BS_Welder where JointInfo.JOT_CellWelder = BS_Welder.WED_ID and BS_Welder.WED_TYPE = @WED_TYPE)
GROUP BY isoinfo.WorkAreaId) AS current_check_count_total ON current_check_count_total.WorkAreaId = WorkArea.WorkAreaId
WHERE(WorkArea.ProjectId = @projectId) AND
(WorkArea.UnitId = @unitno OR @UnitNo IS NULL)
ORDER BY Unit.UnitCode ,Installation.InstallationCode" ;
List < SqlParameter > listpar5 = new List < SqlParameter >
{
new SqlParameter ( "@projectId" , this . CurrUser . LoginProjectId )
} ;
if ( this . drpUnit . SelectedValue ! = BLL . Const . _Null & & ! string . IsNullOrEmpty ( this . drpUnit . SelectedValue ) )
{
listpar5 . Add ( new SqlParameter ( "@unitNo" , this . drpUnit . SelectedValue ) ) ;
}
else
{
listpar5 . Add ( new SqlParameter ( "@unitNo" , null ) ) ;
} ;
listpar5 . Add ( new SqlParameter ( "@date1" , this . txtStartDate . Text . Trim ( ) ) ) ;
listpar5 . Add ( new SqlParameter ( "@date2" , this . txtEndDate . Text . Trim ( ) ) ) ;
listpar5 . Add ( new SqlParameter ( "@WED_TYPE" , "设备" ) ) ;
SqlParameter [ ] parameter5 = listpar5 . ToArray ( ) ;
DataTable dt5 = SQLHelper . GetDataTableRunText ( strSql5 , parameter5 ) ;
dt5 . TableName = "Table3" ;
BLL . Common . FastReportService . AddFastreportTable ( dt5 ) ;
// Session["Table"] = dt;
// Session["CH_TrustID"] = reportId;
string initTemplatePath = "" ;
string rootPath = Server . MapPath ( "~/" ) ;
initTemplatePath = "File\\Fastreport\\焊接周报.frx" ;
if ( File . Exists ( rootPath + initTemplatePath ) )
{
PageContext . RegisterStartupScript ( Window2 . GetShowReference ( String . Format ( "../TrustManage/Fastreport.aspx?ReportPath={0}" , rootPath + initTemplatePath ) ) ) ;
}
// string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
// //模板文件
// string TempletFileName = Server.MapPath("~/") + "File/Excel/HJGL_DataOut/焊接周报.xlsx";
// //导出文件
// string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
// if (!Directory.Exists(filePath))
// {
// Directory.CreateDirectory(filePath);
// }
// string ReportFileName = filePath + "out.xlsx";
// FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
// XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
// ICellStyle styleCenter = hssfworkbook.CreateCellStyle();
// styleCenter.VerticalAlignment = VerticalAlignment.Center;
// styleCenter.Alignment = HorizontalAlignment.Center;
// styleCenter.BorderLeft = BorderStyle.Thin;
// styleCenter.BorderTop = BorderStyle.Thin;
// styleCenter.BorderRight = BorderStyle.Thin;
// styleCenter.BorderBottom = BorderStyle.Thin;
// styleCenter.WrapText = true;
// IFont font = styleCenter.GetFont(hssfworkbook);
// //font.Color = 10;//颜色
// font.FontHeightInPoints = 10;//字体高度(与excel中的字号一致)
// styleCenter.SetFont(font);
// XSSFSheet recordSheet = (XSSFSheet)hssfworkbook.GetSheet("焊接周报");
// // recordSheet.AddMergedRegion(new CellRangeAddress(0, 0, 8, 9));
// if (string.IsNullOrEmpty(this.txtStartDate.Text) || string.IsNullOrEmpty(this.txtEndDate.Text))
// {
// Alert.ShowInTop("日期不能为空!", MessageBoxIcon.Warning);
// return;
// }
// if (drpUnit.SelectedValue == BLL.Const._Null)
// {
// Alert.ShowInTop("单位不能为空!", MessageBoxIcon.Warning);
// return;
// }
// recordSheet.GetRow(1).CreateCell(2).SetCellValue(drpUnit.SelectedText);
// recordSheet.GetRow(1).GetCell(2).CellStyle = styleCenter;
// var unit1 = ProjectUnitService.GetProjectUnitListByProjectIdUnitType(this.CurrUser.LoginProjectId, Const.ProjectUnitType_1);
// if (unit1 != null && unit1.Count > 0)
// {
// string unitids1 = "";
// foreach (var u in unit1)
// {
// unitids1 += u.UnitId + ",";
// }
// recordSheet.GetRow(2).CreateCell(2).SetCellValue(UnitService.getUnitNamesUnitIds(unitids1.TrimEnd(',')));
// recordSheet.GetRow(2).GetCell(2).CellStyle = styleCenter;
// }
// var unit3 = ProjectUnitService.GetProjectUnitListByProjectIdUnitType(this.CurrUser.LoginProjectId, Const.ProjectUnitType_3);
// if (unit3 != null && unit1.Count > 0)
// {
// string unitids1 = "";
// foreach (var u in unit3)
// {
// unitids1 += u.UnitId + ",";
// }
// recordSheet.GetRow(3).CreateCell(2).SetCellValue(UnitService.getUnitNamesUnitIds(unitids1.TrimEnd(',')));
// recordSheet.GetRow(3).GetCell(2).CellStyle = styleCenter; UnitService.getUnitNamesUnitIds(unitids1.TrimEnd(','));
// }
// if(Grid1.Rows.Count>1)
// {
// recordSheet.ShiftRows(8, 28, Grid1.Rows.Count - 1,true, false);
// for (int j = 1; j < Grid1.Rows.Count; j++)
// {
// recordSheet.CopyRow(6 + j, 7 + j);
// }
// }
// int i = 0;
// foreach (GridRow row in Grid1.Rows)
// {
// foreach (GridColumn column in Grid1.Columns)
// {
// string html = row.Values[column.ColumnIndex].ToString();
// if (column.ColumnID == "tfNumber")
// {
// html = (row.FindControl("labNumber1") as AspNet.Label).Text;
// }
// recordSheet.GetRow(6+ i).GetCell(column.ColumnIndex).SetCellValue(html);
// }
// i++;
// }
// int shiftIndex = Grid1.Rows.Count-1;
// if (Grid4.Rows.Count > 1)
// {
// recordSheet.ShiftRows(shiftIndex + 12, shiftIndex+ 28, Grid4.Rows.Count - 1, true, false);
// for (int j = 1; j < Grid4.Rows.Count; j++)
// {
// recordSheet.CopyRow(shiftIndex+10 + j, shiftIndex+ 11 + j);
// }
// }
// i = 0;
// foreach (GridRow row in Grid4.Rows)
// {
// foreach (GridColumn column in Grid4.Columns)
// {
// string html = row.Values[column.ColumnIndex].ToString();
// if (column.ColumnID == "tfNumber")
// {
// html = (row.FindControl("labNumber4") as AspNet.Label).Text;
// }
// recordSheet.GetRow(shiftIndex + 11 + i).GetCell(column.ColumnIndex).SetCellValue(html);
// }
// i++;
// }
// shiftIndex = Grid1.Rows.Count>1? Grid1.Rows.Count - 1:0+ Grid4.Rows.Count>1? Grid4.Rows.Count -1:0;
// if (Grid5.Rows.Count > 1)
// {
// recordSheet.ShiftRows(shiftIndex + 17, shiftIndex + 28, Grid5.Rows.Count - 1, true, false);
// for (int j = 1; j < Grid5.Rows.Count; j++)
// {
// recordSheet.CopyRow(shiftIndex + 15 + j, shiftIndex + 16 + j);
// }
// }
// i = 0;
// foreach (GridRow row in Grid5.Rows)
// {
// foreach (GridColumn column in Grid5.Columns)
// {
// string html = row.Values[column.ColumnIndex].ToString();
// if (column.ColumnID == "tfNumber")
// {
// html = (row.FindControl("labNumber5") as AspNet.Label).Text;
// }
// recordSheet.GetRow(shiftIndex+16 + i).GetCell(column.ColumnIndex).SetCellValue(html);
// }
//i++;
// }
// shiftIndex = Grid1.Rows.Count>1? Grid1.Rows.Count - 1:0 + Grid4.Rows.Count>1? Grid4.Rows.Count - 1:0 + Grid5.Rows.Count>1? Grid5.Rows.Count - 1:0;
// if (Grid2.Rows.Count > 1)
// {
// recordSheet.ShiftRows(shiftIndex+22, shiftIndex+28, Grid2.Rows.Count - 1, true, false);
// for (int j = 1; j < Grid2.Rows.Count; j++)
// {
// recordSheet.CopyRow(shiftIndex+20 + j, shiftIndex+21 + j);
// }
// }
// i = 0;
// foreach (GridRow row in Grid2.Rows)
// {
// foreach (GridColumn column in Grid2.Columns)
// {
// string html = row.Values[column.ColumnIndex].ToString();
// if (column.ColumnID == "tfNumber")
// {
// html = (row.FindControl("labNumber2") as AspNet.Label).Text;
// }
// recordSheet.GetRow(shiftIndex + 20 + i).GetCell(column.ColumnIndex).SetCellValue(html);
// }
// i++;
// }
// shiftIndex = Grid1.Rows.Count >1? Grid1.Rows.Count - 1:0 + Grid4.Rows.Count>1 ? Grid4.Rows.Count - 1:0 + Grid5.Rows.Count>1 ? Grid5.Rows.Count - 1:0+ Grid2.Rows.Count >1 ? Grid2.Rows.Count - 1:0;
// if (Grid3.Rows.Count > 1)
// {
// recordSheet.ShiftRows(shiftIndex + 27, shiftIndex + 28, Grid3.Rows.Count - 1, true, false);
// for (int j = 1; j < Grid3.Rows.Count; j++)
// {
// recordSheet.CopyRow(shiftIndex + 25 + j, shiftIndex + 26 + j);
// }
// }
// i = 0;
// foreach (GridRow row in Grid3.Rows)
// {
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(0).SetCellValue( (row.FindControl("labNumber3") as AspNet.Label).Text);
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(1).SetCellValue(row.Values[1].ToString());
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(2).SetCellValue(row.Values[2].ToString());
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(3).SetCellValue(row.Values[4].ToString());
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(4).SetCellValue(row.Values[5].ToString());
// if (!string.IsNullOrEmpty(row.Values[6].ToString()))
// {
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(5).SetCellValue((100 * double.Parse(row.Values[6].ToString())).ToString("0.##"));
// }
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(6).SetCellValue(row.Values[8].ToString());
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(7).SetCellValue(row.Values[9].ToString());
// if (!string.IsNullOrEmpty(row.Values[10].ToString()))
// {
// recordSheet.GetRow(shiftIndex + 26 + i).GetCell(8).SetCellValue((100 * double.Parse(row.Values[10].ToString())).ToString("0.##"));
// }
// i++;
// }
// using (FileStream filess = File.OpenWrite(ReportFileName))
// {
// hssfworkbook.Write(filess);
// }
// //PageContext.RegisterStartupScript(Window5.GetShowReference(String.Format("../../ReportPrint/ExReportPrint.aspx?ispop=1&reportId={0}&replaceParameter={1}&varValue={2}&projectId={3}", BLL.Const.HJGL_JointInfoReportId, isoId, varValue, this.CurrUser.LoginProjectId)));
// FileInfo filet = new FileInfo(ReportFileName);
// Response.Clear();
// Response.Charset = "GB2312";
// Response.ContentEncoding = System.Text.Encoding.UTF8;
// // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
// Response.AddHeader("Content-Disposition", "attachment; filename=焊接周报_" + Server.UrlEncode(DateTime.Now.ToString("yyyyMMddhhmmss") + ".xlsx"));
// // 添加头信息,指定文件大小,让浏览器能够显示下载进度
// Response.AddHeader("Content-Length", filet.Length.ToString());
// // 指定返回的是一个不能被客户端读取的流,必须被下载
// Response.ContentType = "application/ms-excel";
// // 把文件流发送到客户端
// Response.WriteFile(filet.FullName);
// // 停止页面的执行
// Response.End();
}
#region 右 键 删 除
/// <summary>
/// 右键删除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click ( object sender , EventArgs e )
{
if ( Grid1 . SelectedRowIndexArray . Length > 0 )
{
foreach ( int rowIndex in Grid1 . SelectedRowIndexArray )
{
string rowID = Grid1 . DataKeys [ rowIndex ] [ 0 ] . ToString ( ) ;
var rep = BLL . NDTReportService . GetNDTReportById ( rowID ) ;
if ( rep ! = null )
{
BLL . NDTReportService . DeleteNDTReportById ( rowID ) ;
}
}
ShowNotify ( "删除成功!" , MessageBoxIcon . Success ) ;
BindGrid ( ) ;
}
}
#endregion
#region 日 期 选 择 事 件
/// <summary>
/// 开始日期选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtStartDate_TextChanged ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( this . txtStartDate . Text . Trim ( ) ) )
{
this . txtEndDate . Text = Funs . GetNewDateTime ( this . txtStartDate . Text . Trim ( ) ) . Value . AddDays ( 6 ) . ToShortDateString ( ) ;
}
}
/// <summary>
/// 结束日期选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtEndDate_TextChanged ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( this . txtEndDate . Text . Trim ( ) ) )
{
this . txtStartDate . Text = Funs . GetNewDateTime ( this . txtEndDate . Text . Trim ( ) ) . Value . AddDays ( - 6 ) . ToShortDateString ( ) ;
}
}
#endregion
}
}